public class CommitCommand extends GitCommand<RevCommit>
Commit command. It has setters for all
supported options and arguments of this command and a call() method
to finally execute the command.repo| Modifier | Constructor and Description |
|---|---|
protected |
CommitCommand(Repository repo) |
| Modifier and Type | Method and Description |
|---|---|
RevCommit |
call()
Executes the
commit command with all the options and parameters
collected by the setter methods of this class. |
PersonIdent |
getAuthor() |
PersonIdent |
getCommitter() |
String |
getMessage() |
CommitCommand |
setAll(boolean all)
If set to true the Commit command automatically stages files that have
been modified and deleted, but new files not known by the repository are
not affected.
|
CommitCommand |
setAmend(boolean amend)
Used to amend the tip of the current branch.
|
CommitCommand |
setAuthor(PersonIdent author)
Sets the author for this
commit. |
CommitCommand |
setAuthor(String name,
String email)
Sets the author for this
commit. |
CommitCommand |
setCommitter(PersonIdent committer)
Sets the committer for this
commit. |
CommitCommand |
setCommitter(String name,
String email)
Sets the committer for this
commit. |
CommitCommand |
setInsertChangeId(boolean insertChangeId)
If set to true a change id will be inserted into the commit message
An existing change id is not replaced.
|
CommitCommand |
setMessage(String message) |
CommitCommand |
setOnly(String only)
Commit dedicated path only
This method can be called several times to add multiple paths.
|
CommitCommand |
setReflogComment(String reflogComment)
Override the message written to the reflog
|
checkCallable, getRepository, setCallableprotected CommitCommand(Repository repo)
repo - public RevCommit call() throws NoHeadException, NoMessageException, UnmergedPathException, ConcurrentRefUpdateException, JGitInternalException, WrongRepositoryStateException
commit command with all the options and parameters
collected by the setter methods of this class. Each instance of this
class should only be used for one invocation of the command (means: one
call to call())RevCommit object representing the successful commit.NoHeadException - when called on a git repo without a HEAD referenceNoMessageException - when called without specifying a commit messageUnmergedPathException - when the current index contained unmerged paths (conflicts)WrongRepositoryStateException - when repository is not in the right state for committingJGitInternalException - a low-level exception of JGit has occurred. The original
exception can be retrieved by calling
Throwable.getCause(). Expect only
IOException's to be wrapped. Subclasses of
IOException (e.g. UnmergedPathException) are
typically not wrapped here but thrown as original exceptionConcurrentRefUpdateExceptionpublic CommitCommand setMessage(String message)
message - the commit message used for the committhispublic String getMessage()
commitpublic CommitCommand setCommitter(PersonIdent committer)
commit. If no committer is explicitly
specified because this method is never called or called with null
value then the committer will be deduced from config info in repository,
with current time.committer - the committer used for the committhispublic CommitCommand setCommitter(String name, String email)
commit. If no committer is explicitly
specified because this method is never called or called with null
value then the committer will be deduced from config info in repository,
with current time.name - the name of the committer used for the commitemail - the email of the committer used for the committhispublic PersonIdent getCommitter()
commit. If no committer was
specified null is returned and the default
PersonIdent of this repo is used during execution of the
commandpublic CommitCommand setAuthor(PersonIdent author)
commit. If no author is explicitly
specified because this method is never called or called with null
value then the author will be set to the committer.author - the author used for the committhispublic CommitCommand setAuthor(String name, String email)
commit. If no author is explicitly
specified because this method is never called or called with null
value then the author will be set to the committer.name - the name of the author used for the commitemail - the email of the author used for the committhispublic PersonIdent getAuthor()
commit. If no author was
specified null is returned and the default
PersonIdent of this repo is used during execution of the
commandpublic CommitCommand setAll(boolean all)
all - thisJGitInternalException - in case of an illegal combination of arguments/ optionspublic CommitCommand setAmend(boolean amend)
amend - thispublic CommitCommand setOnly(String only)
only - path to committhispublic CommitCommand setInsertChangeId(boolean insertChangeId)
insertChangeId - thispublic CommitCommand setReflogComment(String reflogComment)
reflogComment - thisCopyright © 2012. All Rights Reserved.