Java Code Examples for org.eclipse.jgit.api.CommitCommand#setMessage()
The following examples show how to use
org.eclipse.jgit.api.CommitCommand#setMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JGitOperator.java From verigreen with Apache License 2.0 | 6 votes |
@Override public String commit(String author, String email, String message) { RevCommit revCommit = null; CommitCommand command = _git.commit(); command.setCommitter(author, email); command.setMessage(message); command.setAll(true); try { revCommit = command.call(); } catch (Throwable e) { throw new RuntimeException("Failed to commit", e); } return revCommit.getId().getName(); }
Example 2
Source File: AbstractGitTest.java From onedev with MIT License | 5 votes |
protected String commit(String comment) { CommitCommand ci = git.commit(); ci.setMessage(comment); ci.setAuthor(user); ci.setCommitter(user); try { return ci.call().name(); } catch (GitAPIException e) { throw new RuntimeException(e); } }
Example 3
Source File: CommitTask.java From ant-git-tasks with Apache License 2.0 | 4 votes |
@Override protected void doExecute() throws BuildException { try { setFailOnError(true); CommitCommand cmd = git.commit(); if (!GitTaskUtils.isNullOrBlankString(message)) { cmd.setMessage(brandedMessage ? GitTaskUtils.BRANDING_MESSAGE + " " + message : message); } else { cmd.setMessage(GitTaskUtils.BRANDING_MESSAGE); } String prefix = getDirectory().getCanonicalPath(); String[] allFiles = getPath().list(); if (!GitTaskUtils.isNullOrBlankString(only)) { cmd.setOnly(only); } else if (allFiles.length > 0) { for (String file : allFiles) { String modifiedFile = translateFilePathUsingPrefix(file, prefix); log("Will commit " + modifiedFile); cmd.setOnly(modifiedFile); } } else { cmd.setAll(true); } GitSettings gitSettings = lookupSettings(); if (gitSettings == null) { throw new MissingRequiredGitSettingsException(); } cmd.setAmend(amend).setAuthor(gitSettings.getIdentity()).setCommitter(gitSettings.getIdentity()); if (reflogComment != null) { cmd.setReflogComment(reflogComment); } RevCommit revCommit = cmd.call(); if (revCommitIdProperty != null) { String revisionId = ObjectId.toString(revCommit.getId()); getProject().setProperty(revCommitIdProperty, revisionId); } log(revCommit.getFullMessage()); } catch (IOException ioe) { throw new GitBuildException(MESSAGE_COMMIT_FAILED, ioe); } catch (GitAPIException ex) { throw new GitBuildException(MESSAGE_COMMIT_FAILED, ex); } }