Class GitTools


  • public class GitTools
    extends java.lang.Object
    Provides some useful static helpers like #isOriginReachable(URIish), #isValidRepository(URIish), #cloneRepository(URIish, File, CredentialsProvider, int), ...
    • Constructor Summary

      Constructors 
      Constructor Description
      GitTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String checkOutRef​(org.eclipse.jgit.lib.Repository repo, java.lang.String ref)
      Checks out the given ref branch in the given repository.
      static org.eclipse.jgit.lib.Repository cloneRepository​(org.eclipse.jgit.transport.URIish remoteUri, java.io.File destFolder, org.eclipse.jgit.transport.RefSpec fetchSpec, org.eclipse.jgit.transport.CredentialsProvider credentials, int timeout)
      Clones the given remote repository into the given destination folder.
      static void fetchRepository​(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.transport.RefSpec fetchSpec, org.eclipse.jgit.transport.CredentialsProvider credentials, int timeout)
      Fetch deltas from a source-repository
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GitTools

        public GitTools()
    • Method Detail

      • cloneRepository

        public static org.eclipse.jgit.lib.Repository cloneRepository​(org.eclipse.jgit.transport.URIish remoteUri,
                                                                      java.io.File destFolder,
                                                                      org.eclipse.jgit.transport.RefSpec fetchSpec,
                                                                      org.eclipse.jgit.transport.CredentialsProvider credentials,
                                                                      int timeout)
                                                               throws java.io.IOException
        Clones the given remote repository into the given destination folder. The method clones all branches but doesn't perform a checkout.
        Parameters:
        remoteUri - URI of the remote repository
        destFolder - local destination folder
        credentials - user credentials
        Returns:
        the cloned repository
        Throws:
        java.io.IOException - if something went wrong
      • checkOutRef

        public static java.lang.String checkOutRef​(org.eclipse.jgit.lib.Repository repo,
                                                   java.lang.String ref)
                                            throws java.io.IOException
        Checks out the given ref branch in the given repository.
        Parameters:
        targetBranch - a local or remote branch name.
        Throws:
        java.io.IOException - if something went wrong
      • fetchRepository

        public static void fetchRepository​(org.eclipse.jgit.lib.Repository repo,
                                           org.eclipse.jgit.transport.RefSpec fetchSpec,
                                           org.eclipse.jgit.transport.CredentialsProvider credentials,
                                           int timeout)
                                    throws java.lang.Exception
        Fetch deltas from a source-repository
        Throws:
        java.lang.Exception