Java Code Examples for org.eclipse.jgit.api.CheckoutCommand#setName()

The following examples show how to use org.eclipse.jgit.api.CheckoutCommand#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JGitOperator.java    From verigreen with Apache License 2.0 6 votes vote down vote up
@Override
public String checkout(
        String branchName,
        boolean useBranchNameAsStartPoint,
        boolean createBranch,
        boolean useForce) {
    
    CheckoutCommand command = _git.checkout();
    command.setCreateBranch(createBranch);
    command.setForce(useForce);
    command.setName(branchName);
    if (useBranchNameAsStartPoint) {
        command.setStartPoint(REFS_REMOTES + branchName);
    }
    Ref ref = null;
    try {
        ref = command.call();
    } catch (Throwable e) {
        throw new RuntimeException(
                String.format("Failed to checkout branch [%s]", branchName),
                e);
    }
    
    return ref.getName();
}
 
Example 2
Source File: GitRepository.java    From Getaviz with Apache License 2.0 4 votes vote down vote up
public void reset() throws Exception {
	CheckoutCommand checkout = git.checkout();
	checkout.setName(getDefaultBranch().getName());
	checkout.setCreateBranch(false);
	checkout.call();
}
 
Example 3
Source File: JGitEnvironmentRepositoryIntegrationTests.java    From spring-cloud-config with Apache License 2.0 4 votes vote down vote up
private String getCommitID(Git git, String label) throws GitAPIException {
	CheckoutCommand checkout = git.checkout();
	checkout.setName(label);
	Ref localRef = checkout.call();
	return localRef.getObjectId().getName();
}