public class JGitUtils extends Object
Modifier and Type | Method and Description |
---|---|
static List<ScmFile> |
addAllFiles(org.eclipse.jgit.api.Git git,
ScmFileSet fileSet)
Adds all files in the given fileSet to the repository.
|
static void |
closeRepo(org.eclipse.jgit.api.Git git)
Closes the repository wrapped by the passed git object
|
static org.eclipse.jgit.transport.CredentialsProvider |
getCredentials(GitScmProviderRepository repository)
Creates a credentials provider from the information passed in the
repository.
|
static List<ScmFile> |
getFilesInCommit(org.eclipse.jgit.lib.Repository repository,
org.eclipse.jgit.revwalk.RevCommit commit)
get a list of all files in the given commit
|
static org.eclipse.jgit.lib.ProgressMonitor |
getMonitor(ScmLogger logger)
Construct a logging ProgressMonitor for all JGit operations.
|
static List<org.eclipse.jgit.revwalk.RevCommit> |
getRevCommits(org.eclipse.jgit.lib.Repository repo,
org.eclipse.jgit.revwalk.RevSort[] sortings,
String fromRev,
String toRev,
Date fromDate,
Date toDate,
int maxLines)
Get a list of commits between two revisions.
|
static ScmFileStatus |
getScmFileStatus(org.eclipse.jgit.diff.DiffEntry.ChangeType changeType)
Translate a
FileStatus in the matching ScmFileStatus . |
static boolean |
hasCommits(org.eclipse.jgit.lib.Repository repo)
Does the Repository have any commits?
|
static org.eclipse.jgit.transport.CredentialsProvider |
prepareSession(ScmLogger logger,
org.eclipse.jgit.api.Git git,
GitScmProviderRepository repository)
Prepares the in memory configuration of git to connect to the configured
repository.
|
static Iterable<org.eclipse.jgit.transport.PushResult> |
push(ScmLogger logger,
org.eclipse.jgit.api.Git git,
GitScmProviderRepository repo,
org.eclipse.jgit.transport.RefSpec refSpec) |
public static void closeRepo(org.eclipse.jgit.api.Git git)
git
- public static org.eclipse.jgit.lib.ProgressMonitor getMonitor(ScmLogger logger)
logger
- public static org.eclipse.jgit.transport.CredentialsProvider prepareSession(ScmLogger logger, org.eclipse.jgit.api.Git git, GitScmProviderRepository repository)
logger
- used to log some detailsgit
- the instance to configure (only in memory, not saved)repository
- the repo config to be usedCredentialsProvider
in case there are credentials
informations configured in the repository.public static org.eclipse.jgit.transport.CredentialsProvider getCredentials(GitScmProviderRepository repository)
repository
- the config to get the details fromnull
if there is not enough info to create a
provider withpublic static Iterable<org.eclipse.jgit.transport.PushResult> push(ScmLogger logger, org.eclipse.jgit.api.Git git, GitScmProviderRepository repo, org.eclipse.jgit.transport.RefSpec refSpec) throws org.eclipse.jgit.api.errors.GitAPIException, org.eclipse.jgit.api.errors.InvalidRemoteException, org.eclipse.jgit.api.errors.TransportException
org.eclipse.jgit.api.errors.GitAPIException
org.eclipse.jgit.api.errors.InvalidRemoteException
org.eclipse.jgit.api.errors.TransportException
public static boolean hasCommits(org.eclipse.jgit.lib.Repository repo)
repo
- public static List<ScmFile> getFilesInCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit commit) throws org.eclipse.jgit.errors.MissingObjectException, org.eclipse.jgit.errors.IncorrectObjectTypeException, org.eclipse.jgit.errors.CorruptObjectException, IOException
repository
- the repocommit
- the commit to get the files fromorg.eclipse.jgit.errors.MissingObjectException
org.eclipse.jgit.errors.IncorrectObjectTypeException
org.eclipse.jgit.errors.CorruptObjectException
IOException
public static ScmFileStatus getScmFileStatus(org.eclipse.jgit.diff.DiffEntry.ChangeType changeType)
FileStatus
in the matching ScmFileStatus
.changeType
- public static List<ScmFile> addAllFiles(org.eclipse.jgit.api.Git git, ScmFileSet fileSet) throws org.eclipse.jgit.api.errors.GitAPIException, org.eclipse.jgit.api.errors.NoFilepatternException
git
- the repo to add the files tofileSet
- the set of files within the workspace, the files are added
relative to the basedir of this filesetorg.eclipse.jgit.api.errors.GitAPIException
org.eclipse.jgit.api.errors.NoFilepatternException
public static List<org.eclipse.jgit.revwalk.RevCommit> getRevCommits(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevSort[] sortings, String fromRev, String toRev, Date fromDate, Date toDate, int maxLines) throws IOException, org.eclipse.jgit.errors.MissingObjectException, org.eclipse.jgit.errors.IncorrectObjectTypeException
repo
- the repository to work onsortings
- sortingfromRev
- start revisiontoRev
- if null, falls back to headfromDate
- from which date ontoDate
- until which datemaxLines
- max number of linesnull
IOException
org.eclipse.jgit.errors.MissingObjectException
org.eclipse.jgit.errors.IncorrectObjectTypeException
Copyright © 2003–2015 The Apache Software Foundation. All rights reserved.