Package com.google.gerrit.server.update
Class ChainedReceiveCommands
java.lang.Object
com.google.gerrit.server.update.ChainedReceiveCommands
- All Implemented Interfaces:
RefCache
Collection of
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 Summary
ConstructorsConstructorDescriptionChainedReceiveCommands
(RepoRefCache refCache) ChainedReceiveCommands
(org.eclipse.jgit.lib.Repository repo) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.void
close()
Closes this cache, releasing the references to any underlying resources.Optional<org.eclipse.jgit.lib.ObjectId>
Get the latest value of a ref according to this sequence of commands.Returns an unmodifiable view of commands.boolean
isEmpty()
-
Constructor Details
-
ChainedReceiveCommands
public ChainedReceiveCommands(org.eclipse.jgit.lib.Repository repo) -
ChainedReceiveCommands
-
-
Method Details
-
getRepoRefCache
-
isEmpty
public boolean isEmpty() -
add
public void add(org.eclipse.jgit.transport.ReceiveCommand cmd) Add a command.- Parameters:
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.
-
get
Get the latest value of a ref according to this sequence of commands.After the value for a ref is read from the repo once, it is cached as in
RepoRefCache
.- Specified by:
get
in interfaceRefCache
- Parameters:
refName
- name of the ref.- Returns:
- value of the ref; absent if the ref does not exist in the repo. Never null, and never
present with a value of
ObjectId.zeroId()
. - Throws:
IOException
- See Also:
-
addTo
public void addTo(org.eclipse.jgit.lib.BatchRefUpdate bru) Add commands from this instance to a native JGit batch update.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.
- Parameters:
bru
- batch update
-
getCommands
Returns an unmodifiable view of commands. -
close
public void close()Description copied from interface:RefCache
Closes this cache, releasing the references to any underlying resources.
-