• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ChangeApi类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ChangeApi类属于com.google.gerrit.extensions.api.changes包,在下文中一共展示了ChangeApi类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: cherryPickConflict

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void cherryPickConflict() throws Exception {
  PushOneCommit.Result r = createChange();
  CherryPickInput in = new CherryPickInput();
  in.destination = "foo";
  in.message = "it goes to stable branch";
  gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());

  PushOneCommit push =
      pushFactory.create(
          db,
          admin.getIdent(),
          testRepo,
          PushOneCommit.SUBJECT,
          PushOneCommit.FILE_NAME,
          "another content");
  push.to("refs/heads/foo");

  String triplet = project.get() + "~master~" + r.getChangeId();
  ChangeApi orig = gApi.changes().id(triplet);
  assertThat(orig.get().messages).hasSize(1);

  exception.expect(ResourceConflictException.class);
  exception.expectMessage("Cherry pick failed: merge conflict");
  orig.revision(r.getCommit().name()).cherryPick(in);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:RevisionIT.java


示例3: create

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi create(ChangeInput in) throws RestApiException {
    if (in.branch == null) {
        throw new IllegalArgumentException("Branch must be set in change creation input.");
    }

    String url = "/changes/";
    String changeInput = changesParser.generateChangeInput(in);
    JsonElement result = gerritRestClient.postRequest(url, changeInput);
    ChangeInfo info = changesParser.parseSingleChangeInfo(result);
    return new ChangeApiRestClient(gerritRestClient,
        this,
        changesParser,
        commentsParser,
        includedInInfoParser,
        fileInfoParser,
        diffInfoParser,
        addReviewerResultParser,
        reviewResultParser,
        suggestedReviewerInfoParser,
        reviewerInfoParser,
        editInfoParser,
        info.id);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:25,代码来源:ChangesRestClient.java


示例4: revert

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi revert(RevertInput revertInput) throws RestApiException {
    String request = getRequestPath() + "/revert";
    String json = gerritRestClient.getGson().toJson(revertInput);
    gerritRestClient.postRequest(request, json);
    return new ChangeApiRestClient(gerritRestClient,
        changesRestClient,
        changesParser,
        commentsParser,
        includedInInfoParser,
        fileInfoParser,
        diffInfoParser,
        addReviewerResultParser,
        reviewResultParser,
        suggestedReviewerInfoParser,
        reviewerInfoParser,
        editInfoParser,
        id);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:20,代码来源:ChangeApiRestClient.java


示例5: testCreate

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void testCreate() throws Exception {
    ChangesCreateTestCase testCase = new ChangesCreateTestCase().expectUrl("/changes/");
    ChangeInput changeInput = new ChangeInput();
    changeInput.branch = "master";
    String changeInputJsonString = "{}";
    GerritRestClient gerritRestClient = setupGerritRestClient(testCase, changeInputJsonString);
    ChangeInfo changeInfo = new ChangeInfo();
    changeInfo.id = "id";
    ChangesParser changesParser = setupChangesParserForCreate(changeInput,
        changeInputJsonString, changeInfo);

    ChangesRestClient changes = new ChangesRestClient(gerritRestClient, changesParser, null, null, null, null, null, null, null, null, null);

    ChangeApi changeApi = changes.create(changeInput);

    Truth.assertThat(changeApi.id()).isEqualTo(changeInfo.id);
    EasyMock.verify(gerritRestClient, changesParser);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:20,代码来源:ChangesRestClientTest.java


示例6: testAddReviewer

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void testAddReviewer() throws Exception {
    GerritRestClient gerritRestClient = getGerritRestClient(
            "/changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/reviewers",
            "{\"reviewer\":\"jdoe\",\"confirmed\":true}");
    ChangesRestClient changesRestClient = getChangesRestClient(gerritRestClient);

    ChangeApi changeApi = changesRestClient.id("myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940");

    AddReviewerInput input = new AddReviewerInput();
    input.reviewer = "jdoe";
    input.confirmed = true;

    changeApi.addReviewer(input);

    EasyMock.verify(gerritRestClient);
}
 
开发者ID:uwolfer,项目名称:gerrit-rest-java-client,代码行数:18,代码来源:ChangeApiRestClientTest.java


示例7: cherryPick

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
  try {
    return changes.id(cherryPickCommit.apply(commitResource, input)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot cherry pick", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:CommitApiImpl.java


示例8: revert

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi revert(RevertInput in) throws RestApiException {
  try {
    return changeApi.id(revert.apply(change, in)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot revert change", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:ChangeApiImpl.java


示例9: rebase

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi rebase(RebaseInput in) throws RestApiException {
  try {
    return changes.id(rebase.apply(revision, in)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot rebase ps", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:RevisionApiImpl.java


示例10: cherryPick

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
  try {
    return changes.id(cherryPick.apply(revision, in)._number);
  } catch (Exception e) {
    throw asRestApiException("Cannot cherry pick", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:RevisionApiImpl.java


示例11: create

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Override
public ChangeApi create(ChangeInput in) throws RestApiException {
  try {
    ChangeInfo out = createChange.apply(TopLevelResource.INSTANCE, in).value();
    return api.create(changes.parse(new Change.Id(out._number)));
  } catch (Exception e) {
    throw asRestApiException("Cannot create change", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:ChangesImpl.java


示例12: cherryPickwithNoTopic

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void cherryPickwithNoTopic() throws Exception {
  PushOneCommit.Result r = pushTo("refs/for/master");
  CherryPickInput in = new CherryPickInput();
  in.destination = "foo";
  in.message = "it goes to stable branch";
  gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
  ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());

  ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
  assertThat(cherry.get().topic).isNull();
  cherry.current().review(ReviewInput.approve());
  cherry.current().submit();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RevisionIT.java


示例13: 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


示例14: patchWithPath

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void patchWithPath() throws Exception {
  PushOneCommit.Result r = createChange();
  ChangeApi changeApi = gApi.changes().id(r.getChangeId());
  BinaryResult bin = changeApi.revision(r.getCommit().name()).patch(FILE_NAME);
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  bin.writeTo(os);
  String res = new String(os.toByteArray(), UTF_8);
  assertThat(res).isEqualTo(PATCH_FILE_ONLY);

  exception.expect(ResourceNotFoundException.class);
  exception.expectMessage("File not found: nonexistent-file.");
  changeApi.revision(r.getCommit().name()).patch("nonexistent-file");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:RevisionIT.java


示例15: projectChangeNumberReturnsChangeWhenProjectContainsSlashes

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void projectChangeNumberReturnsChangeWhenProjectContainsSlashes() throws Exception {
  Project.NameKey p = createProject("foo/bar");
  ChangeInfo ci = gApi.changes().create(new ChangeInput(p.get(), "master", "msg")).get();
  ChangeApi cApi = gApi.changes().id(p.get(), ci._number);
  assertThat(cApi.get().changeId).isEqualTo(ci.changeId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:ChangeIdIT.java


示例16: changeIdReturnsChange

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void changeIdReturnsChange() throws Exception {
  // ChangeId is not unique and this method needs a unique changeId to work.
  // Hence we generate a new change with a different content.
  ChangeInfo ci =
      gApi.changes().create(new ChangeInput(project.get(), "master", "different message")).get();
  ChangeApi cApi = gApi.changes().id(ci.changeId);
  assertThat(cApi.get()._number).isEqualTo(ci._number);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:ChangeIdIT.java


示例17: checkContentMergedCommit

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void checkContentMergedCommit() throws Exception {
  testRepo
      .branch("HEAD")
      .commit()
      .insertChangeId()
      .message("first commit")
      .add("a.txt", "a contents ")
      .create();
  testRepo
      .git()
      .push()
      .setRemote("origin")
      .setRefSpecs(new RefSpec("HEAD:refs/heads/master"))
      .call();

  // create a change, and cherrypick into master
  PushOneCommit.Result cId = createChange();
  RevCommit commitId = cId.getCommit();
  CherryPickInput cpi = new CherryPickInput();
  cpi.destination = "master";
  cpi.message = "cherry pick the commit";
  ChangeApi orig = gApi.changes().id(cId.getChangeId());
  ChangeApi cherry = orig.current().cherryPick(cpi);
  cherry.current().review(ReviewInput.approve());
  cherry.current().submit();

  ObjectId remoteId = getRemoteHead();
  assertThat(remoteId).isNotEqualTo(commitId);
  assertContentMerged("master", commitId.getName(), "recursive");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:CheckMergeabilityIT.java


示例18: onlyContentMerged

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void onlyContentMerged() throws Exception {
  testRepo
      .branch("HEAD")
      .commit()
      .insertChangeId()
      .message("first commit")
      .add("a.txt", "a contents ")
      .create();
  testRepo
      .git()
      .push()
      .setRemote("origin")
      .setRefSpecs(new RefSpec("HEAD:refs/heads/master"))
      .call();

  // create a change, and cherrypick into master
  PushOneCommit.Result cId = createChange();
  RevCommit commitId = cId.getCommit();
  CherryPickInput cpi = new CherryPickInput();
  cpi.destination = "master";
  cpi.message = "cherry pick the commit";
  ChangeApi orig = gApi.changes().id(cId.getChangeId());
  ChangeApi cherry = orig.current().cherryPick(cpi);
  cherry.current().review(ReviewInput.approve());
  cherry.current().submit();

  ObjectId remoteId = getRemoteHead();
  assertThat(remoteId).isNotEqualTo(commitId);

  ChangeInput in = newMergeChangeInput("master", commitId.getName(), "");
  assertCreateSucceeds(in);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:34,代码来源:CreateChangeIT.java


示例19: openChangeForTargetBranchPreventsMerge

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
@Test
public void openChangeForTargetBranchPreventsMerge() throws Exception {
  gApi.projects().name(project.get()).branch("stable").create(new BranchInput());

  // Propose a change for master, but leave it open for master!
  PushOneCommit change =
      pushFactory.create(db, user.getIdent(), testRepo, "small fix", "a.txt", "2");
  PushOneCommit.Result change2result = change.to("refs/for/master");

  // Now cherry pick to stable
  CherryPickInput in = new CherryPickInput();
  in.destination = "stable";
  in.message = "it goes to stable branch";
  ChangeApi orig = gApi.changes().id(change2result.getChangeId());
  ChangeApi cherry = orig.current().cherryPick(in);
  cherry.current().review(ReviewInput.approve());
  cherry.current().submit();

  // Create a commit locally
  testRepo.git().fetch().setRefSpecs(new RefSpec("refs/heads/stable")).call();

  PushOneCommit.Result change3 = createChange(testRepo, "stable", "test", "a.txt", "3", "");
  submitWithConflict(
      change3.getChangeId(),
      "Failed to submit 1 change due to the following problems:\n"
          + "Change "
          + change3.getPatchSetId().getParentKey().get()
          + ": depends on change that was not submitted");

  assertRefUpdatedEvents();
  assertChangeMergedEvents();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:SubmitByMergeIfNecessaryIT.java


示例20: addReviewers

import com.google.gerrit.extensions.api.changes.ChangeApi; //导入依赖的package包/类
public void addReviewers(Change change, Collection<Account.Id> reviewers)
    throws ReviewerManagerException {
  try (ManualRequestContext ctx = requestContext.openAs(change.getOwner())) {

    ChangeApi cApi = gApi.changes().id(change.getId().get());
    for (Account.Id account : reviewers) {
      cApi.addReviewer(account.toString());
    }

  } catch (RestApiException | OrmException e) {
    log.error("Couldn't add reviewers to the change", e);
    throw new ReviewerManagerException(e);
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_owners,代码行数:15,代码来源:ReviewerManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SimpleTriggerFactoryBean类代码示例发布时间:2022-05-22
下一篇:
Java IOptionRenderer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap