@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()); }
command.setStartPoint(startPoint); if (upstreamMode != null) command.setUpstreamMode(upstreamMode); command.call();
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(); }
/** * Create a local branch for remote tracking if it doesn't exist already. */ protected void createBranchIfNeeded(String branch) throws Exception { fetch(); // in case the branch is not known locally if (localRepo.findRef(branch) == null) { git.branchCreate() .setName(branch) .setUpstreamMode(SetupUpstreamMode.TRACK) .setStartPoint("origin/" + branch) .call(); } }
git._branchCreate() .setName(localBranch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint(remote.getK1() + "/" + localBranch) .setForce(true) git._branchCreate() .setName(branch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint(remote.getK1() + "/" + branch) .setForce(true)
@Override public Void call() { try { git.branchCreate() .setName(branchName) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + branchName) .setForce(true) .call(); git.checkout().setName(branchName).call(); } catch (final GitAPIException e) { LOGGER.error("Unable to create/checkout branch " + branchName, e); } return null; } });
@Override public Void call() { try { git.branchCreate() .setName(branchName) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + branchName) .setForce(true) .call(); git.checkout().setName(branchName).call(); } catch (final GitAPIException e) { LOGGER.error("Unable to create/checkout branch " + branchName, e); } return null; } });
.setUpstreamMode( CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM ) .setStartPoint( "upstream/master" ) .setForce( true )
private void overrideBranchNames(final Repository repository, final RevWalk revWalk, final Map<ObjectId, ObjectId> commitMap) throws AmbiguousObjectException, IncorrectObjectTypeException, IOException, MissingObjectException, GitAPIException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException { for (String branchName : branches) { if (branchName.equals("HEAD")) { continue; } final ObjectId oldBranchTipId = repository.resolve(branchName); final ObjectId newBranchTipId = closestMappedAncestorOrSelf(commitMap, revWalk.parseCommit(oldBranchTipId))[0]; final RevCommit newBranchTip = revWalk.parseCommit(newBranchTipId); org.eclipse.jgit.api.Git.wrap(repository) .branchCreate() .setName(branchName) .setForce(true) .setStartPoint(newBranchTip) .setUpstreamMode(SetupUpstreamMode.NOTRACK) .call(); } }
public void switchBranch(String branchName) throws RefNotFoundException, Exception { Repository repository = git.getRepository(); if(branchName != null && !repository.getBranch().equals(branchName)) { log.info("Switching branch from {} to {}", repository.getBranch(), branchName); CheckoutCommand checkout = git.checkout(); if(isTag(branchName)) { checkout.setName(branchName); } else { checkout.setName("refs/heads/"+branchName); if(repository.getRef("refs/heads/"+ branchName) == null) { CreateBranchCommand create = git.branchCreate(); create.setName(branchName); create.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM); create.setStartPoint("origin/"+branchName); create.call(); } } checkout.call(); } }
git.branchCreate() .setName(branch) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .setStartPoint(Constants.DEFAULT_REMOTE_NAME + "/" + branch) .call();
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(); } }
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(); } }
if (branchName != null && branchName.endsWith(targetRef)) ref = repo.branchCreate().setName(targetRef).setUpstreamMode(SetupUpstreamMode.TRACK) .setStartPoint("origin/" + targetRef).call(); ref = repo.branchCreate().setName(version).setUpstreamMode(SetupUpstreamMode.TRACK) .setStartPoint("origin/" + version).call();
command.setStartPoint(startPoint); if (upstreamMode != null) command.setUpstreamMode(upstreamMode); command.call();
command.setStartPoint(startPoint); if (upstreamMode != null) command.setUpstreamMode(upstreamMode); command.call();
git.branchCreate() .setName(context.getMaster()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + context.getMaster()) .call(); git.branchCreate() .setName(context.getDevelop()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + context.getDevelop()) .call(); git.branchCreate() .setName(context.getDevelop()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.NOTRACK) .call();
git.branchCreate() .setName(context.getMaster()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + context.getMaster()) .call(); git.branchCreate() .setName(context.getDevelop()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + context.getDevelop()) .call(); git.branchCreate() .setName(context.getDevelop()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.NOTRACK) .call();
git.branchCreate() .setName(context.getMaster()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + context.getMaster()) .call(); git.branchCreate() .setName(context.getDevelop()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.SET_UPSTREAM) .setStartPoint("origin/" + context.getDevelop()) .call(); git.branchCreate() .setName(context.getDevelop()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.NOTRACK) .call();