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

Java MergeStatus类代码示例

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

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



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

示例1: mergeBranch

import org.eclipse.jgit.api.MergeResult.MergeStatus; //导入依赖的package包/类
private boolean mergeBranch( String value, String mergeStrategy ) {
  try {
    ObjectId obj = git.getRepository().resolve( value );
    MergeResult result = git.merge()
      .include( obj )
      .setStrategy( MergeStrategy.get( mergeStrategy ) )
      .call();
    if ( result.getMergeStatus().isSuccessful() ) {
      showMessageBox( BaseMessages.getString( PKG, "Dialog.Success" ), BaseMessages.getString( PKG, "Dialog.Success" ) );
      return true;
    } else {
      showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), result.getMergeStatus().toString() );
      if ( result.getMergeStatus() == MergeStatus.CONFLICTING ) {
        result.getConflicts().keySet().forEach( path -> {
          checkout( path, Constants.HEAD, ".ours" );
          checkout( path, getExpandedName( value, IVCS.TYPE_BRANCH ), ".theirs" );
        } );
        return true;
      }
    }
  } catch ( Exception e ) {
    showMessageBox( BaseMessages.getString( PKG, "Dialog.Error" ), e.getMessage() );
  }
  return false;
}
 
开发者ID:HiromuHota,项目名称:pdi-git-plugin,代码行数:26,代码来源:UIGit.java


示例2: doExecute

import org.eclipse.jgit.api.MergeResult.MergeStatus; //导入依赖的package包/类
@Override
public void doExecute() {
        try {
                PullCommand pullCommand = git.pull().setRebase(rebase);

                if (getProgressMonitor() != null) {
                        pullCommand.setProgressMonitor(getProgressMonitor());
                }

                setupCredentials(pullCommand);
                PullResult pullResult = pullCommand.call();

                if (!pullResult.isSuccessful()) {
                        FetchResult fetchResult = pullResult.getFetchResult();
                        GitTaskUtils.validateTrackingRefUpdates(MESSAGE_PULLED_FAILED, fetchResult.getTrackingRefUpdates());
                        MergeStatus mergeStatus = pullResult.getMergeResult().getMergeStatus();

                        if (!mergeStatus.isSuccessful()) {
                                throw new BuildException(String.format(MESSAGE_PULLED_FAILED_WITH_STATUS, mergeStatus.name()));
                        }
                }
        }
        catch (Exception e) {
                throw new GitBuildException(String.format(MESSAGE_PULLED_FAILED_WITH_URI, getUri()), e);
        }
}
 
开发者ID:rimerosolutions,项目名称:ant-git-tasks,代码行数:27,代码来源:PullTask.java


示例3: remoteToLocal_merge

