org.gitective.core
Class RepositoryUtils

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

public abstract class RepositoryUtils
extends Object

Utilities for dealing with Git repositories.

This class provides helpers for getting the branches, tags, and note references in a repository.

This class also provides helpers for knowing which references differ between a local and remote repository.


Nested Class Summary
static class RepositoryUtils.RefDiff
          Wrapper class for a remote and local ref that are different
 
Constructor Summary
RepositoryUtils()
           
 
Method Summary
static Collection<RepositoryUtils.RefDiff> diffOriginRefs(org.eclipse.jgit.lib.Repository repository)
          List the origin remote references and return all remote references that are missing locally or have a different remote object id than the local reference.
static Collection<RepositoryUtils.RefDiff> diffRemoteRefs(org.eclipse.jgit.lib.Repository repository, String remote)
          List remote references and return all remote references that are missing locally or have a different remote object id than the local reference.
static Collection<String> getBranches(org.eclipse.jgit.lib.Repository repository)
          Get all the local and remote tracking branch references in the given repository.
static Collection<String> getNoteRefs(org.eclipse.jgit.lib.Repository repository)
          Get all the note references in the given repository.
protected static Collection<org.eclipse.jgit.lib.Ref> getRefs(org.eclipse.jgit.lib.Repository repository, String prefix)
          Get the refs with prefix in repository
static Collection<String> getTags(org.eclipse.jgit.lib.Repository repository)
          Get all the tag references in the given repository.
protected static boolean hasRemote(org.eclipse.jgit.lib.Repository repository, String remote)
          Does the given remote exist in the repository?
static Map<String,Set<String>> mapEmailsToNames(Collection<org.eclipse.jgit.lib.PersonIdent> persons)
          Map e-mail addresses to names for all given PersonIdent instances
static Map<String,Set<String>> mapNamesToEmails(Collection<org.eclipse.jgit.lib.PersonIdent> persons)
          Map names to e-mail addresses for all given PersonIdent instances
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryUtils

public RepositoryUtils()
Method Detail

getRefs

protected static Collection<org.eclipse.jgit.lib.Ref> getRefs(org.eclipse.jgit.lib.Repository repository,
                                                              String prefix)
Get the refs with prefix in repository

Parameters:
repository -
prefix -
Returns:
collection of refs

getNoteRefs

public static Collection<String> getNoteRefs(org.eclipse.jgit.lib.Repository repository)
Get all the note references in the given repository.

Parameters:
repository -
Returns:
non-null but possibly empty array of note references

getBranches

public static Collection<String> getBranches(org.eclipse.jgit.lib.Repository repository)
Get all the local and remote tracking branch references in the given repository.

Parameters:
repository -
Returns:
non-null but possibly array of branch reference names

getTags

public static Collection<String> getTags(org.eclipse.jgit.lib.Repository repository)
Get all the tag references in the given repository.

Parameters:
repository -
Returns:
non-null but possibly array of branch reference names

diffOriginRefs

public static Collection<RepositoryUtils.RefDiff> diffOriginRefs(org.eclipse.jgit.lib.Repository repository)
List the origin remote references and return all remote references that are missing locally or have a different remote object id than the local reference.

Parameters:
repository -
Returns:
non-null but possibly empty collection of RepositoryUtils.RefDiff

hasRemote

protected static boolean hasRemote(org.eclipse.jgit.lib.Repository repository,
                                   String remote)
                            throws URISyntaxException
Does the given remote exist in the repository?

Parameters:
repository -
remote -
Returns:
true if exists, false otherwise
Throws:
URISyntaxException

diffRemoteRefs

public static Collection<RepositoryUtils.RefDiff> diffRemoteRefs(org.eclipse.jgit.lib.Repository repository,
                                                                 String remote)
List remote references and return all remote references that are missing locally or have a different remote object id than the local reference.

Parameters:
repository -
remote -
Returns:
non-null but possibly collection of RepositoryUtils.RefDiff

mapNamesToEmails

public static Map<String,Set<String>> mapNamesToEmails(Collection<org.eclipse.jgit.lib.PersonIdent> persons)
Map names to e-mail addresses for all given PersonIdent instances

PersonIdent entries with a null or empty name will be ignored.

Parameters:
persons -
Returns:
non-null but possibly empty map of names to e-mail addresses
See Also:
PersonIdent.getName(), PersonIdent.getEmailAddress()

mapEmailsToNames

public static Map<String,Set<String>> mapEmailsToNames(Collection<org.eclipse.jgit.lib.PersonIdent> persons)
Map e-mail addresses to names for all given PersonIdent instances

PersonIdent entries with a null or empty e-mail address will be ignored.

Parameters:
persons -
Returns:
non-null but possibly empty map of e-mail addresses to names
See Also:
PersonIdent.getName(), PersonIdent.getEmailAddress()


Copyright © 2011-2012. All Rights Reserved.