public class GitUtils extends Object
| Constructor and Description |
|---|
GitUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addDummyFileToEmptyFolders(File dir)
Git tends to ignore empty directories so lets add a dummy file to empty folders to keep them in git
|
static void |
addFiles(org.eclipse.jgit.api.Git git,
File... files) |
static void |
configureBranch(org.eclipse.jgit.api.Git git,
String branch,
String origin,
String remoteRepository) |
static <C extends org.eclipse.jgit.api.GitCommand> |
configureCommand(org.eclipse.jgit.api.TransportCommand<C,?> command,
org.eclipse.jgit.transport.CredentialsProvider credentialsProvider,
File sshPrivateKey,
File sshPublicKey)
Configures the transport of the command to deal with things like SSH
|
static <C extends org.eclipse.jgit.api.GitCommand> |
configureCommand(org.eclipse.jgit.api.TransportCommand<C,?> command,
UserDetails userDetails)
Configures the transport of the command to deal with things like SSH
|
static void |
disableSslCertificateChecks() |
static void |
doAddCommitAndPushFiles(org.eclipse.jgit.api.Git git,
UserDetails userDetails,
org.eclipse.jgit.lib.PersonIdent personIdent,
String branch,
String origin,
String message,
boolean pushOnCommit) |
static org.eclipse.jgit.revwalk.RevCommit |
doCommitAndPush(org.eclipse.jgit.api.Git git,
String message,
UserDetails userDetails,
org.eclipse.jgit.lib.PersonIdent author,
String branch,
String origin,
boolean pushOnCommit) |
static org.eclipse.jgit.lib.Repository |
findRepository(File baseDir)
Returns the git repository for the current folder or null if none can be found
|
static Date |
getCommitDate(org.eclipse.jgit.revwalk.RevCommit commit)
Retrieves a Java Date from a Git commit.
|
static String |
getFilePattern(File rootDir,
File file) |
static String |
getGitHostName(String gitUrl) |
static String |
getGitProtocol(String gitUrl) |
static String |
getRemoteURL(org.eclipse.jgit.api.Git git,
String branch)
Returns the remote git URL for the given branch
|
static String |
getRemoteURL(org.eclipse.jgit.lib.Repository repository)
Returns the remote repository for the current branch in the given repository
|
static String |
getRemoteURL(org.eclipse.jgit.lib.Repository repository,
String remoteName) |
static File |
getRootGitDirectory(org.eclipse.jgit.api.Git git) |
static Map<String,Properties> |
parseGitConfig()
Returns the ~/.gitconfig file parsed
|
static String |
toString(Collection<org.eclipse.jgit.transport.RemoteRefUpdate> updates) |
public static File getRootGitDirectory(org.eclipse.jgit.api.Git git)
public static String toString(Collection<org.eclipse.jgit.transport.RemoteRefUpdate> updates)
public static void disableSslCertificateChecks()
public static String getRemoteURL(org.eclipse.jgit.api.Git git, String branch)
public static String getRemoteURL(org.eclipse.jgit.lib.Repository repository) throws IOException
IOExceptionpublic static String getRemoteURL(org.eclipse.jgit.lib.Repository repository, String remoteName)
public static void configureBranch(org.eclipse.jgit.api.Git git,
String branch,
String origin,
String remoteRepository)
public static void addFiles(org.eclipse.jgit.api.Git git,
File... files)
throws org.eclipse.jgit.api.errors.GitAPIException,
IOException
org.eclipse.jgit.api.errors.GitAPIExceptionIOExceptionpublic static String getFilePattern(File rootDir, File file) throws IOException
IOExceptionpublic static org.eclipse.jgit.revwalk.RevCommit doCommitAndPush(org.eclipse.jgit.api.Git git,
String message,
UserDetails userDetails,
org.eclipse.jgit.lib.PersonIdent author,
String branch,
String origin,
boolean pushOnCommit)
throws org.eclipse.jgit.api.errors.GitAPIException
org.eclipse.jgit.api.errors.GitAPIExceptionpublic static void doAddCommitAndPushFiles(org.eclipse.jgit.api.Git git,
UserDetails userDetails,
org.eclipse.jgit.lib.PersonIdent personIdent,
String branch,
String origin,
String message,
boolean pushOnCommit)
throws org.eclipse.jgit.api.errors.GitAPIException
org.eclipse.jgit.api.errors.GitAPIExceptionpublic static Date getCommitDate(org.eclipse.jgit.revwalk.RevCommit commit)
commit - the commitpublic static <C extends org.eclipse.jgit.api.GitCommand> void configureCommand(org.eclipse.jgit.api.TransportCommand<C,?> command,
UserDetails userDetails)
public static <C extends org.eclipse.jgit.api.GitCommand> void configureCommand(org.eclipse.jgit.api.TransportCommand<C,?> command,
org.eclipse.jgit.transport.CredentialsProvider credentialsProvider,
File sshPrivateKey,
File sshPublicKey)
public static void addDummyFileToEmptyFolders(File dir)
public static org.eclipse.jgit.lib.Repository findRepository(File baseDir) throws IOException
IOExceptionpublic static Map<String,Properties> parseGitConfig() throws IOException
IOExceptionCopyright © 2011–2016 Red Hat. All rights reserved.