当前位置: 首页>>代码示例>>Java>>正文


Java CommitBuilder.setMessage方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.CommitBuilder.setMessage方法的典型用法代码示例。如果您正苦于以下问题:Java CommitBuilder.setMessage方法的具体用法?Java CommitBuilder.setMessage怎么用?Java CommitBuilder.setMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.CommitBuilder的用法示例。


在下文中一共展示了CommitBuilder.setMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: commit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
/**
 * 
 * @param commitBuilder
 * @param treeId
 * @param repo
 * @return
 * @throws UnsupportedEncodingException
 * @throws IOException 
 */
public static ObjectId commit(CommitBuilder commitBuilder, ObjectId treeId, Repository repo) throws UnsupportedEncodingException, IOException {
    commitBuilder.setTreeId(treeId);
    commitBuilder.setMessage(System.currentTimeMillis() + ": My commit!\n");
    PersonIdent person = new PersonIdent("Alex", "[email protected]");
    commitBuilder.setAuthor(person);
    commitBuilder.setCommitter(person);

    commitBuilder.build();

    ObjectInserter commitInserter = repo.newObjectInserter();
    ObjectId commitId = commitInserter.insert(commitBuilder);
    commitInserter.flush();

    updateMasterRecord(repo, commitId);

    System.out.println("Commit Object ID: " + commitId.getName());

    return commitId;
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:29,代码来源:Commands.java

示例2: createCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private ObjectId createCommit(
    Repository repository,
    RevCommit basePatchSetCommit,
    ObjectId tree,
    String commitMessage,
    Timestamp timestamp)
    throws IOException {
  try (ObjectInserter objectInserter = repository.newObjectInserter()) {
    CommitBuilder builder = new CommitBuilder();
    builder.setTreeId(tree);
    builder.setParentIds(basePatchSetCommit.getParents());
    builder.setAuthor(basePatchSetCommit.getAuthorIdent());
    builder.setCommitter(getCommitterIdent(timestamp));
    builder.setMessage(commitMessage);
    ObjectId newCommitId = objectInserter.insert(builder);
    objectInserter.flush();
    return newCommitId;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:ChangeEditModifier.java

示例3: createGroupBranch

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private void createGroupBranch(Project.NameKey project, String ref) throws IOException {
  try (Repository r = repoManager.openRepository(project);
      ObjectInserter oi = r.newObjectInserter();
      RevWalk rw = new RevWalk(r)) {
    ObjectId emptyTree = oi.insert(Constants.OBJ_TREE, new byte[] {});
    PersonIdent ident = new PersonIdent(serverIdent.get(), TimeUtil.nowTs());

    CommitBuilder cb = new CommitBuilder();
    cb.setTreeId(emptyTree);
    cb.setCommitter(ident);
    cb.setAuthor(ident);
    cb.setMessage("Create group");
    ObjectId emptyCommit = oi.insert(cb);

    oi.flush();

    RefUpdate updateRef = r.updateRef(ref);
    updateRef.setExpectedOldObjectId(ObjectId.zeroId());
    updateRef.setNewObjectId(emptyCommit);
    assertThat(updateRef.update(rw)).isEqualTo(RefUpdate.Result.NEW);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:GroupsIT.java

示例4: createMergeCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
public ObjectId createMergeCommit(Map<SubtreeConfig, RevCommit> parentCommits, String message)
		throws IOException {
	PersonIdent latestIdent = getLatestPersonIdent(parentCommits.values());
	DirCache treeDirCache = createTreeDirCache(parentCommits, message);
	List<? extends ObjectId> parentIds = new ArrayList<>(parentCommits.values());
	try (ObjectInserter inserter = repository.newObjectInserter()) {
		ObjectId treeId = treeDirCache.writeTree(inserter);

		PersonIdent repositoryUser = new PersonIdent(repository);
		PersonIdent ident = new PersonIdent(repositoryUser, latestIdent.getWhen().getTime(),
				latestIdent.getTimeZoneOffset());
		CommitBuilder commitBuilder = new CommitBuilder();
		commitBuilder.setTreeId(treeId);
		commitBuilder.setAuthor(ident);
		commitBuilder.setCommitter(ident);
		commitBuilder.setMessage(message);
		commitBuilder.setParentIds(parentIds);
		ObjectId mergeCommit = inserter.insert(commitBuilder);
		inserter.flush();
		return mergeCommit;
	}
}
 
开发者ID:robinst,项目名称:git-merge-repos,代码行数:23,代码来源:SubtreeMerger.java

示例5: rebase

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Nullable
  public static ObjectId rebase(Repository repository, ObjectId source, ObjectId target, PersonIdent committer) {
  	try (	RevWalk revWalk = new RevWalk(repository);
  			ObjectInserter inserter = repository.newObjectInserter();) {
  		RevCommit sourceCommit = revWalk.parseCommit(source);
  		RevCommit targetCommit = revWalk.parseCommit(target);
  		revWalk.setRevFilter(RevFilter.NO_MERGES);
  		List<RevCommit> commits = RevWalkUtils.find(revWalk, sourceCommit, targetCommit);
  		Collections.reverse(commits);
  		RevCommit headCommit = targetCommit;
  		for (RevCommit commit: commits) {
      		ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE.newMerger(repository, true);
      		merger.setBase(commit.getParent(0));
      		if (merger.merge(headCommit, commit)) {
			if (!headCommit.getTree().getId().equals(merger.getResultTreeId())) {
		        CommitBuilder newCommit = new CommitBuilder();
		        newCommit.setAuthor(commit.getAuthorIdent());
		        newCommit.setCommitter(committer);
		        newCommit.setParentId(headCommit);
		        newCommit.setMessage(commit.getFullMessage());
		        newCommit.setTreeId(merger.getResultTreeId());
		        headCommit = revWalk.parseCommit(inserter.insert(newCommit));
			}
      		} else {
      			return null;
      		}
  		}
  		inserter.flush();
  		return headCommit.copy();
  	} catch (IOException e) {
  		throw new RuntimeException(e);
}
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:34,代码来源:GitUtils.java

示例6: merge

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Nullable
  public static ObjectId merge(Repository repository, ObjectId source, ObjectId target, 
  		boolean squash, PersonIdent committer, String commitMessage) {
  	try (	RevWalk revWalk = new RevWalk(repository);
  			ObjectInserter inserter = repository.newObjectInserter();) {
  		RevCommit sourceCommit = revWalk.parseCommit(source);
  		RevCommit targetCommit = revWalk.parseCommit(target);
  		Merger merger = MergeStrategy.RECURSIVE.newMerger(repository, true);
  		if (merger.merge(targetCommit, sourceCommit)) {
        CommitBuilder mergedCommit = new CommitBuilder();
        mergedCommit.setAuthor(sourceCommit.getAuthorIdent());
        mergedCommit.setCommitter(committer);
        if (squash)
        	mergedCommit.setParentId(targetCommit);
        else
        	mergedCommit.setParentIds(targetCommit, sourceCommit);
        mergedCommit.setMessage(commitMessage);
        mergedCommit.setTreeId(merger.getResultTreeId());
        ObjectId mergedCommitId = inserter.insert(mergedCommit);
        inserter.flush();
        return mergedCommitId;
  		} else {
  			return null;
  		}
  	} catch (IOException e) {
  		throw new RuntimeException(e);
}
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:29,代码来源:GitUtils.java

示例7: applyImpl

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Override
protected CommitBuilder applyImpl(RevWalk rw, ObjectInserter ins, ObjectId curr)
    throws OrmException, IOException {
  CommitBuilder cb = new CommitBuilder();
  cb.setMessage("Update draft comments");
  try {
    return storeCommentsInNotes(rw, ins, curr, cb);
  } catch (ConfigInvalidException e) {
    throw new OrmException(e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:ChangeDraftUpdate.java

示例8: createCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private RevCommit createCommit(
    NoteMap map, PersonIdent author, String message, RevCommit... parents) throws IOException {
  CommitBuilder b = new CommitBuilder();
  b.setTreeId(map.writeTree(inserter));
  b.setAuthor(author);
  b.setCommitter(author);
  if (parents.length > 0) {
    b.setParentIds(parents);
  }
  b.setMessage(message);
  ObjectId commitId = inserter.insert(b);
  inserter.flush();
  return revWalk.parseCommit(commitId);
}
 
开发者ID:google,项目名称:git-appraise-eclipse,代码行数:15,代码来源:GitNoteWriter.java

示例9: onSave

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Override
protected boolean onSave(CommitBuilder commit) throws IOException, ConfigInvalidException {
  if (!dirty) {
    return false;
  }
  commit.setMessage("Remove \"My Drafts\" menu items");
  return super.onSave(commit);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:Schema_160.java

示例10: save

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
protected void save(PersonIdent ident, String msg) throws IOException, ConfigInvalidException {
  File path = getPath();
  if (path == null) {
    throw new IOException(project + " does not exist.");
  }

  try (Repository repo = new FileRepository(path);
      ObjectInserter i = repo.newObjectInserter();
      ObjectReader r = repo.newObjectReader();
      RevWalk rw = new RevWalk(r)) {
    inserter = i;
    reader = r;

    RevTree srcTree = revision != null ? rw.parseTree(revision) : null;
    newTree = readTree(srcTree);

    CommitBuilder commit = new CommitBuilder();
    commit.setAuthor(ident);
    commit.setCommitter(ident);
    commit.setMessage(msg);

    onSave(commit);

    ObjectId res = newTree.writeTree(inserter);
    if (res.equals(srcTree)) {
      return;
    }
    commit.setTreeId(res);

    if (revision != null) {
      commit.addParentId(revision);
    }
    ObjectId newRevision = inserter.insert(commit);
    updateRef(repo, ident, newRevision, "commit: " + msg);
    revision = rw.parseCommit(newRevision);
  } finally {
    inserter = null;
    reader = null;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:41,代码来源:VersionedMetaDataOnInit.java

示例11: execute

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
public void execute() {
    final Repository repo = this.git.getRepository();

    final RevCommit latestCommit = git.getLastCommit(branch);
    final RevCommit startCommit = checkIfCommitIsPresentAtBranch(this.git,
                                                                 this.branch,
                                                                 this.startCommitString);

    RevCommit parent = startCommit;
    if (startCommit.getParentCount() > 0) {
        parent = startCommit.getParent(0);
    }

    final CommitBuilder commitBuilder = new CommitBuilder();
    commitBuilder.setParentId(parent);
    commitBuilder.setTreeId(latestCommit.getTree().getId());
    commitBuilder.setMessage(squashedCommitMessage);
    commitBuilder.setAuthor(startCommit.getAuthorIdent());
    commitBuilder.setCommitter(startCommit.getAuthorIdent());

    try (final ObjectInserter odi = repo.newObjectInserter()) {
        final RevCommit squashedCommit = git.resolveRevCommit(odi.insert(commitBuilder));
        git.refUpdate(branch,
                      squashedCommit);
    } catch (ConcurrentRefUpdateException | IOException e) {
        throw new GitException("Error on executing squash.",
                               e);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:30,代码来源:Squash.java

示例12: writeSquashedCommit

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
private static RevCommit writeSquashedCommit(
    RevWalk rw, ObjectInserter inserter, RevCommit parent, RevCommit edit) throws IOException {
  CommitBuilder mergeCommit = new CommitBuilder();
  for (int i = 0; i < parent.getParentCount(); i++) {
    mergeCommit.addParentId(parent.getParent(i));
  }
  mergeCommit.setAuthor(parent.getAuthorIdent());
  mergeCommit.setMessage(edit.getFullMessage());
  mergeCommit.setCommitter(edit.getCommitterIdent());
  mergeCommit.setTreeId(edit.getTree());

  return rw.parseCommit(commit(inserter, mergeCommit));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:ChangeEditUtil.java

示例13: onSave

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Override
protected boolean onSave(CommitBuilder cb) throws IOException, ConfigInvalidException {
  // Two ways to produce a no-op: don't call setIncrement, and call setIncrement(0);
  if (!increment.isPresent()) {
    return false;
  }
  Config cfg = readConfig(CONFIG_FILE);
  cfg.setInt(SECTION, null, NAME, cfg.getInt(SECTION, null, NAME, 0) + increment.get());
  cb.setMessage(String.format("Increment %s.%s by %d", SECTION, NAME, increment.get()));
  saveConfig(CONFIG_FILE, cfg);
  increment = Optional.empty();
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:VersionedMetaDataTest.java

示例14: onSave

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Override
protected boolean onSave(CommitBuilder commit) throws IOException {
  if (Strings.isNullOrEmpty(commit.getMessage())) {
    commit.setMessage("Updated SSH keys\n");
  }

  saveUTF8(AuthorizedKeys.FILE_NAME, AuthorizedKeys.serialize(keys));
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:VersionedAuthorizedKeys.java

示例15: onSave

import org.eclipse.jgit.lib.CommitBuilder; //导入方法依赖的package包/类
@Override
protected boolean onSave(CommitBuilder commit) throws IOException, ConfigInvalidException {
  if (commit.getMessage() == null || "".equals(commit.getMessage())) {
    commit.setMessage("Updated configuration\n");
  }
  saveConfig(fileName, cfg);
  return true;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:ProjectLevelConfig.java


注:本文中的org.eclipse.jgit.lib.CommitBuilder.setMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。