Class JGitAPIImpl

  • All Implemented Interfaces:
    IGitAPI, Serializable, GitClient

    public class JGitAPIImpl
    extends Object
    GitClient pure Java implementation using JGit. Goal is to eventually get a full java implementation for GitClient For internal use only, don't use directly. See Git
    See Also:
    Serialized Form
    • Method Detail

      • clearCredentials

        public void clearCredentials()
        clearCredentials.
      • addCredentials

        public void addCredentials​(String url,
                                   com.cloudbees.plugins.credentials.common.StandardCredentials credentials)
        Adds credentials to be used against a specific url.
        Parameters:
        url - the url for the credentials to be used against.
        credentials - the credentials to use.
      • setCredentialsProvider

        public void setCredentialsProvider​(org.eclipse.jgit.transport.CredentialsProvider prov)
        setCredentialsProvider.
        Parameters:
        prov - a CredentialsProvider object.
      • subGit

        public GitClient subGit​(String subdir)
        subGit.
        Parameters:
        subdir - a String object.
        Returns:
        a IGitAPI implementation to manage git submodule repository
      • setAuthor

        public void setAuthor​(String name,
                              String email)
                       throws GitException
        Sets the identity of the author for future commits and merge operations.
        Parameters:
        name - a String object.
        email - a String object.
        Throws:
        GitException - if underlying git operation fails.
      • setCommitter

        public void setCommitter​(String name,
                                 String email)
                          throws GitException
        Sets the identity of the committer for future commits and merge operations.
        Parameters:
        name - a String object.
        email - a String object.
        Throws:
        GitException - if underlying git operation fails.
      • deleteBranch

        public void deleteBranch​(String name)
                          throws GitException
        (force) delete a branch.
        Parameters:
        name - a String object.
        Throws:
        GitException - if underlying git operation fails.
      • getRemoteBranches

        public Set<Branch> getRemoteBranches()
                                      throws GitException
        getRemoteBranches.
        Returns:
        a Set object.
        Throws:
        GitException - if underlying git operation fails.
      • tag

        public void tag​(String name,
                        String message)
                 throws GitException
        Create (or update) a tag. If tag already exist it gets updated (equivalent to git tag --force)
        Parameters:
        name - a String object.
        message - a String object.
        Throws:
        GitException - if underlying git operation fails.
      • tagExists

        public boolean tagExists​(String tagName)
                          throws GitException
        tagExists.
        Parameters:
        tagName - a String object.
        Returns:
        true if tag exists in repository
        Throws:
        GitException - if underlying git operation fails.
      • fetch

        public void fetch​(org.eclipse.jgit.transport.URIish url,
                          List<org.eclipse.jgit.transport.RefSpec> refspecs)
                   throws GitException,
                          InterruptedException
        Fetch commits from url which match any of the passed in refspecs. Assumes remote.remoteName.url has been set.
        Parameters:
        url - a URIish object.
        refspecs - a List object.
        Throws:
        GitException - if any.
        InterruptedException - if any.
      • fetch

        public void fetch​(String remoteName,
                          org.eclipse.jgit.transport.RefSpec... refspec)
                   throws GitException
        fetch.
        Parameters:
        remoteName - a String object.
        refspec - a RefSpec object.
        Throws:
        GitException - if underlying git operation fails.
      • fetch

        public void fetch​(String remoteName,
                          org.eclipse.jgit.transport.RefSpec refspec)
                   throws GitException
        fetch.
        Parameters:
        remoteName - a String object.
        refspec - a RefSpec object.
        Throws:
        GitException - if underlying git operation fails.
      • ref

        public void ref​(String refName)
                 throws GitException,
                        InterruptedException
        Create (or update) a ref. The ref will reference HEAD (equivalent to git update-ref ... HEAD).
        Parameters:
        refName - the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • refExists

        public boolean refExists​(String refName)
                          throws GitException,
                                 InterruptedException
        Check if a ref exists. Equivalent to comparing the return code of git show-ref to zero.
        Parameters:
        refName - the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.
        Returns:
        True if the ref exists, false otherwse.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • deleteRef

        public void deleteRef​(String refName)
                       throws GitException,
                              InterruptedException
        Deletes a ref. Has no effect if the ref does not exist, equivalent to git update-ref -d.
        Parameters:
        refName - the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • getRefNames

        public Set<String> getRefNames​(String refPrefix)
                                throws GitException,
                                       InterruptedException
        List refs with the given prefix. Equivalent to git for-each-ref --format="%(refname)".
        Parameters:
        refPrefix - the literal prefix any ref returned will have. The empty string implies all.
        Returns:
        a set of refs, each beginning with the given prefix. Empty if none.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • getRemoteReferences

        public Map<String,​org.eclipse.jgit.lib.ObjectId> getRemoteReferences​(String url,
                                                                                   String pattern,
                                                                                   boolean headsOnly,
                                                                                   boolean tagsOnly)
                                                                            throws GitException,
                                                                                   InterruptedException
        List references in a remote repository. Equivalent to git ls-remote [--heads] [--tags] <repository> [<refs>].
        Parameters:
        url - Remote repository URL.
        pattern - Only references matching the given pattern are displayed.
        headsOnly - Limit to only refs/heads.
        tagsOnly - Limit to only refs/tags. headsOnly and tagsOnly are not mutually exclusive; when both are true, references stored in refs/heads and refs/tags are displayed.
        Returns:
        a map of reference names and their commit hashes. Empty if none.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • getRemoteSymbolicReferences

        public Map<String,​String> getRemoteSymbolicReferences​(String url,
                                                                    String pattern)
                                                             throws GitException,
                                                                    InterruptedException
        Description copied from interface: GitClient
        List symbolic references in a remote repository. Equivalent to git ls-remote --symref <repository> [<refs>]. Note: the response may be empty for multiple reasons
        Parameters:
        url - Remote repository URL.
        pattern - Only references matching the given pattern are displayed.
        Returns:
        a map of reference names and their underlying references. Empty if none or if the remote does not report symbolic references (i.e. Git 1.8.4 or earlier) or if the client does not support reporting symbolic references (e.g. command line Git prior to 2.8.0).
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • getHeadRev

        public org.eclipse.jgit.lib.ObjectId getHeadRev​(String remoteRepoUrl,
                                                        String branchSpec)
                                                 throws GitException
        getHeadRev.
        Parameters:
        remoteRepoUrl - a String object.
        branchSpec - a String object.
        Returns:
        a ObjectId object.
        Throws:
        GitException - if underlying git operation fails.
      • getRemoteUrl

        public String getRemoteUrl​(String name)
                            throws GitException
        From a given repository, get a remote's URL
        Parameters:
        name - The name of the remote (e.g. origin)
        Returns:
        a String object.
        Throws:
        GitException - if executing the git command fails
      • getRepository

        @NonNull
        public org.eclipse.jgit.lib.Repository getRepository()
                                                      throws GitException
        getRepository.
        Returns:
        a Repository object.
        Throws:
        GitException - if underlying git operation fails.
      • getWorkTree

        public FilePath getWorkTree()
        getWorkTree.
        Returns:
        a FilePath object.
      • setRemoteUrl

        public void setRemoteUrl​(String name,
                                 String url)
                          throws GitException
        For a given repository, set a remote's URL
        Parameters:
        name - The name of the remote (e.g. origin)
        url - The new value of the remote's URL
        Throws:
        GitException - if executing the git command fails
      • addNote

        public void addNote​(String note,
                            String namespace)
                     throws GitException
        Adds a new git-note on the current HEAD commit.
        Parameters:
        note - Content of the note.
        namespace - If unqualified, interpreted as "refs/notes/NAMESPACE" just like cgit.
        Throws:
        GitException - if underlying git operation fails.
      • appendNote

        public void appendNote​(String note,
                               String namespace)
                        throws GitException
        Appends to an existing git-note on the current HEAD commit. If a note doesn't exist, it works just like GitClient.addNote(String, String)
        Parameters:
        note - Content of the note.
        namespace - If unqualified, interpreted as "refs/notes/NAMESPACE" just like cgit.
        Throws:
        GitException - if underlying git operation fails.
      • clean

        public void clean​(boolean cleanSubmodule)
                   throws GitException
        clean.
        Parameters:
        cleanSubmodule - flag to add extra -f
        Throws:
        GitException - if underlying git operation fails.
      • deleteTag

        public void deleteTag​(String tagName)
                       throws GitException
        deleteTag.
        Parameters:
        tagName - a String object.
        Throws:
        GitException - if underlying git operation fails.
      • getSubmodules

        public List<IndexEntry> getSubmodules​(String treeIsh)
                                       throws GitException
        Finds all the submodule references in this repository at the specified tree.
        Parameters:
        treeIsh - a String object.
        Returns:
        never null.
        Throws:
        GitException - if underlying git operation fails.
      • addSubmodule

        public void addSubmodule​(String remoteURL,
                                 String subdir)
                          throws GitException
        Create a submodule in subdir child directory for remote repository
        Parameters:
        remoteURL - a String object.
        subdir - a String object.
        Throws:
        GitException - if underlying git operation fails.
      • getRemoteTagNames

        public Set<String> getRemoteTagNames​(String tagPattern)
                                      throws GitException
        getRemoteTagNames.
        Parameters:
        tagPattern - a String object.
        Returns:
        a Set object.
        Throws:
        GitException - if underlying git operation fails.
      • hasGitRepo

        public boolean hasGitRepo()
                           throws GitException
        Returns true if the current workspace has a git repository. Does not search parent directories for a repository.
        Returns:
        true if this workspace has a git repository
        Throws:
        GitException - if underlying git operation fails.
      • hasGitRepo

        public boolean hasGitRepo​(boolean checkParentDirectories)
                           throws GitException
        Returns true if the current workspace has a git repository. If checkParentDirectories is true, searches parent directories. If checkParentDirectories is false, checks workspace directory only.
        Parameters:
        checkParentDirectories - if true, search upwards for a git repository
        Returns:
        true if this workspace has a git repository
        Throws:
        GitException - if underlying git operation fails.
      • isCommitInRepo

        public boolean isCommitInRepo​(org.eclipse.jgit.lib.ObjectId commit)
                               throws GitException
        isCommitInRepo.
        Parameters:
        commit - a ObjectId object.
        Returns:
        true if commit is in repository
        Throws:
        GitException - if underlying git operation fails.
      • prune

        public void prune​(org.eclipse.jgit.transport.RemoteConfig repository)
                   throws GitException
        Prune stale remote tracking branches with "git remote prune" on the specified remote.
        Parameters:
        repository - a RemoteConfig object.
        Throws:
        GitException - if underlying git operation fails.
      • revListAll

        public List<org.eclipse.jgit.lib.ObjectId> revListAll()
                                                       throws GitException
        revListAll.
        Returns:
        a List object.
        Throws:
        GitException - if underlying git operation fails.
      • revList

        public List<org.eclipse.jgit.lib.ObjectId> revList​(String ref)
                                                    throws GitException
        revList.
        Parameters:
        ref - a String object.
        Returns:
        a List object.
        Throws:
        GitException - if underlying git operation fails.
      • revParse

        public org.eclipse.jgit.lib.ObjectId revParse​(String revName)
                                               throws GitException
        Retrieve commit object that is direct child for revName revision reference.
        Parameters:
        revName - a commit sha1 or tag/branch refname
        Returns:
        a ObjectId object.
        Throws:
        GitException - when no such commit / revName is found in repository.
      • showRevision

        public List<String> showRevision​(org.eclipse.jgit.lib.ObjectId from,
                                         org.eclipse.jgit.lib.ObjectId to)
                                  throws GitException
        Given a Revision, show it as if it were an entry from git whatchanged, so that it can be parsed by GitChangeLogParser.

        Changes are computed on the [from..to] range. If from is null, this prints just one commit that to represents.

        For merge commit, this method reports one diff per each parent. This makes this method behave differently from GitClient.changelog().

        Parameters:
        from - a ObjectId object.
        to - a ObjectId object.
        Returns:
        The git whatchanged output, in raw format.
        Throws:
        GitException - if underlying git operation fails.
      • showRevision

        public List<String> showRevision​(org.eclipse.jgit.lib.ObjectId from,
                                         org.eclipse.jgit.lib.ObjectId to,
                                         Boolean useRawOutput)
                                  throws GitException
        Given a Revision, show it as if it were an entry from git whatchanged, so that it can be parsed by GitChangeLogParser.

        If useRawOutput is true, the '--raw' option will include commit file information to be passed to the GitChangeLogParser.

        Changes are computed on the [from..to] range. If from is null, this prints just one commit that to represents.

        For merge commit, this method reports one diff per each parent. This makes this method behave differently from GitClient.changelog().

        Parameters:
        from - a ObjectId object.
        to - a ObjectId object.
        useRawOutput - a {java.lang.Boolean} object.
        Returns:
        The git whatchanged output, in raw format.
        Throws:
        GitException - if underlying git operation fails.
      • submoduleClean

        public void submoduleClean​(boolean recursive)
                            throws GitException
        submoduleClean.
        Parameters:
        recursive - a boolean.
        Throws:
        GitException - if underlying git operation fails.
      • getBranchesContaining

        public List<Branch> getBranchesContaining​(String revspec,
                                                  boolean allBranches)
                                           throws GitException,
                                                  InterruptedException
        Find all the branches that include the given commit. "git branch --contains=X" is a pretty plain traversal. We walk the commit graph until we find the target revision we want. Doing this individually for every branch is too expensive, so we use flags to track multiple branches at once. JGit gives us 24 bits of flags, so we divide up all the branches to batches of 24, then perform a graph walk. For flags to carry correctly over from children to parents, all the children must be visited before we see the parent. This requires a topological sorting order. In addition, we want kind of a "breadth first search" to avoid going down a part of the graph that's not terribly interesting and topo sort helps with that, too (imagine the following commit graph, and compute "git branch --contains=t"; we don't want to visit all the way to c1 before visiting c.) INIT -> c1 -> c2 -> ... long history of commits --+--> c1000 --+--> branch1 | | --> t ------

        Since we reuse RevWalk, it'd be nice to flag commits reachable from 't' as uninteresting and keep them across resets, but I'm not sure how to do it.

        Parameters:
        revspec - commit id to query for
        allBranches - whether remote branches should be also queried (true) or not (false)
        Returns:
        list of branches the specified commit belongs to
        Throws:
        GitException - on Git exceptions
        InterruptedException - on thread interruption
      • mergeBase

        @Deprecated
        public org.eclipse.jgit.lib.ObjectId mergeBase​(org.eclipse.jgit.lib.ObjectId id1,
                                                       org.eclipse.jgit.lib.ObjectId id2)
        Deprecated.
        mergeBase.
        Parameters:
        id1 - a ObjectId object.
        id2 - a ObjectId object.
        Returns:
        a ObjectId object.
      • getAllLogEntries

        @Deprecated
        public String getAllLogEntries​(String branch)
        Deprecated.
        This method makes no sense, in that it lists all log entries across all refs and yet it takes a meaningless 'branch' parameter. Please do not use this.
        Parameters:
        branch - a String object.
        Returns:
        a String object.
      • setSubmoduleUrl

        @Deprecated
        public void setSubmoduleUrl​(String name,
                                    String url)
                             throws GitException
        Deprecated.
        Sets URL of the named submodule.
        Parameters:
        name - submodule name whose URL will be set
        url - URL for the named submodule
        Throws:
        GitException - if underlying git operation fails.
      • setupSubmoduleUrls

        @Deprecated
        public void setupSubmoduleUrls​(Revision rev,
                                       TaskListener listener)
                                throws GitException
        Deprecated.
        Set up submodule URLs so that they correspond to the remote pertaining to the revision that has been checked out. I don't think anyone is using this method, and I don't think we ever need to implement this. This kind of logic doesn't belong here, as it lacks generality. It should be whoever manipulating Git.
        Parameters:
        rev - a Revision object.
        listener - a TaskListener object.
        Throws:
        GitException - if underlying git operation fails.
      • describe

        public String describe​(String tip)
                        throws GitException,
                               InterruptedException
        Equivalent of "git-describe --tags". Find a nearby tag (including unannotated ones) and come up with a short identifier to describe the tag. This implementation is based on my reading of the cgit source code at https://github.com/git/git/blob/master/builtin/describe.c

        The basic structure of the algorithm is as follows. We walk the commit graph, find tags, and mark commits that are reachable from those tags. The marking uses flags given by JGit, so there's a fairly small upper bound in the number of tags we can keep track of.

        As we walk commits, we count commits that each tag doesn't contain. We call it "depth", following the variable name in C Git. As we walk further and find enough tags, we go into wind-down mode and only walk to the point of accurately determining all the depths.

        Parameters:
        tip - a String object.
        Returns:
        a String object.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • reset

        @Deprecated
        public void reset​(boolean hard)
                   throws GitException,
                          InterruptedException
        Deprecated.
        Reset the contents of the working directory of this repository. Refer to git reset documentation.
        Parameters:
        hard - reset as though "--hard" were passed to "git reset"
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • setRemoteUrl

        @Deprecated
        public void setRemoteUrl​(String name,
                                 String url,
                                 String GIT_DIR)
                          throws GitException,
                                 InterruptedException
        Deprecated.
        Set remote repository name and URL.
        Parameters:
        name - name for the remote repository, for examnple, "origin"
        url - URL for the remote repository, for example https://github.com/jenkinsci/git-client-plugin.git
        GIT_DIR - directory containing git repository
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • getTags

        public Set<GitObject> getTags()
                               throws GitException
        Return name and object ID of all tags in current repository.
        Returns:
        set of tags in current repository
        Throws:
        GitException - on Git exceptions
      • maintenance

        public boolean maintenance​(String task)
        Description copied from interface: GitClient
        Executes git maintenance commands based on the git version.
        Parameters:
        task - a String object. i.e (prefetch/gc/commit-graph/incremental-repack/loose-objects)
        Returns:
        Boolean if maintenance has been executed or not.
      • hasGitModules

        @Deprecated
        public boolean hasGitModules​(String treeIsh)
                              throws GitException
        Deprecated.
        Returns true if this repository has submodules.
        Specified by:
        hasGitModules in interface IGitAPI
        Parameters:
        treeIsh - an ignored argument, kept for compatibility
        Returns:
        true if this repository has submodules (git modules file)
        Throws:
        GitException - if underlying git operation fails.
        See Also:
        GitClient.hasGitModules()
      • fetch

        @Deprecated
        public void fetch​(org.eclipse.jgit.transport.RemoteConfig remoteRepository)
                   throws InterruptedException
        Deprecated.
        Retrieve commits from RemoteConfig.
        Specified by:
        fetch in interface IGitAPI
        Parameters:
        remoteRepository - remote configuration from which refs will be retrieved
        Throws:
        InterruptedException - if interrupted.
      • clone

        @Deprecated
        public void clone​(org.eclipse.jgit.transport.RemoteConfig rc,
                          boolean useShallowClone)
                   throws GitException,
                          InterruptedException
        Deprecated.
        Clone repository from RemoteConfig rc to this repository.
        Specified by:
        clone in interface IGitAPI
        Parameters:
        rc - the remote config for the remote repository
        useShallowClone - if true, use a shallow clone
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • hasGitModules

        public boolean hasGitModules()
                              throws GitException
        hasGitModules.
        Specified by:
        hasGitModules in interface GitClient
        Returns:
        true if this repositor has one or more submodules
        Throws:
        GitException - if underlying git operation fails.
      • showRevision

        public List<String> showRevision​(org.eclipse.jgit.lib.ObjectId r)
                                  throws GitException,
                                         InterruptedException
        Given a Revision, show it as if it were an entry from git whatchanged, so that it can be parsed by GitChangeLogParser.

        Changes are computed on the [from..to] range. If from is null, this prints just one commit that to represents.

        For merge commit, this method reports one diff per each parent. This makes this method behave differently from GitClient.changelog().

        Specified by:
        showRevision in interface GitClient
        Parameters:
        r - a ObjectId object.
        Returns:
        The git whatchanged output, in raw format.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • extractBranchNameFromBranchSpec

        protected String extractBranchNameFromBranchSpec​(String branchSpec)
        This method takes a branch specification and normalizes it get unambiguous results. This is the case when using "refs/heads/"

        TODO: Currently only for specs starting with "refs/heads/" the implementation is correct. All others branch specs should also be normalized to "refs/heads/" in order to get unambiguous results. To achieve this it is necessary to identify remote names in the branch spec and to discuss how to handle clashes (e.g. "remoteName/main" for branch "main" (refs/heads/main) in remote "remoteName" and branch "remoteName/main" (refs/heads/remoteName/main)).

        Existing behavior is intentionally being retained so that current use cases are not disrupted by a behavioral change.

        E.g.
        Branch Spec Normalization Examples
        branch specnormalized
        mainmain*
        feature1feature1*
        feature1/main
        main feature1/main*
        origin/mainmain*
        repo2/feature1feature1*
        refs/heads/feature1refs/heads/feature1
        origin/namespaceA/fix15
        fix15 namespaceA/fix15*
        refs/heads/namespaceA/fix15refs/heads/namespaceA/fix15
        remotes/origin/namespaceA/fix15refs/heads/namespaceA/fix15

        *) TODO: Normalize to "refs/heads/"
        Parameters:
        branchSpec - a String object.
        Returns:
        normalized branch name
      • setAuthor

        public void setAuthor​(org.eclipse.jgit.lib.PersonIdent p)
        setAuthor.
        Specified by:
        setAuthor in interface GitClient
        Parameters:
        p - a PersonIdent object.
      • setCommitter

        public void setCommitter​(org.eclipse.jgit.lib.PersonIdent p)
        setCommitter.
        Specified by:
        setCommitter in interface GitClient
        Parameters:
        p - a PersonIdent object.
      • clone

        public void clone​(String url,
                          String origin,
                          boolean useShallowClone,
                          String reference)
                   throws GitException,
                          InterruptedException
        Clone a remote repository
        Specified by:
        clone in interface GitClient
        Parameters:
        url - URL for remote repository to clone
        origin - upstream track name, defaults to origin by convention
        useShallowClone - option to create a shallow clone, that has some restriction but will make clone operation
        reference - (optional) reference to a local clone for faster clone operations (reduce network and local storage costs)
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • checkout

        public void checkout​(String ref,
                             String branch)
                      throws GitException,
                             InterruptedException
        Creates a new branch that points to the specified ref. (equivalent to git checkout -b branch commit) This will fail if the branch already exists.
        Specified by:
        checkout in interface GitClient
        Parameters:
        ref - A git object references expression. For backward compatibility, null will checkout current HEAD
        branch - name of the branch to create from reference
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • checkoutBranch

        public void checkoutBranch​(String branch,
                                   String ref)
                            throws GitException,
                                   InterruptedException
        Regardless of the current state of the workspace (whether there is some dirty files, etc) and the state of the repository (whether the branch of the specified name exists or not), when this method exits the following conditions hold:
        • The branch of the specified name branch exists and points to the specified ref
        • HEAD points to branch. In other words, the workspace is on the specified branch.
        • Both index and workspace are the same tree with ref. (no dirty files and no staged changes, although this method will not touch untracked files in the workspace.)

        This method is preferred over the GitClient.checkout(String, String) family of methods, as this method is affected far less by the current state of the repository. The checkout methods, in their attempt to emulate the "git checkout" command line behaviour, have too many side effects. In Jenkins, where you care a lot less about throwing away local changes and care a lot more about resetting the workspace into a known state, methods like this is more useful.

        For compatibility reasons, the order of the parameter is different from GitClient.checkout(String, String).

        Specified by:
        checkoutBranch in interface GitClient
        Parameters:
        branch - a String object.
        ref - a String object.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • remoteProxyFor

        protected org.jenkinsci.plugins.gitclient.RemoteGitImpl remoteProxyFor​(GitClient proxy)
        remoteProxyFor.
        Parameters:
        proxy - a GitClient object.
        Returns:
        a RemoteGitImpl object.
      • setCredentials

        public void setCredentials​(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
        setCredentials.
        Specified by:
        setCredentials in interface GitClient
        Parameters:
        cred - a StandardUsernameCredentials object.
      • submoduleUpdate

        public void submoduleUpdate​(boolean recursive,
                                    String reference)
                             throws GitException,
                                    InterruptedException
        Run submodule update optionally recursively on all submodules, with a specific reference passed to git clone if needing to --init. (equivalent of git submodule update --recursive --reference 'reference'.)
        Specified by:
        submoduleUpdate in interface GitClient
        Parameters:
        recursive - a boolean.
        reference - a String object.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • submoduleUpdate

        public void submoduleUpdate​(boolean recursive,
                                    boolean remoteTracking)
                             throws GitException,
                                    InterruptedException
        Run submodule update optionally recursively on all submodules, optionally with remoteTracking submodules (equivalent of git submodule update --recursive --remote.)
        Specified by:
        submoduleUpdate in interface GitClient
        Parameters:
        recursive - a boolean.
        remoteTracking - a boolean.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.
      • submoduleUpdate

        public void submoduleUpdate​(boolean recursive,
                                    boolean remoteTracking,
                                    String reference)
                             throws GitException,
                                    InterruptedException
        Run submodule update optionally recursively on all submodules, optionally with remoteTracking, with a specific reference passed to git clone if needing to --init. (equivalent of git submodule update --recursive --remote --reference 'reference'.)
        Specified by:
        submoduleUpdate in interface GitClient
        Parameters:
        recursive - a boolean.
        remoteTracking - a boolean.
        reference - a String object.
        Throws:
        GitException - if underlying git operation fails.
        InterruptedException - if interrupted.