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

Java RebaseCommand类代码示例

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

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



RebaseCommand类属于org.eclipse.jgit.api包,在下文中一共展示了RebaseCommand类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: process

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
@Override
public RebaseResponse process(Repository repository, String message) throws GitAPIException, IOException {

    try (Git git = Git.wrap(repository)) {
        git.commit()
                .setMessage(stripCommentLines(message))
                .setAmend(true).setNoVerify(true).call();

        getRebaseFile(repository, MESSAGE_SQUASH).delete();
        getRebaseFile(repository, MESSAGE_FIXUP).delete();

        createFile(repository, MESSAGE, message);

        RebaseResult result = git.rebase()
                .setOperation(RebaseCommand.Operation.SKIP)
                .runInteractively(handler)
                .call();

        return new RebaseResponse(result);
    }
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:22,代码来源:SquashActionHandler.java


示例2: process

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
@Override
public RebaseResponse process(Repository repository, String message) throws GitAPIException {
    try (Git git = Git.wrap(repository)) {
        git.commit()
                .setAll(true)
                .setAmend(true)
                .setNoVerify(true)
                .setMessage(message)
                .call();

        RebaseResult result = git.rebase()
                .setOperation(RebaseCommand.Operation.CONTINUE)
                .runInteractively(handler)
                .call();

        // 如果 conflict and edit,amend 后 continue 会返回 NOTHING_TO_COMMIT
        // so skip this commit
        if (result.getStatus().equals(RebaseResult.Status.NOTHING_TO_COMMIT)) {
            result = git.rebase().setOperation(RebaseCommand.Operation.SKIP).call();
        }

        return new RebaseResponse(result);
    }
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:25,代码来源:EditActionHandler.java


示例3: process

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
@Override
public RebaseResponse process(Repository repository, String message) throws GitAPIException, IOException {

    try (Git git = Git.wrap(repository)) {
        git.commit()
                .setMessage(message)
                .setAmend(true)
                .setNoVerify(true)
                .call();

        RebaseResult result = git.rebase()
                .setOperation(RebaseCommand.Operation.SKIP)
                .runInteractively(handler)
                .call();

        return new RebaseResponse(result);
    }
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:19,代码来源:RewordActionHandler.java


示例4: setRebaseOperation

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
private void setRebaseOperation(RebaseCommand rebaseCommand, String operation) {
  RebaseCommand.Operation op = RebaseCommand.Operation.BEGIN;

  // If other operation other than 'BEGIN' was specified, set it
  if (operation != null) {
    switch (operation) {
      case REBASE_OPERATION_ABORT:
        op = RebaseCommand.Operation.ABORT;
        break;
      case REBASE_OPERATION_CONTINUE:
        op = RebaseCommand.Operation.CONTINUE;
        break;
      case REBASE_OPERATION_SKIP:
        op = RebaseCommand.Operation.SKIP;
        break;
      default:
        op = RebaseCommand.Operation.BEGIN;
        break;
    }
  }
  rebaseCommand.setOperation(op);
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:JGitConnection.java


示例5: rebase

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
@Override
public boolean rebase(String upStreamBranchName) {
    
    RebaseCommand command = _git.rebase();
    RebaseResult result = null;
    try {
        command.setUpstream(upStreamBranchName);
        result = command.call();
        // if there are merge conflicts (rebase interactive) - reset the repository
        if (!result.getStatus().isSuccessful()) {
            _git.rebase().setOperation(Operation.ABORT).call();
        }
    } catch (Throwable e) {
        throw new RuntimeException(String.format(
                "Failed to rebase with upstream [%s]",
                upStreamBranchName), e);
    }
    
    return result.getStatus().isSuccessful();
}
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:21,代码来源:JGitOperator.java


示例6: rebaseOnTargetBranch

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
private void rebaseOnTargetBranch(Git git, final List<Commit> commits) throws Exception {
    RebaseCommand rebase = git.rebase();
    rebase.setUpstream(request.getTarget().getBranch());
    rebase.setProgressMonitor(new NotificationProgressMonitor(request, notification, progress));
    rebase.runInteractively(new GitUtil.InteractiveRebase(notification, request.getKey(), commits));
    RebaseResult result = rebase.call();
    if(!result.getStatus().isSuccessful()) {
        throw new RuntimeException("Rebase not successful, status " + result.getStatus());
    }
}
 
开发者ID:aslakknutsen,项目名称:github-merge,代码行数:11,代码来源:GitService.java


示例7: rebase

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
@Override
public RebaseResponse rebase(String operation, String branch) throws GitException {
  RebaseResult result;
  RebaseStatus status;
  List<String> failed;
  List<String> conflicts;
  try {
    RebaseCommand rebaseCommand = getGit().rebase();
    setRebaseOperation(rebaseCommand, operation);
    if (branch != null && !branch.isEmpty()) {
      rebaseCommand.setUpstream(branch);
    }
    result = rebaseCommand.call();
  } catch (GitAPIException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
  switch (result.getStatus()) {
    case ABORTED:
      status = RebaseStatus.ABORTED;
      break;
    case CONFLICTS:
      status = RebaseStatus.CONFLICTING;
      break;
    case UP_TO_DATE:
      status = RebaseStatus.ALREADY_UP_TO_DATE;
      break;
    case FAST_FORWARD:
      status = RebaseStatus.FAST_FORWARD;
      break;
    case NOTHING_TO_COMMIT:
      status = RebaseStatus.NOTHING_TO_COMMIT;
      break;
    case OK:
      status = RebaseStatus.OK;
      break;
    case STOPPED:
      status = RebaseStatus.STOPPED;
      break;
    case UNCOMMITTED_CHANGES:
      status = RebaseStatus.UNCOMMITTED_CHANGES;
      break;
    case EDIT:
      status = RebaseStatus.EDITED;
      break;
    case INTERACTIVE_PREPARED:
      status = RebaseStatus.INTERACTIVE_PREPARED;
      break;
    case STASH_APPLY_CONFLICTS:
      status = RebaseStatus.STASH_APPLY_CONFLICTS;
      break;
    default:
      status = RebaseStatus.FAILED;
  }
  conflicts = result.getConflicts() != null ? result.getConflicts() : emptyList();
  failed =
      result.getFailingPaths() != null
          ? new ArrayList<>(result.getFailingPaths().keySet())
          : emptyList();
  return newDto(RebaseResponse.class)
      .withStatus(status)
      .withConflicts(conflicts)
      .withFailed(failed);
}
 
开发者ID:eclipse,项目名称:che,代码行数:64,代码来源:JGitConnection.java


示例8: buildWithPullRebaseUberfireTest

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
@Test
public void buildWithPullRebaseUberfireTest() throws Exception {

    //Setup origin in memory
    final URI originRepo = URI.create("git://repo");
    final JGitFileSystem origin = (JGitFileSystem) ioService.newFileSystem(originRepo,
                                                                           new HashMap<String, Object>() {{
                                                                               put("init",
                                                                                   Boolean.TRUE);
                                                                               put("internal",
                                                                                   Boolean.TRUE);
                                                                               put("listMode",
                                                                                   "ALL");
                                                                           }});
    ioService.startBatch(origin);

    ioService.write(origin.getPath("/dummy/pom.xml"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/pom.xml").toPath())));
    ioService.write(origin.getPath("/dummy/dummyA/src/main/java/dummy/DummyA.java"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/src/main/java/dummy/DummyA.java").toPath())));
    ioService.write(origin.getPath("/dummy/dummyB/src/main/java/dummy/DummyB.java"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/src/main/java/dummy/DummyB.java").toPath())));
    ioService.write(origin.getPath("/dummy/dummyA/pom.xml"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/pom.xml").toPath())));
    ioService.write(origin.getPath("/dummy/dummyB/pom.xml"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/pom.xml").toPath())));
    ioService.endBatch();

    // clone into a regularfs
    Path tmpRootCloned = Files.createTempDirectory("cloned");
    Path tmpCloned = Files.createDirectories(Paths.get(tmpRootCloned.toString(),
                                                       ".clone"));

    final Git cloned = Git.cloneRepository().setURI("git://localhost:9418/repo").setBare(false).setDirectory(tmpCloned.toFile()).call();

    assertNotNull(cloned);

    PullCommand pc = cloned.pull().setRemote("origin").setRebase(Boolean.TRUE);
    PullResult pullRes = pc.call();
    assertTrue(pullRes.getRebaseResult().getStatus().equals(RebaseResult.Status.UP_TO_DATE));// nothing changed yet

    RebaseCommand rb = cloned.rebase().setUpstream("origin/master");
    RebaseResult rbResult = rb.setPreserveMerges(true).call();
    assertTrue(rbResult.getStatus().isSuccessful());

    //Compile the repo
    AFCompiler compiler = MavenCompilerFactory.getCompiler(Decorator.LOG_OUTPUT_AFTER);

    byte[] encoded = Files.readAllBytes(Paths.get(tmpCloned + "/dummy/pom.xml"));
    String pomAsAstring = new String(encoded,
                                     StandardCharsets.UTF_8);
    Assert.assertFalse(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));

    Path prjFolder = Paths.get(tmpCloned + "/dummy/");

    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjFolder);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(),
                                                           info,
                                                           new String[]{MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE},
                                                           new HashMap<>(),
                                                           Boolean.TRUE);

    CompilationResponse res = compiler.compileSync(req);
    if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
        TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(),
                                                  "KieDefaultMavenCompilerOnInMemoryFSTest.buildWithPullRebaseUberfireTest");
    }

    assertTrue(res.isSuccessful());

    Path incrementalConfiguration = Paths.get(prjFolder + "/target/incremental/io.takari.maven.plugins_takari-lifecycle-plugin_compile_compile");
    assertTrue(incrementalConfiguration.toFile().exists());

    encoded = Files.readAllBytes(Paths.get(prjFolder + "/pom.xml"));
    pomAsAstring = new String(encoded,
                              StandardCharsets.UTF_8);
    assertTrue(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));

    TestUtil.rm(tmpRootCloned.toFile());
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:81,代码来源:DefaultMavenCompilerTest.java


示例9: buildWithPullRebaseUberfireTest

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
@Test
public void buildWithPullRebaseUberfireTest() throws Exception {

    //Setup origin in memory
    final URI originRepo = URI.create("git://repo");
    final JGitFileSystem origin = (JGitFileSystem) ioService.newFileSystem(originRepo,
                                                                           new HashMap<String, Object>() {{
                                                                               put("init",
                                                                                   Boolean.TRUE);
                                                                               put("internal",
                                                                                   Boolean.TRUE);
                                                                               put("listMode",
                                                                                   "ALL");
                                                                           }});
    ioService.startBatch(origin);

    ioService.write(origin.getPath("/dummy/pom.xml"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/pom.xml").toPath())));
    ioService.write(origin.getPath("/dummy/dummyA/src/main/java/dummy/DummyA.java"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/src/main/java/dummy/DummyA.java").toPath())));
    ioService.write(origin.getPath("/dummy/dummyB/src/main/java/dummy/DummyB.java"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/src/main/java/dummy/DummyB.java").toPath())));
    ioService.write(origin.getPath("/dummy/dummyA/pom.xml"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyA/pom.xml").toPath())));
    ioService.write(origin.getPath("/dummy/dummyB/pom.xml"),
                    new String(java.nio.file.Files.readAllBytes(new File("src/test/projects/dummy_multimodule_untouched/dummyB/pom.xml").toPath())));
    ioService.endBatch();

    // clone into a regularfs
    Path tmpRootCloned = Files.createTempDirectory("cloned");
    Path tmpCloned = Files.createDirectories(Paths.get(tmpRootCloned.toString(),
                                                       ".clone"));

    final Git cloned = Git.cloneRepository().setURI("git://localhost:9418/repo").setBare(false).setDirectory(tmpCloned.toFile()).call();

    assertNotNull(cloned);

    PullCommand pc = cloned.pull().setRemote("origin").setRebase(Boolean.TRUE);
    PullResult pullRes = pc.call();
    assertTrue(pullRes.getRebaseResult().getStatus().equals(RebaseResult.Status.UP_TO_DATE));// nothing changed yet

    RebaseCommand rb = cloned.rebase().setUpstream("origin/master");
    RebaseResult rbResult = rb.setPreserveMerges(true).call();
    assertTrue(rbResult.getStatus().isSuccessful());

    //Compile the repo
    AFCompiler compiler = KieMavenCompilerFactory.getCompiler(KieDecorator.LOG_OUTPUT_AFTER);

    byte[] encoded = Files.readAllBytes(Paths.get(tmpCloned + "/dummy/pom.xml"));
    String pomAsAstring = new String(encoded,
                                     StandardCharsets.UTF_8);
    Assert.assertFalse(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));

    Path prjFolder = Paths.get(tmpCloned + "/dummy/");

    WorkspaceCompilationInfo info = new WorkspaceCompilationInfo(prjFolder);
    CompilationRequest req = new DefaultCompilationRequest(mavenRepo.toAbsolutePath().toString(),
                                                           info,
                                                           new String[]{MavenCLIArgs.CLEAN, MavenCLIArgs.COMPILE},
                                                           new HashMap<>(),
                                                           Boolean.TRUE);

    CompilationResponse res = compiler.compileSync(req);
    if (res.getMavenOutput().isPresent() && !res.isSuccessful()) {
        TestUtil.writeMavenOutputIntoTargetFolder(res.getMavenOutput().get(),
                                                  "KieDefaultMavenCompilerTest.buildWithPullRebaseUberfireTest");
    }

    assertTrue(res.isSuccessful());

    Path incrementalConfiguration = Paths.get(prjFolder + "/target/incremental/io.takari.maven.plugins_takari-lifecycle-plugin_compile_compile");
    assertTrue(incrementalConfiguration.toFile().exists());

    encoded = Files.readAllBytes(Paths.get(prjFolder + "/pom.xml"));
    pomAsAstring = new String(encoded,
                              StandardCharsets.UTF_8);
    assertTrue(pomAsAstring.contains("<artifactId>takari-lifecycle-plugin</artifactId>"));

    TestUtil.rm(tmpRootCloned.toFile());
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:81,代码来源:KieDefaultMavenCompilerTest.java


示例10: main

import org.eclipse.jgit.api.RebaseCommand; //导入依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
    try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
        // all refs
        try (Git git = new Git(repository)) {
            InteractiveHandler handler = new InteractiveHandler() {
                @Override
                public void prepareSteps(List<RebaseTodoLine> steps) {
                    // the handler receives the list of commits that are rebased, i.e. the ones on the local branch
                    for(RebaseTodoLine step : steps) {
                        // for each step, you can decide which action should be taken
                        // default is PICK
                        try {
                            // by selecting "EDIT", the rebase will stop and ask you to edit the commit-contents
                            step.setAction(Action.EDIT);
                        } catch (IllegalTodoFileModification e) {
                            throw new IllegalStateException(e);
                        }
                    }
                }

                @Override
                public String modifyCommitMessage(String oldMessage) {
                    return oldMessage;
                }
            };

            RebaseResult result = git.rebase().setUpstream("origin/master").runInteractively(handler).call();
            System.out.println("Rebase had state: " + result.getStatus() + ": " + result.getConflicts());

            // because of the "EDIT" in the InteractiveHandler, the rebase was stopped in-between
            // now you can adjust the commit and continue rebasing with setOperation(RebaseCommand.Operation.CONTINUE)
            // to use the local changes for the commit or setOperation(RebaseCommand.Operation.SKIP) to skip this
            // commit (i.e. remove it from the branch!)

            if(!result.getStatus().isSuccessful()) {
                // if rebasing stopped or failed, you can get back to the original state by running it with setOperation(RebaseCommand.Operation.ABORT)
                result = git.rebase().setUpstream("origin/master").runInteractively(handler).setOperation(RebaseCommand.Operation.ABORT).call();
                System.out.println("Aborted reabse with state: " + result.getStatus() + ": " + result.getConflicts());
            }
        }
    }
}
 
开发者ID:centic9,项目名称:jgit-cookbook,代码行数:43,代码来源:RebaseToOriginMaster.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java DtStamp类代码示例发布时间:2022-05-22
下一篇:
Java StatusesService类代码示例发布时间: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