public class ChainedReceiveCommands extends java.lang.Object implements RefCache
ReceiveCommand
s that supports multiple updates per ref.
The underlying behavior of BatchRefUpdate
is undefined (an implementations vary) when
more than one command per ref is added. This class works around that limitation by allowing
multiple updates per ref, as long as the previous new SHA-1 matches the next old SHA-1.
Constructor and Description |
---|
ChainedReceiveCommands(RepoRefCache refCache) |
ChainedReceiveCommands(org.eclipse.jgit.lib.Repository repo) |
Modifier and Type | Method and Description |
---|---|
void |
add(org.eclipse.jgit.transport.ReceiveCommand cmd)
Add a command.
|
void |
addTo(org.eclipse.jgit.lib.BatchRefUpdate bru)
Add commands from this instance to a native JGit batch update.
|
java.util.Optional<org.eclipse.jgit.lib.ObjectId> |
get(java.lang.String refName)
Get the latest value of a ref according to this sequence of commands.
|
java.util.Map<java.lang.String,org.eclipse.jgit.transport.ReceiveCommand> |
getCommands() |
RepoRefCache |
getRepoRefCache() |
boolean |
isEmpty() |
public ChainedReceiveCommands(org.eclipse.jgit.lib.Repository repo)
public ChainedReceiveCommands(RepoRefCache refCache)
public RepoRefCache getRepoRefCache()
public boolean isEmpty()
public void add(org.eclipse.jgit.transport.ReceiveCommand cmd)
cmd
- command to add. If a command has been previously added for the same ref, the new
SHA-1 of the most recent previous command must match the old SHA-1 of this command.public java.util.Optional<org.eclipse.jgit.lib.ObjectId> get(java.lang.String refName) throws java.io.IOException
After the value for a ref is read from the repo once, it is cached as in RepoRefCache
.
get
in interface RefCache
refName
- name of the ref.ObjectId.zeroId()
.java.io.IOException
RefCache.get(String)
public void addTo(org.eclipse.jgit.lib.BatchRefUpdate bru)
Exactly one command per ref will be added to the update. The old SHA-1 will be the old SHA-1 of the first command added to this instance for that ref; the new SHA-1 will be the new SHA-1 of the last command.
bru
- batch updatepublic java.util.Map<java.lang.String,org.eclipse.jgit.transport.ReceiveCommand> getCommands()