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

The following examples show how to use org.eclipse.jgit.api.errors.InvalidRefNameException. 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: orion.server   Author: eclipse   File: GitStashHandlerV1.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Helper method extracting the StashRef for the stash commit rev
 * 
 * @param git
 *            Git handler object
 * @param stashRev
 *            Git commit name
 * @return StashRef wrapper object or <code>null</code> if the given commit is not present in the stash
 * @throws InvalidRefNameException
 * @throws GitAPIException
 */
protected StashRef getStashRef(Git git, String stashRev) throws InvalidRefNameException, GitAPIException {

	if (stashRev == null)
		return null;

	StashListCommand stashList = git.stashList();
	Collection<RevCommit> stashedRefsCollection = stashList.call();

	int k = 0;
	for (RevCommit rev : stashedRefsCollection)
		if (stashRev.equals(rev.getName()))
			return new StashRef(k);
		else
			++k;

	return null;
}
 
Example #2
Source Project: orion.server   Author: eclipse   File: StashApplyCommand.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private ObjectId getStashId() throws GitAPIException {
	final String revision = stashRef != null ? stashRef : DEFAULT_REF;
	final ObjectId stashId;
	try {
		stashId = repo.resolve(revision);
	} catch (IOException e) {
		throw new InvalidRefNameException(MessageFormat.format(JGitText.get().stashResolveFailed, revision), e);
	}
	if (stashId == null)
		throw new InvalidRefNameException(MessageFormat.format(JGitText.get().stashResolveFailed, revision));
	return stashId;
}
 
Example #3
Source Project: spring-cloud-config   Author: spring-cloud   File: JGitEnvironmentRepositoryConcurrencyTests.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Ref call() throws GitAPIException, RefAlreadyExistsException,
		RefNotFoundException, InvalidRefNameException, CheckoutConflictException {
	try {
		Thread.sleep(250);
	}
	catch (InterruptedException e) {
		e.printStackTrace();
	}
	return super.call();
}
 
Example #4
Source Project: gradle-gitsemver   Author: palantir   File: TagBasedVersionFactoryTest.java    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 #5
Source Project: gitflow-incremental-builder   Author: vackosar   File: MavenIntegrationTest.java    License: MIT License 4 votes vote down vote up
private void checkoutDevelop() throws GitAPIException, CheckoutConflictException, RefAlreadyExistsException,
        RefNotFoundException, InvalidRefNameException {
    Git git = localRepoMock.getGit();
    git.reset().setMode(ResetCommand.ResetType.HARD).setRef("HEAD").call();
    git.checkout().setName("develop").call();
}
 
Example #6
Source Project: juneau   Author: apache   File: GitControl.java    License: Apache License 2.0 4 votes vote down vote up
public void branch(String name) throws RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
		CheckoutConflictException, GitAPIException {
	git.checkout().setName(name).setStartPoint("origin/".concat(name)).call();
}
 
Example #7
Source Project: orion.server   Author: eclipse   File: GitStashHandlerV1.java    License: Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Helper method returning whether the stash is empty or not
 * 
 * @param git
 *            Git handler object
 * @return <code>true</code> iff the git stash is empty
 * @throws InvalidRefNameException
 * @throws GitAPIException
 */
protected boolean isStashEmpty(Git git) throws InvalidRefNameException, GitAPIException {
	StashListCommand stashList = git.stashList();
	Collection<RevCommit> stashedRefsCollection = stashList.call();
	return stashedRefsCollection.isEmpty();
}