public class Command extends Object
RefTree
.
Unlike ReceiveCommand
(which can only update a reference to an
ObjectId
), 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.
Constructor and Description |
---|
Command(Ref oldRef,
Ref newRef)
Create a command to create, update or delete a reference.
|
Command(RevWalk rw,
ReceiveCommand cmd)
Construct a RefTree command wrapped around a ReceiveCommand.
|
Modifier and Type | Method and Description |
---|---|
static void |
abort(Iterable<Command> commands,
String why)
Set unprocessed commands as failed due to transaction aborted.
|
String |
getMessage() |
Ref |
getNewRef()
New peeled reference.
|
Ref |
getOldRef()
Old peeled reference.
|
String |
getRefName() |
ReceiveCommand.Result |
getResult() |
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() |
public Command(@Nullable Ref oldRef, @Nullable Ref newRef)
At least one of oldRef
or newRef
must be supplied.
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.public Command(RevWalk rw, ReceiveCommand cmd) throws MissingObjectException, IOException
rw
- walk instance to peel the newId
.cmd
- command received from a push client.MissingObjectException
- oldId
or newId
is missing.IOException
- oldId
or newId
cannot be peeled.public static void abort(Iterable<Command> commands, @Nullable String why)
If a command is still ReceiveCommand.Result.NOT_ATTEMPTED
it will be set to
ReceiveCommand.Result.REJECTED_OTHER_REASON
. If why
is non-null its
contents will be used as the message for the first command status.
commands
- commands to mark as failed.why
- optional message to set on the first aborted command.public String getRefName()
public void setResult(ReceiveCommand.Result result)
result
- the command result.public void setResult(ReceiveCommand.Result result, @Nullable String why)
result
- the command result.why
- optional message explaining the result status.public ReceiveCommand.Result getResult()
@Nullable public String getMessage()
@Nullable public Ref getOldRef()
@Nullable public Ref getNewRef()
Copyright © 2018 Eclipse JGit Project. All rights reserved.