import org.eclipse.jgit.api.MergeResult.MergeStatus; //导入依赖的package包/类
@Test
public void remoteToLocal_merge() throws Exception {
    pushMirrorSettings(null, null);

    // Mirror an empty git repository, which will;
    // - Create /mirror_state.json
    // - Remove the sample files created by createProject().
    mirroringService.mirror().join();

    // Create a text file, modify it in two branches ('master' and 'fork') and merge 'fork' into 'master'.
    addToGitIndex("alphabets.txt", // 'c' and 'x' are missing.
                  "a\nb\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\ny\nz\n");
    git.commit().setMessage("Add alphabets.txt").call();

    //// Create a new branch 'fork' and add the missing 'x'.
    git.checkout().setCreateBranch(true).setName("fork").call();
    addToGitIndex("alphabets.txt", // Add the missing 'x'.
                  "a\nb\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n");
    final RevCommit commit1 = git.commit().setMessage("Add missing 'x'").call();

    //// Check out 'master' and add the missing 'c'.
    git.checkout().setName("master").call();
    addToGitIndex("alphabets.txt", // Add the missing 'c'.
                  "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\ny\nz\n");
    final RevCommit commit2 = git.commit().setMessage("Add missing 'c'").call();

    //// Merge 'fork' into 'master' to create a merge commit.
    final MergeResult mergeResult = git.merge()
                                       .include(commit1.getId())
                                       .setFastForward(FastForwardMode.NO_FF)
                                       .setMessage("Merge 'fork'").call();

    //// Make sure the merge commit has been added.
    assertThat(mergeResult.getMergeStatus()).isEqualTo(MergeStatus.MERGED);
    final RevCommit lastCommit = git.log().all().call().iterator().next();
    assertThat(lastCommit.getParentCount()).isEqualTo(2);
    assertThat(lastCommit.getParents()).containsExactlyInAnyOrder(commit1, commit2);

    // Run the mirror and ensure alphabets.txt contains all alphabets.
    mirroringService.mirror().join();

    final Entry<JsonNode> expectedMirrorState = expectedMirrorState("/");
    final Entry<String> expectedAlphabets = Entry.ofText(
            "/alphabets.txt",
            "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n");

    assertThat(client.getFiles(projName, REPO_MAIN, Revision.HEAD, "/**").join().values())
            .containsExactlyInAnyOrder(expectedMirrorState, expectedAlphabets);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:50,代码来源:GitMirrorTest.java


示例4: checkResult

import org.eclipse.jgit.api.MergeResult.MergeStatus; //导入依赖的package包/类
private Pair<Boolean, String> checkResult(
         String branchToUpdate,
         String branchHead,
         Pair<Boolean, String> ret,
         MergeResult mergeResult) throws IOException {
     
     if (mergeResult.getMergeStatus().equals(MergeStatus.CONFLICTING)
         || mergeResult.getMergeStatus().equals(MergeStatus.FAILED)) {
         VerigreenLogger.get().log(
                 getClass().getName(),
                 RuntimeUtils.getCurrentMethodName(),
                 String.format(
                         "Merge conflicts for parent_branch:%s into:%s. rejecting commit",
                         branchHead,
                         branchToUpdate));
         reset(_repo.getRef(branchToUpdate).getName());
     } else if (mergeResult.getMergeStatus().equals(MergeStatus.ALREADY_UP_TO_DATE)
                || mergeResult.getMergeStatus().equals(MergeStatus.FAST_FORWARD)) {
         VerigreenLogger.get().log(
                 getClass().getName(),
                 RuntimeUtils.getCurrentMethodName(),
                 String.format(
                         "Merge not needed for parent_branch:%s into:%s",
                         branchHead,
                         branchToUpdate));
         ret = new Pair<>(true, "");
     } else if (mergeResult.getMergeStatus().equals(MergeStatus.MERGED_NOT_COMMITTED)) {
         String autoMergeMessage = createMessageAutoCommit(mergeResult);
String commitId = commit(commited_By_Collector, email_Address, autoMergeMessage );
String adjustCommitId = commitId.substring(0,7) + "_" + commited_By_Collector;
         VerigreenLogger.get().log(
                 getClass().getName(),
                 RuntimeUtils.getCurrentMethodName(),
                 String.format(
                         "Verigreen merge for parent_branch:%s into:%s was not committed. Performing auto commit [%s]",
                         branchHead,
                         branchToUpdate,
                         adjustCommitId));
         ret = new Pair<>(true, adjustCommitId);
     }else if (mergeResult.getMergeStatus().equals(MergeStatus.MERGED)) {
      VerigreenLogger.get().log(
              getClass().getName(),
              RuntimeUtils.getCurrentMethodName(),
              "Merge was made after diverted branch with auto commit");
      ret = new Pair<>(true, "");
      new RestClientImpl().post(CollectorApi.getPostVerigreenNeededRequest(mergeResult.getNewHead().getName().substring(0, 7)));
  }
     return ret;
 }
 
开发者ID:Verigreen,项目名称:verigreen,代码行数:50,代码来源:JGitOperator.java


示例5: execute

import org.eclipse.jgit.api.MergeResult.MergeStatus; //导入依赖的package包/类
@Override
public void execute(Wandora wandora, Context context) {

    try {
        Git git = getGit();
        if(git != null) {
            if(isNotEmpty(getGitRemoteUrl())) {
                PullCommand pull = git.pull();
                String user = getUsername();
                if(user == null) {
                    if(pullUI == null) {
                        pullUI = new PullUI();
                    }
                    pullUI.setUsername(getUsername());
                    pullUI.setPassword(getPassword());
                    pullUI.setRemoteUrl(getGitRemoteUrl());

                    pullUI.openInDialog();

                    if(pullUI.wasAccepted()) {
                        setUsername(pullUI.getUsername());
                        setPassword(pullUI.getPassword());
                        // setGitRemoteUrl(pullUI.getRemoteUrl());    
                        
                        // pull.setRemote(pullUI.getRemoteUrl());
                        if(isNotEmpty(getUsername())) {
                            CredentialsProvider credentialsProvider = new UsernamePasswordCredentialsProvider( getUsername(), getPassword() );
                            pull.setCredentialsProvider(credentialsProvider);
                        }
                    }
                    else {
                        return;
                    }
                }

                setDefaultLogger();
                setLogTitle("Git pull");

                log("Pulling changes from remote repository...");
                PullResult result = pull.call();

                FetchResult fetchResult = result.getFetchResult();
                MergeResult mergeResult = result.getMergeResult();
                MergeStatus mergeStatus = mergeResult.getMergeStatus();

                String fetchResultMessages = fetchResult.getMessages();
                if(isNotEmpty(fetchResultMessages)) {
                    log(fetchResult.getMessages());
                }
                log(mergeStatus.toString());

                if(mergeStatus.equals(MergeStatus.MERGED)) {
                    int a = WandoraOptionPane.showConfirmDialog(wandora, "Reload Wandora project after pull?", "Reload Wandora project after pull?", WandoraOptionPane.YES_NO_OPTION);
                    if(a == WandoraOptionPane.YES_OPTION) {
                        reloadWandoraProject();
                    }
                }
                log("Ready.");
            }
            else {
                log("Repository has no remote origin and can't be pulled. " 
                    + "Initialize repository by cloning remote repository to set the remote origin.");
            }
        }
        else {
            logAboutMissingGitRepository();
        }
    }
    catch(GitAPIException gae) {
        log(gae.toString());
    }
    catch(NoWorkTreeException nwte) {
        log(nwte.toString());
    }
    catch(Exception e) {
        log(e);
    }
    setState(WAIT);
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:80,代码来源:Pull.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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