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


Java ChangeApi.get方法代码示例

本文整理汇总了Java中com.google.gerrit.extensions.api.changes.ChangeApi.get方法的典型用法代码示例。如果您正苦于以下问题:Java ChangeApi.get方法的具体用法?Java ChangeApi.get怎么用?Java ChangeApi.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gerrit.extensions.api.changes.ChangeApi的用法示例。


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

示例1: cherryPickSetChangeId

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入方法依赖的package包/类
@Test
public void cherryPickSetChangeId() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  CherryPickInput in = new CherryPickInput();
  in.destination = "foo";
  String id = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbe3f";
  in.message = "it goes to foo branch\n\nChange-Id: " + id;

  gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
  ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());

  assertThat(orig.get().messages).hasSize(1);
  ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);

  ChangeInfo changeInfo = cherry.get();

  // The cherry-pick honors the ChangeId specified in the input message:
  RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
  assertThat(revInfo).isNotNull();
  assertThat(revInfo.commit.message).endsWith(id + "\n");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:RevisionIT.java

示例2: patch

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入方法依赖的package包/类
@Test
public void patch() throws Exception {
  PushOneCommit.Result r = createChange();
  ChangeApi changeApi = gApi.changes().id(r.getChangeId());
  BinaryResult bin = changeApi.revision(r.getCommit().name()).patch();
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  bin.writeTo(os);
  String res = new String(os.toByteArray(), UTF_8);
  ChangeInfo change = changeApi.get();
  RevisionInfo rev = change.revisions.get(change.currentRevision);
  DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
  String date = df.format(rev.commit.author.date);
  assertThat(res).isEqualTo(String.format(PATCH, r.getCommit().name(), date, r.getChangeId()));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RevisionIT.java

示例3: cherryPickToSameBranchWithRebase

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入方法依赖的package包/类
@Test
public void cherryPickToSameBranchWithRebase() throws Exception {
  // Push a new change, then merge it
  PushOneCommit.Result baseChange = createChange();
  String triplet = project.get() + "~master~" + baseChange.getChangeId();
  RevisionApi baseRevision = gApi.changes().id(triplet).current();
  baseRevision.review(ReviewInput.approve());
  baseRevision.submit();

  // Push a new change (change 1)
  PushOneCommit.Result r1 = createChange();

  // Push another new change (change 2)
  String subject = "Test change\n\nChange-Id: Ideadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
  PushOneCommit push =
      pushFactory.create(
          db, admin.getIdent(), testRepo, subject, "another_file.txt", "another content");
  PushOneCommit.Result r2 = push.to("refs/for/master");

  // Change 2's parent should be change 1
  assertThat(r2.getCommit().getParents()[0].name()).isEqualTo(r1.getCommit().name());

  // Cherry pick change 2 onto the same branch
  triplet = project.get() + "~master~" + r2.getChangeId();
  ChangeApi orig = gApi.changes().id(triplet);
  CherryPickInput in = new CherryPickInput();
  in.destination = "master";
  in.message = subject;
  ChangeApi cherry = orig.revision(r2.getCommit().name()).cherryPick(in);
  ChangeInfo cherryInfo = cherry.get();
  assertThat(cherryInfo.messages).hasSize(2);
  Iterator<ChangeMessageInfo> cherryIt = cherryInfo.messages.iterator();
  assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 1.");
  assertThat(cherryIt.next().message).isEqualTo("Uploaded patch set 2.");

  // Parent of change 2 should now be the change that was merged, i.e.
  // change 2 is rebased onto the head of the master branch.
  String newParent =
      cherryInfo.revisions.get(cherryInfo.currentRevision).commit.parents.get(0).commit;
  assertThat(newParent).isEqualTo(baseChange.getCommit().name());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:42,代码来源:RevisionIT.java

示例4: getProjectChangeNumber

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入方法依赖的package包/类
/** Convert a changeId (I0...01) to project~changeNumber (project~00001) */
private String getProjectChangeNumber(String changeId) throws Exception {
  ChangeApi cApi = gApi.changes().id(changeId);
  return cApi.get().project + "~" + cApi.get()._number;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:ChangeIdIT.java

示例5: getTriplet

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入方法依赖的package包/类
/** Convert a changeId (I0...01) to a triplet (project~branch~I0...01) */
private String getTriplet(String changeId) throws Exception {
  ChangeApi cApi = gApi.changes().id(changeId);
  return cApi.get().project + "~" + cApi.get().branch + "~" + changeId;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:ChangeIdIT.java


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