Search in sources :

Example 1 with CreateBranchCommand

use of org.eclipse.jgit.api.CreateBranchCommand in project che by eclipse.

the class JGitConnection method branchCreate.

@Override
public Branch branchCreate(String name, String startPoint) throws GitException {
    CreateBranchCommand createBranchCommand = getGit().branchCreate().setName(name);
    if (startPoint != null) {
        createBranchCommand.setStartPoint(startPoint);
    }
    try {
        Ref brRef = createBranchCommand.call();
        String refName = brRef.getName();
        String displayName = Repository.shortenRefName(refName);
        return newDto(Branch.class).withName(refName).withDisplayName(displayName).withActive(false).withRemote(false);
    } catch (GitAPIException exception) {
        throw new GitException(exception.getMessage(), exception);
    }
}
Also used : CreateBranchCommand(org.eclipse.jgit.api.CreateBranchCommand) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) Ref(org.eclipse.jgit.lib.Ref) GitException(org.eclipse.che.api.git.exception.GitException)

Aggregations

GitException (org.eclipse.che.api.git.exception.GitException)1 CreateBranchCommand (org.eclipse.jgit.api.CreateBranchCommand)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 Ref (org.eclipse.jgit.lib.Ref)1