public class ReceiveCommand extends Object
BaseReceivePack
.
This command instance roughly translates to the server side representation of
the RemoteRefUpdate
created by the client.
Modifier and Type | Class and Description |
---|---|
static class |
ReceiveCommand.Result
Result of the update command.
|
static class |
ReceiveCommand.Type
Type of operation requested.
|
Constructor and Description |
---|
ReceiveCommand(ObjectId oldId,
ObjectId newId,
String name)
Create a new command for
BaseReceivePack . |
ReceiveCommand(ObjectId oldId,
ObjectId newId,
String name,
ReceiveCommand.Type type)
Create a new command for
BaseReceivePack . |
Modifier and Type | Method and Description |
---|---|
static void |
abort(Iterable<ReceiveCommand> commands)
Set unprocessed commands as failed due to transaction aborted.
|
void |
disableRefLog()
Don't record this update in the ref's associated reflog.
|
void |
execute(BaseReceivePack rp)
Execute this command during a receive-pack session.
|
static List<ReceiveCommand> |
filter(Iterable<ReceiveCommand> in,
ReceiveCommand.Result want)
Filter a collection of commands according to result.
|
static List<ReceiveCommand> |
filter(List<ReceiveCommand> commands,
ReceiveCommand.Result want)
Filter a list of commands according to result.
|
String |
getMessage()
Get the message associated with a failure status.
|
ObjectId |
getNewId()
Get the requested new value for this ref.
|
String |
getNewSymref()
Get requested new target for a symbolic reference.
|
ObjectId |
getOldId()
Get the old value the client thinks the ref has.
|
String |
getOldSymref()
Get expected old target for a symbolic reference.
|
Ref |
getRef()
Get the ref, if this was advertised by the connection.
|
String |
getRefLogMessage()
Get the message to include in the reflog.
|
String |
getRefName()
Get the name of the ref being updated.
|
ReceiveCommand.Result |
getResult()
Get the current status code of this command.
|
ReceiveCommand.Type |
getType()
Get the type of this command; see
ReceiveCommand.Type . |
boolean |
hasCustomRefLog()
Check whether this command has a custom reflog message setting that should
override defaults in any containing
BatchRefUpdate . |
Boolean |
isForceRefLog()
Check whether the reflog should be written regardless of repo defaults.
|
boolean |
isRefLogDisabled()
Check whether log has been disabled by
disableRefLog() . |
boolean |
isRefLogIncludingResult()
Check whether the reflog message should include the result of the update,
such as fast-forward or force-update.
|
static boolean |
isTransactionAborted(ReceiveCommand cmd)
Check whether a command failed due to transaction aborted.
|
static ReceiveCommand |
link(ObjectId oldId,
String newTarget,
String name)
Create a command to switch a reference from object to symbolic.
|
static ReceiveCommand |
link(String oldTarget,
String newTarget,
String name)
Create a command to switch a symbolic reference's target.
|
void |
setForceRefLog(boolean force)
Force writing a reflog for the updated ref.
|
void |
setRefLogMessage(String msg,
boolean appendStatus)
Set the message to include in the reflog.
|
void |
setResult(ReceiveCommand.Result s)
Set the status of this command.
|
void |
setResult(ReceiveCommand.Result s,
String m)
Set the status of this command.
|
void |
setResult(RefUpdate.Result r)
Set the result of this command.
|
String |
toString() |
static ReceiveCommand |
unlink(String oldTarget,
ObjectId newId,
String name)
Create a command to switch a reference from symbolic to object.
|
void |
updateType(RevWalk walk)
Update the type of this command by checking for fast-forward.
|
public ReceiveCommand(ObjectId oldId, ObjectId newId, String name)
BaseReceivePack
.oldId
- the expected old object id; must not be null. Use
ObjectId.zeroId()
to indicate a
ref creation.newId
- the new object id; must not be null. Use
ObjectId.zeroId()
to indicate a
ref deletion.name
- name of the ref being affected.public ReceiveCommand(ObjectId oldId, ObjectId newId, String name, ReceiveCommand.Type type)
BaseReceivePack
.oldId
- the old object id; must not be null. Use
ObjectId.zeroId()
to indicate a
ref creation.newId
- the new object id; must not be null. Use
ObjectId.zeroId()
to indicate a
ref deletion.name
- name of the ref being affected.type
- type of the command. Must be
ReceiveCommand.Type.CREATE
if oldId
is zero, or
ReceiveCommand.Type.DELETE
if newId
is zero.public static List<ReceiveCommand> filter(Iterable<ReceiveCommand> in, ReceiveCommand.Result want)
in
- commands to filter.want
- desired status to filter by.public static List<ReceiveCommand> filter(List<ReceiveCommand> commands, ReceiveCommand.Result want)
commands
- commands to filter.want
- desired status to filter by.public static void abort(Iterable<ReceiveCommand> commands)
If a command is still
ReceiveCommand.Result.NOT_ATTEMPTED
it
will be set to
ReceiveCommand.Result.REJECTED_OTHER_REASON
.
commands
- commands to mark as failed.public static boolean isTransactionAborted(ReceiveCommand cmd)
cmd
- command.abort(Iterable)
.public static ReceiveCommand link(@NonNull ObjectId oldId, @NonNull String newTarget, @NonNull String name)
oldId
- expected oldId. May be zeroId
to create.newTarget
- new target; must begin with "refs/"
.name
- name of the reference to make symbolic.public static ReceiveCommand link(@Nullable String oldTarget, @NonNull String newTarget, @NonNull String name)
oldTarget
- expected old target. May be null to create.newTarget
- new target; must begin with "refs/"
.name
- name of the reference to make symbolic.public static ReceiveCommand unlink(@NonNull String oldTarget, @NonNull ObjectId newId, @NonNull String name)
oldTarget
- expected old target.newId
- new object identifier. May be zeroId()
to delete.name
- name of the reference to convert from symbolic.public ObjectId getOldId()
@Nullable public String getOldSymref()
public ObjectId getNewId()
@Nullable public String getNewSymref()
public String getRefName()
public ReceiveCommand.Type getType()
ReceiveCommand.Type
.ReceiveCommand.Type
.public Ref getRef()
public ReceiveCommand.Result getResult()
public String getMessage()
public void setRefLogMessage(String msg, boolean appendStatus)
Overrides the default set by setRefLogMessage
on any containing
BatchRefUpdate
.
msg
- the message to describe this change. If null and appendStatus is
false, the reflog will not be updated.appendStatus
- true if the status of the ref change (fast-forward or
forced-update) should be appended to the user supplied message.public void disableRefLog()
Equivalent to setRefLogMessage(null, false)
.
public void setForceRefLog(boolean force)
force
- whether to force.public boolean hasCustomRefLog()
BatchRefUpdate
.
Does not take into account whether #setForceRefLog(boolean)
has
been called.
public boolean isRefLogDisabled()
disableRefLog()
.@Nullable public String getRefLogMessage()
public boolean isRefLogIncludingResult()
@Nullable public Boolean isForceRefLog()
null
if
#setForceRefLog(boolean)
was never called.public void setResult(ReceiveCommand.Result s)
s
- the new status code for this command.public void setResult(ReceiveCommand.Result s, String m)
s
- new status code for this command.m
- optional message explaining the new status.public void updateType(RevWalk walk) throws IOException
If the command's current type is UPDATE, a merge test will be performed
using the supplied RevWalk to determine if getOldId()
is fully
merged into getNewId()
. If some commits are not merged the
update type is changed to
ReceiveCommand.Type.UPDATE_NONFASTFORWARD
.
walk
- an instance to perform the merge test with. The caller must
allocate and release this object.IOException
- either oldId or newId is not accessible in the repository
used by the RevWalk. This usually indicates data corruption,
and the command cannot be processed.public void execute(BaseReceivePack rp)
Sets the status of the command as a side effect.
rp
- receive-pack session.public void setResult(RefUpdate.Result r)
r
- the new result code for this command.Copyright © 2019 Eclipse JGit Project. All rights reserved.