Class Command
- java.lang.Object
-
- org.eclipse.jgit.internal.storage.reftree.Command
-
public class Command extends Object
Command to create, update or delete an entry inside aRefTree
.Unlike
ReceiveCommand
(which can only update a reference to anObjectId
), a RefTree Command can also create, modify or delete symbolic references to a target reference.RefTree Commands may wrap a
ReceiveCommand
to allow callers to process an existing ReceiveCommand against a RefTree.Commands should be passed into
RefTree.apply(java.util.Collection)
for processing.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
abort(Iterable<Command> commands, String why)
Set unprocessed commands as failed due to transaction aborted.String
getMessage()
Get optional message explaining command failure.Ref
getNewRef()
New peeled reference.Ref
getOldRef()
Old peeled reference.String
getRefName()
Get name of the reference affected by this command.ReceiveCommand.Result
getResult()
Get result of executing this command.void
setResult(ReceiveCommand.Result result)
Set the result of this command.void
setResult(ReceiveCommand.Result result, String why)
Set the result of this command.String
toString()
-
-
-
Constructor Detail
-
Command
public Command(@Nullable Ref oldRef, @Nullable Ref newRef)
Create a command to create, update or delete a reference.At least one of
oldRef
ornewRef
must be supplied.- Parameters:
oldRef
- expected value. Null if the ref should not exist.newRef
- desired value, must be peeled if not null and not symbolic. Null to delete the ref.
-
Command
public Command(RevWalk rw, ReceiveCommand cmd) throws MissingObjectException, IOException
Construct a RefTree command wrapped around a ReceiveCommand.- Parameters:
rw
- walk instance to peel thenewId
.cmd
- command received from a push client.- Throws:
MissingObjectException
-oldId
ornewId
is missing.IOException
-oldId
ornewId
cannot be peeled.
-
-
Method Detail
-
abort
public static void abort(Iterable<Command> commands, @Nullable String why)
Set unprocessed commands as failed due to transaction aborted.If a command is still
ReceiveCommand.Result.NOT_ATTEMPTED
it will be set toReceiveCommand.Result.REJECTED_OTHER_REASON
. Ifwhy
is non-null its contents will be used as the message for the first command status.- Parameters:
commands
- commands to mark as failed.why
- optional message to set on the first aborted command.
-
getRefName
public String getRefName()
Get name of the reference affected by this command.- Returns:
- name of the reference affected by this command.
-
setResult
public void setResult(ReceiveCommand.Result result)
Set the result of this command.- Parameters:
result
- the command result.
-
setResult
public void setResult(ReceiveCommand.Result result, @Nullable String why)
Set the result of this command.- Parameters:
result
- the command result.why
- optional message explaining the result status.
-
getResult
public ReceiveCommand.Result getResult()
Get result of executing this command.- Returns:
- result of executing this command.
-
getMessage
@Nullable public String getMessage()
Get optional message explaining command failure.- Returns:
- optional message explaining command failure.
-
getOldRef
@Nullable public Ref getOldRef()
Old peeled reference.- Returns:
- the old reference; null if the command is creating the reference.
-
getNewRef
@Nullable public Ref getNewRef()
New peeled reference.- Returns:
- the new reference; null if the command is deleting the reference.
-
-