org.gitective.core
Class CommitUtils

java.lang.Object
  extended by org.gitective.core.CommitUtils

public abstract class CommitUtils
extends Object

Utilities for dealing with Git commits.

This class provides helpers for finding the commits that branches and tags reference.


Constructor Summary
CommitUtils()
           
 
Method Summary
static org.eclipse.jgit.revwalk.RevCommit getBase(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId... commits)
          Get the common base commit of the given commits.
static org.eclipse.jgit.revwalk.RevCommit getBase(org.eclipse.jgit.lib.Repository repository, String... revisions)
          Get the common base commit between the given revisions.
static Collection<org.eclipse.jgit.revwalk.RevCommit> getBranches(org.eclipse.jgit.lib.Repository repository)
          Get all the commits that branches in the given repository reference.
static org.eclipse.jgit.revwalk.RevCommit getCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId commitId)
          Get the commit with the given id
static org.eclipse.jgit.revwalk.RevCommit getCommit(org.eclipse.jgit.lib.Repository repository, String revision)
          Get the commit that the revision references.
static org.eclipse.jgit.revwalk.RevCommit getHead(org.eclipse.jgit.lib.Repository repository)
          Get the HEAD commit in the given repository.
static org.eclipse.jgit.revwalk.RevCommit getLastCommit(org.eclipse.jgit.lib.Repository repository, String path)
          Find the commit that last changed the given path starting at the commit that HEAD currently points to
static org.eclipse.jgit.revwalk.RevCommit getLastCommit(org.eclipse.jgit.lib.Repository repository, String revision, String path)
          Find the commit that last changed the given path starting with the commit at the given revision
static org.eclipse.jgit.revwalk.RevCommit getMaster(org.eclipse.jgit.lib.Repository repository)
          Get the commit at the tip of the master branch in the given repository.
static org.eclipse.jgit.revwalk.RevCommit getRef(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.Ref ref)
          Get the commit for the given reference.
static org.eclipse.jgit.revwalk.RevCommit getRef(org.eclipse.jgit.lib.Repository repository, String refName)
          Get the commit that the given name references.
static Collection<org.eclipse.jgit.revwalk.RevCommit> getTags(org.eclipse.jgit.lib.Repository repository)
          Get all the commits that tags in the given repository reference.
protected static org.eclipse.jgit.revwalk.RevCommit parse(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectId commit)
          Parse a commit from the repository
protected static org.eclipse.jgit.revwalk.RevCommit parse(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.lib.ObjectReader reader, org.eclipse.jgit.lib.ObjectId commit)
          Parse a commit from the object reader
protected static org.eclipse.jgit.lib.ObjectId resolve(org.eclipse.jgit.lib.Repository repository, String revision)
          Resolve the revision string to a commit object id
protected static org.eclipse.jgit.lib.ObjectId strictResolve(org.eclipse.jgit.lib.Repository repository, String revision)
          Resolve the revision string to a commit object id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommitUtils

public CommitUtils()
Method Detail

getCommit

public static org.eclipse.jgit.revwalk.RevCommit getCommit(org.eclipse.jgit.lib.Repository repository,
                                                           String revision)
Get the commit that the revision references.

Parameters:
repository -
revision -
Returns:
commit

getCommit

public static org.eclipse.jgit.revwalk.RevCommit getCommit(org.eclipse.jgit.lib.Repository repository,
                                                           org.eclipse.jgit.lib.ObjectId commitId)
Get the commit with the given id

Parameters:
repository -
commitId -
Returns:
commit

getHead

public static org.eclipse.jgit.revwalk.RevCommit getHead(org.eclipse.jgit.lib.Repository repository)
Get the HEAD commit in the given repository.

Parameters:
repository -
Returns:
commit never null

getMaster

public static org.eclipse.jgit.revwalk.RevCommit getMaster(org.eclipse.jgit.lib.Repository repository)
Get the commit at the tip of the master branch in the given repository.

Parameters:
repository -
Returns:
commit never null

getBase

public static org.eclipse.jgit.revwalk.RevCommit getBase(org.eclipse.jgit.lib.Repository repository,
                                                         org.eclipse.jgit.lib.ObjectId... commits)
Get the common base commit of the given commits.

Parameters:
repository -
commits -
Returns:
base commit or null if none

getBase

public static org.eclipse.jgit.revwalk.RevCommit getBase(org.eclipse.jgit.lib.Repository repository,
                                                         String... revisions)
Get the common base commit between the given revisions.

Parameters:
repository -
revisions -
Returns:
base commit or null if none

getRef

public static org.eclipse.jgit.revwalk.RevCommit getRef(org.eclipse.jgit.lib.Repository repository,
                                                        String refName)
Get the commit that the given name references.

Parameters:
repository -
refName -
Returns:
commit, may be null

getRef

public static org.eclipse.jgit.revwalk.RevCommit getRef(org.eclipse.jgit.lib.Repository repository,
                                                        org.eclipse.jgit.lib.Ref ref)
Get the commit for the given reference.

Parameters:
repository -
ref -
Returns:
commit, may be null

getTags

public static Collection<org.eclipse.jgit.revwalk.RevCommit> getTags(org.eclipse.jgit.lib.Repository repository)
Get all the commits that tags in the given repository reference.

Parameters:
repository -
Returns:
non-null but possibly empty collection of commits

getBranches

public static Collection<org.eclipse.jgit.revwalk.RevCommit> getBranches(org.eclipse.jgit.lib.Repository repository)
Get all the commits that branches in the given repository reference.

Parameters:
repository -
Returns:
non-null but possibly empty collection of commits

resolve

protected static org.eclipse.jgit.lib.ObjectId resolve(org.eclipse.jgit.lib.Repository repository,
                                                       String revision)
Resolve the revision string to a commit object id

Parameters:
repository -
revision -
Returns:
commit id

strictResolve

protected static org.eclipse.jgit.lib.ObjectId strictResolve(org.eclipse.jgit.lib.Repository repository,
                                                             String revision)
Resolve the revision string to a commit object id.

A GitException will be thrown when the revision can not be resolved to an ObjectId

Parameters:
repository -
revision -
Returns:
commit id

parse

protected static org.eclipse.jgit.revwalk.RevCommit parse(org.eclipse.jgit.lib.Repository repository,
                                                          org.eclipse.jgit.lib.ObjectId commit)
Parse a commit from the repository

Parameters:
repository -
commit -
Returns:
commit

parse

protected static org.eclipse.jgit.revwalk.RevCommit parse(org.eclipse.jgit.lib.Repository repository,
                                                          org.eclipse.jgit.lib.ObjectReader reader,
                                                          org.eclipse.jgit.lib.ObjectId commit)
Parse a commit from the object reader

Parameters:
repository -
reader -
commit -
Returns:
commit

getLastCommit

public static org.eclipse.jgit.revwalk.RevCommit getLastCommit(org.eclipse.jgit.lib.Repository repository,
                                                               String path)
Find the commit that last changed the given path starting at the commit that HEAD currently points to

Parameters:
repository -
path -
Returns:
commit

getLastCommit

public static org.eclipse.jgit.revwalk.RevCommit getLastCommit(org.eclipse.jgit.lib.Repository repository,
                                                               String revision,
                                                               String path)
Find the commit that last changed the given path starting with the commit at the given revision

Parameters:
repository -
revision -
path -
Returns:
commit


Copyright © 2011-2012. All Rights Reserved.