Class GitToolChooser


  • public class GitToolChooser
    extends Object
    A class which allows Git Plugin to choose a git implementation by estimating the size of a repository from a distance without requiring a local checkout.
    • Constructor Detail

      • GitToolChooser

        public GitToolChooser​(String remoteName,
                              Item projectContext,
                              String credentialsId,
                              hudson.plugins.git.GitTool gitExe,
                              Node n,
                              TaskListener listener,
                              Boolean useJGit)
                       throws IOException,
                              InterruptedException
        Instantiate class using the remote name. It looks for a cached .git directory first, calculates the size if it is found else checks if the extension point has been implemented and asks for the size.
        Parameters:
        remoteName - the repository url
        projectContext - the context where repository size is being estimated
        credentialsId - credential used to access the repository or null if no credential is required
        gitExe - Git tool ('git', 'jgit', 'jgitapache') to be used as the default tool
        n - A Jenkins agent used to check validity of git installation
        listener - TaskListener required by GitUtils.resolveGitTool()
        useJGit - if true the JGit is allowed as an implementation
        Throws:
        IOException - on error
        InterruptedException - on error
    • Method Detail

      • recommendGitToolOnAgent

        public hudson.plugins.git.GitTool recommendGitToolOnAgent​(hudson.plugins.git.GitTool userChoice)
      • getGitTool

        public String getGitTool()
        Recommend git tool to be used by the git client
        Returns:
        git implementation recommendation in the form of a string
      • clearRepositorySizeCache

        public static void clearRepositorySizeCache()
        Clear the cache of repository sizes.
      • putRepositorySizeCache

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static void putRepositorySizeCache​(String repoURL,
                                                  long repoSize)
        Insert an entry into the cache of repository sizes. For testing only - not to be used outside the git plugin.
        Parameters:
        repoURL - repository URL to be added as a cache key
        repoSize - repository size in kilobytes