本文整理汇总了Java中org.eclipse.jgit.api.CommitCommand.setMessage方法的典型用法代码示例。如果您正苦于以下问题:Java CommitCommand.setMessage方法的具体用法?Java CommitCommand.setMessage怎么用?Java CommitCommand.setMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.api.CommitCommand
的用法示例。
在下文中一共展示了CommitCommand.setMessage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: commit
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
@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();
}
示例2: addAllAndCommit
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
static void addAllAndCommit(Git git, UserProfile user, String commitMsg) throws GitAPIException {
AddCommand addCommand = git.add()
.addFilepattern(".")
.addFilepattern("application.json");
CommitCommand commitCmd = git.commit();
if (user != null && user.name() != null && user.email() != null) {
commitCmd.setCommitter(user.name(), user.email());
}
if (commitMsg != null) {
commitCmd.setMessage(commitMsg);
}
GitHandler.commit(() -> {
addCommand.call();
return commitCmd.call();
});
}
示例3: commit
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
protected void commit(String comment) {
CommitCommand ci = git.commit();
ci.setMessage(comment);
ci.setAuthor(user);
ci.setCommitter(user);
try {
ci.call();
} catch (GitAPIException e) {
throw new RuntimeException(e);
}
}
示例4: call
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
public Git call(final GitOperationsStep gitOperationsStep, Git git,
CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder)
throws IllegalArgumentException, IOException, NoHeadException,
NoMessageException, UnmergedPathsException,
ConcurrentRefUpdateException, WrongRepositoryStateException,
GitAPIException {
CommitCommand cc = git
.commit()
.setAuthor(
gitOperationsStep
.environmentSubstitute(this.authorName == null ? ""
: this.authorName),
gitOperationsStep
.environmentSubstitute(this.authorEmail == null ? ""
: this.authorEmail))
.setCommitter(
gitOperationsStep
.environmentSubstitute(this.committerName == null ? ""
: this.committerName),
gitOperationsStep
.environmentSubstitute(this.committerEmail == null ? ""
: this.committerName));
if (!Const.isEmpty(this.commitMessage)) {
cc = cc.setMessage(gitOperationsStep
.environmentSubstitute(this.commitMessage));
}
cc.setAll(all).setInsertChangeId(insertChangeId).setAmend(amend).call();
return git;
}
示例5: createMember
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
@Override
public void createMember(RequestContext ctx, ResourceState state, Responder responder) throws Exception {
String commitMsg = state.getPropertyAsString("msg");
Boolean includeUntracked = state.getPropertyAsBoolean("include-untracked");
if (includeUntracked == null) {
// Default to include all untracked files
includeUntracked = Boolean.TRUE;
}
// Add changed files to staging ready for commit
AddCommand addCmd = parent.git().add().addFilepattern(".");
if (!includeUntracked) {
// This will prevent new files from being added to the index, and therefore the commit
addCmd.setUpdate(true);
}
// Commit staged changes
RevCommit commit;
CommitCommand commitCmd = parent.git().commit();
if (ctx.securityContext() != null) {
UserProfile user = ctx.securityContext().getUser();
if (user != null && user.name() != null && user.email() != null) {
commitCmd.setCommitter(user.name(), user.email());
}
}
if (commitMsg != null) {
commitCmd.setMessage(commitMsg);
}
commit = GitHandler.commit(() -> {
addCmd.call();
return commitCmd.call();
});
responder.resourceCreated(new GitCommitResource(this, commit));
}
示例6: build
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
/**
* Requires a bare repository. We clone to a random workspace
*
* @throws Exception
* @return The generator currently being worked on
*/
public UniqueBranchGenerator build() throws Exception {
Git git;
File workDirTarget = new File(repo.getDirectory().getAbsolutePath() + "/../../" + UUID.randomUUID().toString());
System.out.println(workDirTarget.getAbsolutePath());
Git.cloneRepository()
.setURI("file://" + repo.getDirectory().getAbsolutePath())
.setBare(false)
.setNoCheckout(false)
.setCloneAllBranches(true)
.setDirectory(workDirTarget).call().close();
File gitMetaDir = new File(workDirTarget.getAbsolutePath() + System.getProperty("file.separator") + ".git");
System.out.println("Setting .git metadata to work in directory: " + gitMetaDir.getAbsolutePath());
git = Git.open(gitMetaDir);
CreateBranchCommand createBranchCommand = git.branchCreate();
createBranchCommand.setName(branchName);
createBranchCommand.call();
git.checkout().setName(branchName).call();
File repoRoot = git.getRepository().getWorkTree();
UUID rand = UUID.randomUUID();
File randomFile = new File(repoRoot, rand.toString() + ".log");
randomFile.createNewFile();
git.add().addFilepattern(".").call();
int cnt = 0;
for (String msg : commitMessages) {
FileUtils.writeStringToFile(randomFile, rand.toString() + "-" + cnt + "\n", true);
CommitCommand commitCommand = git.commit();
commitCommand.setMessage(msg);
commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
commitCommand.call();
cnt++;
}
git.push().setPushAll().call();
git.checkout().setName("master");
git.close();
FileUtils.deleteDirectory(workDirTarget);
return this;
}
示例7: createRepoWithoutBranches
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
/**
* Creates a bare git repository with initial commit and a 'readme.md' file
* containing one line. Author and email is set on commit.
*
* @param repoFolderName
* @return
* @throws IOException
* @throws GitAPIException
*/
public static Repository createRepoWithoutBranches(String repoFolderName) throws IOException, GitAPIException {
//'git init --bare test.git' :
//Initialized empty Git repository in /home/bue/gitlab-repos/pretested-integration-plugin/test.git/
//'ls -al test.git/' :
//total 40
//drwxrwxr-x 7 doe usr 4096 dec 11 00:23 .
//drwxrwxr-x 12 doe usr 4096 dec 11 00:23 ..
//drwxrwxr-x 2 doe usr 4096 dec 11 00:23 branches
//-rw-rw-r-- 1 doe usr 66 dec 11 00:23 config
//-rw-rw-r-- 1 doe usr 73 dec 11 00:23 description
//-rw-rw-r-- 1 doe usr 23 dec 11 00:23 HEAD
//drwxrwxr-x 2 doe usr 4096 dec 11 00:23 hooks
//drwxrwxr-x 2 doe usr 4096 dec 11 00:23 info
//drwxrwxr-x 4 doe usr 4096 dec 11 00:23 objects
//drwxrwxr-x 4 doe usr 4096 dec 11 00:23 refs
File repo = new File(WORKDIR,repoFolderName + ".git"); // bare repo should have suffix .git, and contain what normally in .git
File workDirForRepo = new File(WORKDIR, repoFolderName);
System.out.format(workDirForRepo.getAbsolutePath());
if (repo.exists()) {
System.out.format("EXIST:" + repo.getAbsolutePath());
try {
TestUtilsFactory.destroyDirectory(repo);
} catch (InterruptedException e) {
throw new IOException(e);
}
}
Repository repository = new FileRepository(repo);
repository.create(true);
Git.cloneRepository().setURI("file:///" + repo.getAbsolutePath()).setDirectory(workDirForRepo)
.setBare(false)
.setCloneAllBranches(true)
.setNoCheckout(false)
.call().close();
Git git = Git.open(workDirForRepo);
File readme = new File(workDirForRepo, "readme.md");
if (!readme.exists()) {
FileUtils.writeStringToFile(readme, "#My first repository");
}
git.add().addFilepattern(".");
CommitCommand commit = git.commit();
commit.setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, repository.getBranch(), "Initial commit"));
commit.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
commit.call();
git.push().setPushAll().setRemote("origin").call();
git.close();
FileUtils.deleteDirectory(workDirForRepo);
return repository;
}
示例8: createValidRepository
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
public static Repository createValidRepository(String repoFolderName) throws IOException, GitAPIException {
File repo = new File(WORKDIR,repoFolderName + ".git"); // bare repo should have suffix .git, and contain what normally in .git
if (repo.exists()) {
System.out.format("EXIST:" + repo.getAbsolutePath());
try {
TestUtilsFactory.destroyDirectory(repo);
} catch (InterruptedException e) {
throw new IOException(e);
}
}
File workDirForRepo = new File(WORKDIR, repoFolderName);
Repository repository = new FileRepository(repo);
repository.create(true);
Git.cloneRepository().setURI("file:///" + repo.getAbsolutePath()).setDirectory(workDirForRepo)
.setBare(false)
.setCloneAllBranches(true)
.setNoCheckout(false)
.call().close();
Git git = Git.open(workDirForRepo);
String FEATURE_BRANCH_NAME = "ready/feature_1";
File readme = new File(workDirForRepo + "/readme");
if (!readme.exists()) {
FileUtils.writeStringToFile(readme, "sample text\n");
}
git.add().addFilepattern(readme.getName()).call();
git.commit().setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "commit message 1")).call();
FileUtils.writeStringToFile(readme, "changed sample text\n");
git.add().addFilepattern(readme.getName()).call();
git.commit().setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "commit message 2")).call();
CreateBranchCommand createBranchCommand = git.branchCreate();
createBranchCommand.setName(FEATURE_BRANCH_NAME);
createBranchCommand.call();
git.checkout().setName(FEATURE_BRANCH_NAME).call();
FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 1\n", true);
git.add().addFilepattern(readme.getName()).call();
CommitCommand commitCommand = git.commit();
commitCommand.setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "feature 1 commit 1"));
commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
commitCommand.call();
FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 2\n", true);
git.add().addFilepattern(readme.getName()).call();
commitCommand = git.commit();
commitCommand.setMessage(TestUtilsFactory.createCommitMessageForRepo(repoFolderName, git.getRepository().getBranch(), "feature 1 commit 2"));
commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
commitCommand.call();
git.push().setPushAll().call();
git.checkout().setName("master").call();
FileUtils.deleteDirectory(workDirForRepo);
return repository;
}
示例9: createRepositoryWithMergeConflict
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
public static Repository createRepositoryWithMergeConflict(String repoFolderName) throws IOException, GitAPIException {
String FEATURE_BRANCH_NAME = "ready/feature_1";
File repo = new File(WORKDIR,repoFolderName + ".git"); // bare repo should have suffix .git, and contain what normally in .git
File workDirForRepo = new File(WORKDIR, repoFolderName);
Repository repository = new FileRepository(repo);
repository.create(true);
Git.cloneRepository().setURI("file:///" + repo.getAbsolutePath()).setDirectory(workDirForRepo)
.setBare(false)
.setCloneAllBranches(true)
.setNoCheckout(false)
.call().close();
Git git = Git.open(workDirForRepo);
File readme = new File(workDirForRepo + "/readme");
if (!readme.exists()) {
FileUtils.writeStringToFile(readme, "sample text\n");
}
git.add().addFilepattern(readme.getName()).call();
git.commit().setMessage("commit message 1").call();
FileUtils.writeStringToFile(readme, "changed sample text\n");
git.add().addFilepattern(readme.getName()).call();
git.commit().setMessage("commit message 2").call();
CreateBranchCommand createBranchCommand = git.branchCreate();
createBranchCommand.setName(FEATURE_BRANCH_NAME);
createBranchCommand.call();
git.checkout().setName(FEATURE_BRANCH_NAME).call();
FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 1\n");
git.add().addFilepattern(readme.getName()).call();
CommitCommand commitCommand = git.commit();
commitCommand.setMessage("feature 1 commit 1");
commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
commitCommand.call();
FileUtils.writeStringToFile(readme, "FEATURE_1 branch commit 2\n");
git.add().addFilepattern(readme.getName()).call();
commitCommand = git.commit();
commitCommand.setMessage("feature 1 commit 2");
commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
commitCommand.call();
git.checkout().setName("master").call();
FileUtils.writeStringToFile(readme, "Merge conflict branch commit 2\n");
git.add().addFilepattern(readme.getName()).call();
commitCommand = git.commit();
commitCommand.setMessage("merge conflict message 1");
commitCommand.setAuthor(AUTHOR_NAME, AUTHOR_EMAIL);
commitCommand.call();
git.push().setPushAll().call();
FileUtils.deleteDirectory(workDirForRepo);
return repository;
}
示例10: doExecute
import org.eclipse.jgit.api.CommitCommand; //导入方法依赖的package包/类
@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);
}
}