/**
*
* @param lastCommitId
* @param treeId
* @param repo
* @param lastTreeId
* @return
* @throws IOException
*/
public static ObjectId processCommit(ObjectId lastCommitId,ObjectId treeId,Repository repo,ObjectId lastTreeId) throws IOException {
CommitBuilder commitBuilder = new CommitBuilder();
ObjectId commitId = null;
if (lastCommitId == null) {
commitId = Commands.commit(commitBuilder,treeId,repo);
System.out.println("Initial Commit: " + commitId);
} else {
if (lastTreeId.equals(treeId)) {
// Do nothing,because there is no changes in the tree
System.out.println("Did nothing,because there is no changes in the commited tree!\n");
} else {
commitBuilder.setParentId(lastCommitId);
commitId = Commands.commit(commitBuilder,repo);
System.out.println("Current Commit: " + commitId);
}
}
return commitId;
}
项目:svngit
文件:SVNGitMakeActivityHandler.java
@Override
public void execute() throws SVNException {
DAVResource resource = getRequestedDAVResource(false,false);
FSRepository repos = (FSRepository) resource.getRepository();
myGitFS = (GitFS) repos.getFSFS();
readInput(true);
if (commitBuilders.containsKey(resource.getActivityID())) {
throw new DAVException("<DAV:resource-must-be-null/>",HttpServletResponse.SC_CONFLICT,SVNLogType.NETWORK);
}
// FIXME: I don't kNow what it is
if (!resource.canBeActivity()) {
throw new DAVException("<DAV:activity-location-ok/>",HttpServletResponse.SC_FORBIDDEN,SVNLogType.NETWORK);
}
CommitBuilder builder = new CommitBuilder();
commitBuilders.put(resource.getActivityID(),builder);
setResponseHeader(CACHE_CONTROL_HEADER,CACHE_CONTROL_VALUE);
handleDAVCreated(resource.getResourceURI().getURI(),"Activity",false);
}
项目:gerrit
文件:ChangeEditModifier.java
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;
}
}
@Override
protected boolean onSave(CommitBuilder commit) throws IOException,ConfigInvalidException {
checkLoaded();
if (revision != null) {
commit.setMessage("Update account\n");
} else if (account != null) {
commit.setMessage("Create account\n");
commit.setAuthor(new PersonIdent(commit.getAuthor(),registeredOn));
commit.setCommitter(new PersonIdent(commit.getCommitter(),registeredOn));
}
Config cfg = readConfig(ACCOUNT_CONfig);
writetoConfig(account,cfg);
saveConfig(ACCOUNT_CONfig,cfg);
return true;
}
项目:gerrit
文件:CreateChange.java
private static RevCommit newCommit(
ObjectInserter oi,RevWalk rw,PersonIdent authorIdent,RevCommit mergeTip,String commitMessage)
throws IOException {
CommitBuilder commit = new CommitBuilder();
if (mergeTip == null) {
commit.setTreeId(emptyTreeId(oi));
} else {
commit.setTreeId(mergeTip.getTree().getId());
commit.setParentId(mergeTip);
}
commit.setAuthor(authorIdent);
commit.setCommitter(authorIdent);
commit.setMessage(commitMessage);
return rw.parseCommit(insert(oi,commit));
}
项目:gerrit
文件:PutMessage.java
private ObjectId createCommit(
ObjectInserter objectInserter,Timestamp timestamp)
throws IOException {
CommitBuilder builder = new CommitBuilder();
builder.setTreeId(basePatchSetCommit.getTree());
builder.setParentIds(basePatchSetCommit.getParents());
builder.setAuthor(basePatchSetCommit.getAuthorIdent());
builder.setCommitter(
currentUserProvider.get().asIdentifiedUser().newCommitterIdent(timestamp,tz));
builder.setMessage(commitMessage);
ObjectId newCommitId = objectInserter.insert(builder);
objectInserter.flush();
return newCommitId;
}
项目:gerrit
文件:GroupsIT.java
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);
}
}
项目:gerrit
文件:ChangeNotesParserTest.java
private RevCommit writeCommit(String body,PersonIdent author,boolean initWorkInProgress)
throws Exception {
Change change = newChange(initWorkInProgress);
ChangeNotes notes = newNotes(change).load();
try (ObjectInserter ins = testRepo.getRepository().newObjectInserter()) {
CommitBuilder cb = new CommitBuilder();
cb.setParentId(notes.getRevision());
cb.setAuthor(author);
cb.setCommitter(new PersonIdent(serverIdent,author.getWhen()));
cb.setTreeId(testRepo.tree());
cb.setMessage(body);
ObjectId id = ins.insert(cb);
ins.flush();
RevCommit commit = walk.parseCommit(id);
walk.parseBody(commit);
return commit;
}
}
项目:gerrit
文件:CommitMsgHookTest.java
private void setHEAD() throws Exception {
try (ObjectInserter oi = repository.newObjectInserter()) {
final CommitBuilder commit = new CommitBuilder();
commit.setTreeId(oi.insert(Constants.OBJ_TREE,new byte[] {}));
commit.setAuthor(author);
commit.setCommitter(committer);
commit.setMessage("test\n");
ObjectId commitId = oi.insert(commit);
final RefUpdate ref = repository.updateRef(Constants.HEAD);
ref.setNewObjectId(commitId);
Result result = ref.forceUpdate();
assertWithMessage(Constants.HEAD + " did not change: " + ref.getResult())
.that(result)
.isAnyOf(Result.FAST_FORWARD,Result.FORCED,Result.NEW,Result.NO_CHANGE);
}
}
项目:git-merge-repos
文件:SubtreeMerger.java
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;
}
}
项目:gitplex-mit
文件:GitUtils.java
@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);
}
}
项目:gitplex-mit
文件:GitUtils.java
@Nullable
public static ObjectId merge(Repository repository,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);
}
}
项目:gerrit-ci
文件:JobsServlet.java
public static void updateProjectRef(ObjectId treeId,ObjectInserter objectInserter,Repository repository,CurrentUser currentUser)
throws IOException,NoFilepatternException,GitAPIException {
// Create a branch
Ref gerritCiRef = repository.getRef("refs/Meta/gerrit-ci");
CommitBuilder commitBuilder = new CommitBuilder();
commitBuilder.setTreeId(treeId);
logger.info("treeId: " + treeId);
if (gerritCiRef != null) {
ObjectId prevCommit = gerritCiRef.getobjectId();
logger.info("prevCommit: " + prevCommit);
commitBuilder.setParentId(prevCommit);
}
// build commit
logger.info("Adding git tree : " + treeId);
commitBuilder.setMessage("Modify project build rules.");
final IdentifiedUser iUser = (IdentifiedUser) currentUser;
PersonIdent user = new PersonIdent(currentUser.getUserName(),iUser.getEmailAddresses().iterator().next());
commitBuilder.setAuthor(user);
commitBuilder.setCommitter(user);
ObjectId commitId = objectInserter.insert(commitBuilder);
objectInserter.flush();
logger.info(" Making new commit: " + commitId);
RefUpdate newRef = repository.updateRef("refs/Meta/gerrit-ci");
newRef.setNewObjectId(commitId);
newRef.update();
repository.close();
}
项目:git-appraise-eclipse
文件:AppraiseGitReviewClient.java
/**
* Creates a merged notes commit.
*/
private RevCommit createNotesCommit(NoteMap map,ObjectInserter inserter,RevWalk revWalk,String message,RevCommit... parents) throws IOException {
CommitBuilder commitBuilder = new CommitBuilder();
commitBuilder.setTreeId(map.writeTree(inserter));
commitBuilder.setAuthor(author);
commitBuilder.setCommitter(author);
if (parents.length > 0) {
commitBuilder.setParentIds(parents);
}
commitBuilder.setMessage(message);
ObjectId commitId = inserter.insert(commitBuilder);
inserter.flush();
return revWalk.parseCommit(commitId);
}
项目:git-appraise-eclipse
文件:GitNoteWriter.java
private RevCommit createCommit(
NoteMap map,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);
}
项目:gerrit
文件:VersionedAuthorizedKeysOnInit.java
@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;
}
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;
}
}
项目:gerrit
文件:ChangeEditUtil.java
private static RevCommit writeSquashedCommit(
RevWalk rw,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));
}
项目:gerrit
文件:NotesBranchUtil.java
private RevCommit createCommit(
NoteMap map,RevCommit... parents) throws IOException {
CommitBuilder b = new CommitBuilder();
b.setTreeId(map.writeTree(inserter));
b.setAuthor(author != null ? author : gerritIdent);
b.setCommitter(gerritIdent);
if (parents.length > 0) {
b.setParentIds(parents);
}
b.setMessage(message);
ObjectId commitId = inserter.insert(b);
inserter.flush();
return revWalk.parseCommit(commitId);
}
@Inject
public MetaDataUpdate(
GitReferenceUpdated gitRefUpdated,@Assisted Project.NameKey projectName,@Assisted Repository repository,@Assisted @Nullable BatchRefUpdate batch) {
this.gitRefUpdated = gitRefUpdated;
this.projectName = projectName;
this.repository = repository;
this.batch = batch;
this.commit = new CommitBuilder();
}
项目:gerrit
文件:MergeUtil.java
public CodeReviewCommit createCherryPickFromCommit(
ObjectInserter inserter,Config repoConfig,RevCommit originalCommit,PersonIdent cherryPickCommitterIdent,String commitMsg,CodeReviewRevWalk rw,int parentIndex,boolean ignoreIdenticalTree)
throws MissingObjectException,IncorrectObjectTypeException,IOException,MergeIdenticalTreeException,MergeConflictException {
final ThreeWayMerger m = newThreeWayMerger(inserter,repoConfig);
m.setBase(originalCommit.getParent(parentIndex));
if (m.merge(mergeTip,originalCommit)) {
ObjectId tree = m.getResultTreeId();
if (tree.equals(mergeTip.getTree()) && !ignoreIdenticalTree) {
throw new MergeIdenticalTreeException("identical tree");
}
CommitBuilder mergeCommit = new CommitBuilder();
mergeCommit.setTreeId(tree);
mergeCommit.setParentId(mergeTip);
mergeCommit.setAuthor(originalCommit.getAuthorIdent());
mergeCommit.setCommitter(cherryPickCommitterIdent);
mergeCommit.setMessage(commitMsg);
matchAuthorToCommitterDate(project,mergeCommit);
return rw.parseCommit(inserter.insert(mergeCommit));
}
throw new MergeConflictException("merge conflict");
}
项目:gerrit
文件:MergeUtil.java
public static RevCommit createMergeCommit(
ObjectInserter inserter,String mergeStrategy,PersonIdent committerIndent,RevWalk rw)
throws IOException,MergeConflictException {
if (!MergeStrategy.THEirs.getName().equals(mergeStrategy)
&& rw.isMergedInto(originalCommit,mergeTip)) {
throw new ChangeAlreadyMergedException(
"'" + originalCommit.getName() + "' has already been merged");
}
Merger m = newMerger(inserter,repoConfig,mergeStrategy);
if (m.merge(false,mergeTip,originalCommit)) {
ObjectId tree = m.getResultTreeId();
CommitBuilder mergeCommit = new CommitBuilder();
mergeCommit.setTreeId(tree);
mergeCommit.setParentIds(mergeTip,originalCommit);
mergeCommit.setAuthor(committerIndent);
mergeCommit.setCommitter(committerIndent);
mergeCommit.setMessage(commitMsg);
return rw.parseCommit(inserter.insert(mergeCommit));
}
List<String> conflicts = ImmutableList.of();
if (m instanceof ResolveMerger) {
conflicts = ((ResolveMerger) m).getUnmergedpaths();
}
throw new MergeConflictException(createConflictMessage(conflicts));
}
项目:gerrit
文件:MergeUtil.java
private static void matchAuthorToCommitterDate(ProjectState project,CommitBuilder commit) {
if (project.isMatchAuthorToCommitterDate()) {
commit.setAuthor(
new PersonIdent(
commit.getAuthor(),commit.getCommitter().getWhen(),commit.getCommitter().getTimeZone()));
}
}
项目:gerrit
文件:AbstractChangeUpdate.java
/**
* Apply this update to the given inserter.
*
* @param rw walk for reading back any objects needed for the update.
* @param ins inserter to write to; callers should not flush.
* @param curr the current tip of the branch prior to this update.
* @return commit ID produced by inserting this update's commit,or null if this update is a no-op
* and should be skipped. The zero ID is a valid return value,and indicates the ref should be
* deleted.
* @throws OrmException if a Gerrit-level error occurred.
* @throws IOException if a lower-level error occurred.
*/
final ObjectId apply(RevWalk rw,ObjectInserter ins,ObjectId curr)
throws OrmException,IOException {
if (isEmpty()) {
return null;
}
// Allow this method to proceed even if migration.failChangeWrites() = true.
// This may be used by an auto-rebuilding step that the caller does not plan
// to actually store.
checkArgument(rw.getobjectReader().getCreatedFromInserter() == ins);
checkNotReadOnly();
ObjectId z = ObjectId.zeroId();
CommitBuilder cb = applyImpl(rw,ins,curr);
if (cb == null) {
result = z;
return z; // Impl intends to delete the ref.
} else if (cb == NO_OP_UPDATE) {
return null; // Impl is a no-op.
}
cb.setAuthor(authorIdent);
cb.setCommitter(new PersonIdent(serverIdent,when));
if (!curr.equals(z)) {
cb.setParentId(curr);
} else {
cb.setParentIds(); // Ref is currently nonexistent,commit has no parents.
}
if (cb.getTreeId() == null) {
if (curr.equals(z)) {
cb.setTreeId(emptyTree(ins)); // No parent,assume empty tree.
} else {
RevCommit p = rw.parseCommit(curr);
cb.setTreeId(p.getTree()); // copy tree from parent.
}
}
result = ins.insert(cb);
return result;
}
项目:gerrit
文件:RobotCommentUpdate.java
@Override
protected CommitBuilder applyImpl(RevWalk rw,IOException {
CommitBuilder cb = new CommitBuilder();
cb.setMessage("Update robot comments");
try {
return storeCommentsInNotes(rw,curr,cb);
} catch (ConfigInvalidException e) {
throw new OrmException(e);
}
}
项目:gerrit
文件:ChangeDraftUpdate.java
@Override
protected CommitBuilder applyImpl(RevWalk rw,IOException {
CommitBuilder cb = new CommitBuilder();
cb.setMessage("Update draft comments");
try {
return storeCommentsInNotes(rw,cb);
} catch (ConfigInvalidException e) {
throw new OrmException(e);
}
}
项目:gerrit
文件:VersionedAccountPreferences.java
项目:gerrit
文件:VersionedAuthorizedKeys.java
@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;
}
项目:gerrit
文件:RebaseChangeOp.java
/**
* Rebase a commit.
*
* @param ctx repo context.
* @param original the commit to rebase.
* @param base base to rebase against.
* @return the rebased commit.
* @throws MergeConflictException the rebase Failed due to a merge conflict.
* @throws IOException the merge Failed for another reason.
*/
private RevCommit rebaseCommit(
RepoContext ctx,RevCommit original,ObjectId base,String commitMessage)
throws ResourceConflictException,IOException {
RevCommit parentCommit = original.getParent(0);
if (base.equals(parentCommit)) {
throw new ResourceConflictException("Change is already up to date.");
}
ThreeWayMerger merger =
newMergeUtil().newThreeWayMerger(ctx.getInserter(),ctx.getRepoView().getConfig());
merger.setBase(parentCommit);
merger.merge(original,base);
if (merger.getResultTreeId() == null) {
throw new MergeConflictException(
"The change Could not be rebased due to a conflict during merge.");
}
CommitBuilder cb = new CommitBuilder();
cb.setTreeId(merger.getResultTreeId());
cb.setParentId(base);
cb.setAuthor(original.getAuthorIdent());
cb.setMessage(commitMessage);
if (committerIdent != null) {
cb.setCommitter(committerIdent);
} else {
cb.setCommitter(ctx.getIdentifiedUser().newCommitterIdent(ctx.getWhen(),ctx.getTimeZone()));
}
if (matchAuthorToCommitterDate) {
cb.setAuthor(
new PersonIdent(
cb.getAuthor(),cb.getCommitter().getWhen(),cb.getCommitter().getTimeZone()));
}
ObjectId objectId = ctx.getInserter().insert(cb);
ctx.getInserter().flush();
return ctx.getRevWalk().parseCommit(objectId);
}
项目:gerrit
文件:Schema_146.java
private ObjectId createInitialEmptyCommit(
ObjectInserter oi,ObjectId emptyTree,Timestamp registrationDate) throws IOException {
PersonIdent ident = new PersonIdent(serverIdent,registrationDate);
CommitBuilder cb = new CommitBuilder();
cb.setTreeId(emptyTree);
cb.setCommitter(ident);
cb.setAuthor(ident);
cb.setMessage(CREATE_ACCOUNT_MSG);
return oi.insert(cb);
}
项目:gerrit
文件:Schema_160.java
@Override
protected boolean onSave(CommitBuilder commit) throws IOException,ConfigInvalidException {
if (!dirty) {
return false;
}
commit.setMessage("Remove \"My Drafts\" menu items");
return super.onSave(commit);
}
项目:gerrit
文件:SubmitTypeRuleIT.java
@Override
protected boolean onSave(CommitBuilder commit) throws IOException,ConfigInvalidException {
TestSubmitRuleInput in = new TestSubmitRuleinput();
in.rule = rule;
try {
gApi.changes().id(testChangeId.get()).current().testSubmitType(in);
} catch (RestApiException e) {
throw new ConfigInvalidException("Invalid submit type rule",e);
}
saveUTF8(FILENAME,rule);
return true;
}
项目:gerrit
文件:NoteDbOnlyIT.java
private ObjectId newCommit(RevWalk rw,ObjectId parent,String msg)
throws IOException {
PersonIdent ident = serverIdent.get();
CommitBuilder cb = new CommitBuilder();
cb.setParentId(parent);
cb.setTreeId(rw.parseCommit(parent).getTree());
cb.setMessage(msg);
cb.setAuthor(ident);
cb.setCommitter(ident);
return ins.insert(Constants.OBJ_COMMIT,cb.build());
}
private MetaDataUpdate newMetaDataUpdate(@Nullable BatchRefUpdate bru) {
MetaDataUpdate u = new MetaDataUpdate(GitReferenceUpdated.disABLED,project,repo,bru);
CommitBuilder cb = newCommitBuilder();
u.getCommitBuilder().setAuthor(cb.getAuthor());
u.getCommitBuilder().setCommitter(cb.getCommitter());
return u;
}