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 File: GitStashHandlerV1.java    From orion.server with 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 File: StashApplyCommand.java    From orion.server with 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 File: JGitEnvironmentRepositoryConcurrencyTests.java    From spring-cloud-config with 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 File: TagBasedVersionFactoryTest.java    From gradle-gitsemver with 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 File: MavenIntegrationTest.java    From gitflow-incremental-builder with 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 File: GitControl.java    From juneau with 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 File: GitStashHandlerV1.java    From orion.server with 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();
}