org.eclipse.jgit.api.Git.branchCreate()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中org.eclipse.jgit.api.Git.branchCreate()方法的一些代码示例,展示了Git.branchCreate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.branchCreate()方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:branchCreate

Git.branchCreate介绍

[英]Return a command object used to create branches
[中]返回用于创建分支的命令对象

代码示例

代码示例来源:origin: gocd/gocd

void createBranch(String branchName, RevCommit revCommit) throws GitAPIException {
  try {
    git.branchCreate().setName(branchName).setStartPoint(revCommit).call();
  } catch (GitAPIException e) {
    LOGGER.error("[CONFIG_MERGE] Failed to create branch {} at revision {}", branchName, revCommit.getId(), e);
    throw e;
  }
}

代码示例来源:origin: jphp-group/jphp

@Signature
public Memory branchCreate(String name, ArrayMemory settings) throws GitAPIException {
  CreateBranchCommand command = getWrappedObject().branchCreate();
  command.setName(name);
  if (settings != null && settings.isNotNull()) {
    Memory startPoint = settings.valueOfIndex("startPoint");
    if (startPoint.isNotNull()) {
      command.setStartPoint(startPoint.toString());
    }
    command.setForce(settings.valueOfIndex("force").toBoolean());
    Memory upstreamMode = settings.valueOfIndex("upstreamMode");
    if (upstreamMode.isNotNull()) {
      command.setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.valueOf(upstreamMode.toString()));
    }
  }
  return GitUtils.valueOf(command.call());
}

代码示例来源:origin: centic9/jgit-cookbook

git.branchCreate()
    .setName("master")

代码示例来源:origin: centic9/jgit-cookbook

git.branchCreate()
    .setName("master")

代码示例来源:origin: centic9/jgit-cookbook

Ref changes = git.branchCreate().setName("changes").call();
System.out.println("Result of creating the branch: " + changes);

代码示例来源:origin: centic9/jgit-cookbook

Ref changes = git.branchCreate().setName("changes").call();
System.out.println("Result of creating the branch: " + changes);

代码示例来源:origin: centic9/jgit-cookbook

public static void main(String[] args) throws IOException, GitAPIException {
  try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
    try (Git git = new Git(repository)) {
      if(repository.exactRef("refs/heads/testbranch") == null) {
        // first we need to ensure that the remote branch is visible locally
        Ref ref = git.branchCreate().setName("testbranch").setStartPoint("origin/testbranch").call();
        System.out.println("Created local testbranch with ref: " + ref);
      }
      // the diff works on TreeIterators, we prepare two for the two branches
      AbstractTreeIterator oldTreeParser = prepareTreeParser(repository, "refs/heads/testbranch");
      AbstractTreeIterator newTreeParser = prepareTreeParser(repository, "refs/heads/master");
      // then the procelain diff-command returns a list of diff entries
      List<DiffEntry> diff = git.diff().setOldTree(oldTreeParser).setNewTree(newTreeParser).call();
      for (DiffEntry entry : diff) {
        System.out.println("Entry: " + entry);
      }
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

public static void main(String[] args) throws IOException, GitAPIException {
  try (Repository repository = CookbookHelper.openJGitCookbookRepository()) {
    try (Git git = new Git(repository)) {
      if(repository.exactRef("refs/heads/testbranch") == null) {
        // first we need to ensure that the remote branch is visible locally
        Ref ref = git.branchCreate().setName("testbranch").setStartPoint("origin/testbranch").call();
        System.out.println("Created local testbranch with ref: " + ref);
      }
      // the diff works on TreeIterators, we prepare two for the two branches
      AbstractTreeIterator oldTreeParser = prepareTreeParser(repository, "refs/heads/testbranch");
      AbstractTreeIterator newTreeParser = prepareTreeParser(repository, "refs/heads/master");
      // then the procelain diff-command returns a list of diff entries
      List<DiffEntry> diff = git.diff().setOldTree(oldTreeParser).setNewTree(newTreeParser).call();
      for (DiffEntry entry : diff) {
        System.out.println("Entry: " + entry);
      }
    }
  }
}

代码示例来源:origin: centic9/jgit-cookbook

git.branchCreate()
    .setName("testbranch")
    .call();

代码示例来源:origin: centic9/jgit-cookbook

git.branchCreate()
    .setName("testbranch")
    .call();

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

CreateBranchCommand command = git.branchCreate();
command.setName(name);
if (startCommit != null)

代码示例来源:origin: org.jboss.forge.addon/git-impl

@Override
public Ref createBranch(Git git, String branchName) throws GitAPIException
{
 Ref newBranch = git.branchCreate().setName(branchName).call();
 if (newBranch == null)
   throw new RuntimeException("Couldn't create new branch " + branchName);
 return newBranch;
}

代码示例来源:origin: org.uberfire/vfs-jgit

public static void createBranch(final Git git, final String source, final String target) {
  try {
    git.branchCreate().setName(target).setStartPoint(source).call();
  } catch (GitAPIException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: io.hawt/hawtio-git

protected void doCreateBranch(Git git, String fromBranch, String newBranch) throws GitAPIException {
  checkoutBranch(git, fromBranch);
  git.branchCreate().setName(newBranch).call();
  checkoutBranch(git, newBranch);
}

代码示例来源:origin: org.hudsonci.plugins/git

public void branch(String name) throws GitException {
  verifyGitRepository();
  try {
    jGitDelegate.branchCreate().setName(name).call();
  } catch (GitAPIException e) {
    throw new GitException(Messages.GitAPI_Branch_CreateErrorMsg(name), e);
  }
}

代码示例来源:origin: com.societegenerale.ci-droid.tasks-consumer/ci-droid-tasks-consumer-infrastructure

public Ref createBranch(Git git, String branchName) throws GitAPIException {
  return git.branchCreate()
      .setName(branchName)
      .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM)
      .setStartPoint("origin/" + branchName)
      .setForce(true)
      .call();
}

代码示例来源:origin: theonedev/onedev

public void createBranch(String branchName, String branchRevision) {
  try {
    CreateBranchCommand command = git().branchCreate();
    command.setName(branchName);
    RevCommit commit = getRevCommit(branchRevision);
    command.setStartPoint(getRevCommit(branchRevision));
    command.call();
    cacheObjectId(GitUtils.branch2ref(branchName), commit);
  } catch (GitAPIException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.uberfire/uberfire-nio2-jgit

private void updateBranch(final String targetBranchName,
             final org.eclipse.jgit.api.Git git,
             final ObjectId commitId) throws Exception {
  git.branchCreate()
    .setName(targetBranchName)
    .setStartPoint(commitId.name())
    .setForce(true)
    .call();
}

代码示例来源:origin: org.uberfire/uberfire-nio2-jgit

private Ref branch(Git origin, String source, String target) throws Exception {
  final Repository repo = origin.getRepository();
  return org.eclipse.jgit.api.Git.wrap(repo)
                  .branchCreate()
                  .setName(target)
                  .setStartPoint(source)
                  .call();
}

代码示例来源:origin: sheimi/SGit

public void checkoutFromRemote(String remoteBranchName, String branchName)
      throws GitAPIException, JGitInternalException, StopTaskException {
    mRepo.getGit().checkout().setCreateBranch(true).setName(branchName)
        .setStartPoint(remoteBranchName).call();
    mRepo.getGit()
        .branchCreate()
        .setUpstreamMode(
            CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM)
        .setStartPoint(remoteBranchName).setName(branchName)
        .setForce(true).call();
  }
}

相关文章