org.eclipse.jgit.api.errors.RefAlreadyExistsException Java Examples

The following examples show how to use org.eclipse.jgit.api.errors.RefAlreadyExistsException. 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 Project: Refactoring-Bot   Author: Refactoring-Bot   File:    License: MIT License 6 votes vote down vote up
 * This method creates a new branch.
 * @param gitConfig
 * @param branchName
 * @param origin
 * @throws BotRefactoringException
 * @throws GitWorkflowException
public void createBranch(GitConfiguration gitConfig, String branchName, String newBranch, String origin)
		throws BotRefactoringException, GitWorkflowException {
	try (Git git = File(botConfig.getBotRefactoringDirectory() + gitConfig.getConfigurationId()))) {
		// Try to create new branch
		Ref ref = git.checkout().setCreateBranch(true).setName(newBranch)
				.setStartPoint(origin + "/" + branchName).call();
		// Pull data
		// If branch already exists
	} catch (RefAlreadyExistsException r) {
		logger.error(r.getMessage(), r);
		throw new BotRefactoringException(
				"Issue was already refactored in the past! The bot database might have been resetted but not the fork itself.");
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		throw new GitWorkflowException("Branch with the name " + "'" + newBranch + "' could not be created!");
Example #2
Source Project: verigreen   Author: Verigreen   File:    License: Apache License 2.0 6 votes vote down vote up
private void submitBranch(
        String newrev,
        String ref,
        JGitOperator jgitOp,
        RevCommit commitMetadata,
        String shortId) {
    String vgBranchName = VerigreenUtils.getVerigreenBranchName(shortId);
   		jgitOp.createBranch(newrev, vgBranchName); 
    catch(RuntimeException e){
   		if (!(e.getCause() instanceof RefAlreadyExistsException))
   			throw e;
    BranchDescriptor branchData = new BranchDescriptor();
    new RestClientImpl().post(GitHookApi.getCreateBranchRequest(branchData));
Example #3
Source Project: smart-testing   Author: arquillian   File:    License: Apache License 2.0 5 votes vote down vote up
private void checkoutAllBranches(Repository repository) throws GitAPIException {
    final Git git = Git.wrap(repository);
    for (final Ref ref : git.branchList().setListMode(ListBranchCommand.ListMode.REMOTE).call()) {
        final String refName = ref.getName();
        final String branchName = refName.substring(refName.lastIndexOf('/') + 1);
        try {
            git.checkout().setCreateBranch(true).setName(branchName).setStartPoint("origin/" + branchName).call();
        } catch (RefAlreadyExistsException e) {
            LOGGER.warning("Already exists, so ignoring " + e.getMessage());
Example #4
Source Project: spring-cloud-config   Author: spring-cloud   File:    License: Apache License 2.0 5 votes vote down vote up
public Ref call() throws GitAPIException, RefAlreadyExistsException,
		RefNotFoundException, InvalidRefNameException, CheckoutConflictException {
	try {
	catch (InterruptedException e) {
Example #5
Source Project: gradle-gitsemver   Author: palantir   File:    License: Apache License 2.0 5 votes vote down vote up
private static Git initializeGitFlow(Repository repo)
        throws RefAlreadyExistsException, RefNotFoundException,
        InvalidRefNameException, GitAPIException {
    Git git = new Git(repo);
    git.commit().setCommitter(COMMITTER).setMessage("initial commit").call();
    return git;
Example #6
Source Project: gitflow-incremental-builder   Author: vackosar   File:    License: MIT License 4 votes vote down vote up
private void checkoutDevelop() throws GitAPIException, CheckoutConflictException, RefAlreadyExistsException,
        RefNotFoundException, InvalidRefNameException {
    Git git = localRepoMock.getGit();
Example #7
Source Project: juneau   Author: apache   File:    License: Apache License 2.0 4 votes vote down vote up
public void branch(String name) throws RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
		CheckoutConflictException, GitAPIException {