Search in sources :

Example 6 with RevisionSyntaxException

use of org.eclipse.jgit.errors.RevisionSyntaxException in project egit by eclipse.

the class GitFlowRepository method findHead.

/**
 * @param branchName
 * @return HEAD commit on branch branchName or {@literal null} if
 *         {@code branchName} could not be resolved.
 */
@Nullable
public RevCommit findHead(String branchName) {
    try (RevWalk walk = new RevWalk(repository)) {
        try {
            String revstr = R_HEADS + branchName;
            ObjectId head = repository.resolve(revstr);
            if (head == null) {
                return null;
            }
            return walk.parseCommit(head);
        } catch (RevisionSyntaxException | IOException e) {
            throw new RuntimeException(e);
        }
    }
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) RevisionSyntaxException(org.eclipse.jgit.errors.RevisionSyntaxException) IOException(java.io.IOException) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Nullable(org.eclipse.jgit.annotations.Nullable)

Aggregations

IOException (java.io.IOException)6 RevisionSyntaxException (org.eclipse.jgit.errors.RevisionSyntaxException)6 ObjectId (org.eclipse.jgit.lib.ObjectId)5 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 RevWalk (org.eclipse.jgit.revwalk.RevWalk)3 ArrayList (java.util.ArrayList)2 JoinString (org.commonjava.atlas.maven.ident.util.JoinString)2 PlotWalk (org.eclipse.jgit.revplot.PlotWalk)2 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 IInputValidator (org.eclipse.jface.dialogs.IInputValidator)1 StyledString (org.eclipse.jface.viewers.StyledString)1 Nullable (org.eclipse.jgit.annotations.Nullable)1 AnyObjectId (org.eclipse.jgit.lib.AnyObjectId)1 RefDatabase (org.eclipse.jgit.lib.RefDatabase)1 Repository (org.eclipse.jgit.lib.Repository)1 PlotCommitList (org.eclipse.jgit.revplot.PlotCommitList)1 PlotLane (org.eclipse.jgit.revplot.PlotLane)1 RevObject (org.eclipse.jgit.revwalk.RevObject)1