org.jenkinsci.plugins.gitclient
Class JGitAPIImpl

java.lang.Object
  extended by org.jenkinsci.plugins.gitclient.JGitAPIImpl
All Implemented Interfaces:
IGitAPI

public class JGitAPIImpl
extends Object
implements IGitAPI

Author:
Nicolas De Loof

Field Summary
 
Fields inherited from interface hudson.plugins.git.IGitAPI
verbose
 
Constructor Summary
JGitAPIImpl(String gitExe, File workspace, hudson.model.TaskListener listener, hudson.EnvVars environment)
           
 
Method Summary
 void add(String filePattern)
           
 void addNote(String note, String namespace)
           
 void appendNote(String note, String namespace)
           
 void branch(String name)
           
 void changelog(String revFrom, String revTo, OutputStream fos)
          Adds the changelog entries for commits in the range revFrom..revTo.
 void checkout(String commit)
          Checks out the specified commit/tag/branch into the workspace.
 void checkout(String ref, String branch)
          Checks out the specified commit/ref into the workspace, creating specified branch (equivalent to git checkout -b branch commit
 void clean()
           
 void clone(String url, String origin, boolean useShallowClone, String reference)
          Clone a remote repository
 void commit(String message)
           
 void deleteBranch(String name)
           
 void deleteTag(String tagName)
           
 void fetch(String remote, org.eclipse.jgit.transport.RefSpec refspec)
           
 Set<Branch> getBranches()
           
 org.eclipse.jgit.lib.ObjectId getHeadRev(String remoteRepoUrl, String branch)
           
 Set<Branch> getRemoteBranches()
           
 String getRemoteUrl(String name)
          From a given repository, get a remote's URL
 org.eclipse.jgit.lib.Repository getRepository()
           
 List<IndexEntry> getSubmodules(String treeIsh)
           
 Set<String> getTagNames(String tagPattern)
           
 boolean hasGitModules()
          Returns true if the repository has Git submodules.
 boolean hasGitRepo()
           
 void init()
           
 boolean isCommitInRepo(org.eclipse.jgit.lib.ObjectId commit)
           
 void merge(org.eclipse.jgit.lib.ObjectId revSpec)
           
 void prune(org.eclipse.jgit.transport.RemoteConfig repository)
           
 void push(String remoteName, String revspec)
           
 List<org.eclipse.jgit.lib.ObjectId> revListAll()
           
 org.eclipse.jgit.lib.ObjectId revParse(String revName)
           
 void setRemoteUrl(String name, String url)
          For a given repository, set a remote's URL
 void setupSubmoduleUrls(Revision rev, hudson.model.TaskListener listener)
          Set up submodule URLs so that they correspond to the remote pertaining to the revision that has been checked out.
 List<String> showRevision(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to)
          Given a Revision, show it as if it were an entry from git whatchanged, so that it can be parsed by GitChangeLogParser.
 IGitAPI subGit(String subdir)
           
 void submoduleClean(boolean recursive)
           
 void submoduleUpdate(boolean recursive)
           
 void tag(String name, String message)
           
 boolean tagExists(String tagName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JGitAPIImpl

public JGitAPIImpl(String gitExe,
                   File workspace,
                   hudson.model.TaskListener listener,
                   hudson.EnvVars environment)
Method Detail

subGit

public IGitAPI subGit(String subdir)
Specified by:
subGit in interface IGitAPI
Returns:
a IGitAPI implementation to manage git submodule repository

init

public void init()
          throws GitException
Specified by:
init in interface IGitAPI
Throws:
GitException

checkout

public void checkout(String commit)
              throws GitException
Description copied from interface: IGitAPI
Checks out the specified commit/tag/branch into the workspace.

Specified by:
checkout in interface IGitAPI
Parameters:
commit - A git object references expression
Throws:
GitException

checkout

public void checkout(String ref,
                     String branch)
              throws GitException
Description copied from interface: IGitAPI
Checks out the specified commit/ref into the workspace, creating specified branch (equivalent to git checkout -b branch commit

Specified by:
checkout in interface IGitAPI
Parameters:
ref - A git object references expression
branch - name of the branch to create from reference
Throws:
GitException

add

public void add(String filePattern)
         throws GitException
Specified by:
add in interface IGitAPI
Throws:
GitException

commit

public void commit(String message)
            throws GitException
Specified by:
commit in interface IGitAPI
Throws:
GitException

branch

public void branch(String name)
            throws GitException
Specified by:
branch in interface IGitAPI
Throws:
GitException

deleteBranch

public void deleteBranch(String name)
                  throws GitException
Specified by:
deleteBranch in interface IGitAPI
Throws:
GitException

getBranches

public Set<Branch> getBranches()
                        throws GitException
Specified by:
getBranches in interface IGitAPI
Throws:
GitException

getRemoteBranches

public Set<Branch> getRemoteBranches()
                              throws GitException
Specified by:
getRemoteBranches in interface IGitAPI
Throws:
GitException

tag

public void tag(String name,
                String message)
         throws GitException
Specified by:
tag in interface IGitAPI
Throws:
GitException

tagExists

public boolean tagExists(String tagName)
                  throws GitException
Specified by:
tagExists in interface IGitAPI
Throws:
GitException

fetch

public void fetch(String remote,
                  org.eclipse.jgit.transport.RefSpec refspec)
           throws GitException
Specified by:
fetch in interface IGitAPI
Throws:
GitException

getHeadRev

public org.eclipse.jgit.lib.ObjectId getHeadRev(String remoteRepoUrl,
                                                String branch)
                                         throws GitException
Specified by:
getHeadRev in interface IGitAPI
Throws:
GitException

getRemoteUrl

public String getRemoteUrl(String name)
                    throws GitException
Description copied from interface: IGitAPI
From a given repository, get a remote's URL

Specified by:
getRemoteUrl in interface IGitAPI
Parameters:
name - The name of the remote (e.g. origin)
Throws:
GitException - if executing the git command fails

getRepository

public org.eclipse.jgit.lib.Repository getRepository()
                                              throws IOException
Specified by:
getRepository in interface IGitAPI
Throws:
IOException

addNote

public void addNote(String note,
                    String namespace)
             throws GitException
Specified by:
addNote in interface IGitAPI
Throws:
GitException

appendNote

public void appendNote(String note,
                       String namespace)
                throws GitException
Specified by:
appendNote in interface IGitAPI
Throws:
GitException

changelog

public void changelog(String revFrom,
                      String revTo,
                      OutputStream fos)
               throws GitException
Description copied from interface: IGitAPI
Adds the changelog entries for commits in the range revFrom..revTo.

Specified by:
changelog in interface IGitAPI
Throws:
GitException

clean

public void clean()
           throws GitException
Specified by:
clean in interface IGitAPI
Throws:
GitException

clone

public void clone(String url,
                  String origin,
                  boolean useShallowClone,
                  String reference)
           throws GitException
Description copied from interface: IGitAPI
Clone a remote repository

Specified by:
clone in interface IGitAPI
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

deleteTag

public void deleteTag(String tagName)
               throws GitException
Specified by:
deleteTag in interface IGitAPI
Throws:
GitException

getSubmodules

public List<IndexEntry> getSubmodules(String treeIsh)
                               throws GitException
Specified by:
getSubmodules in interface IGitAPI
Throws:
GitException

getTagNames

public Set<String> getTagNames(String tagPattern)
                        throws GitException
Specified by:
getTagNames in interface IGitAPI
Throws:
GitException

hasGitModules

public boolean hasGitModules()
                      throws GitException
Description copied from interface: IGitAPI
Returns true if the repository has Git submodules.

Specified by:
hasGitModules in interface IGitAPI
Throws:
GitException

hasGitRepo

public boolean hasGitRepo()
                   throws GitException
Specified by:
hasGitRepo in interface IGitAPI
Throws:
GitException

isCommitInRepo

public boolean isCommitInRepo(org.eclipse.jgit.lib.ObjectId commit)
                       throws GitException
Specified by:
isCommitInRepo in interface IGitAPI
Throws:
GitException

merge

public void merge(org.eclipse.jgit.lib.ObjectId revSpec)
           throws GitException
Specified by:
merge in interface IGitAPI
Throws:
GitException

prune

public void prune(org.eclipse.jgit.transport.RemoteConfig repository)
           throws GitException
Specified by:
prune in interface IGitAPI
Throws:
GitException

push

public void push(String remoteName,
                 String revspec)
          throws GitException
Specified by:
push in interface IGitAPI
Throws:
GitException

revListAll

public List<org.eclipse.jgit.lib.ObjectId> revListAll()
                                               throws GitException
Specified by:
revListAll in interface IGitAPI
Throws:
GitException

revParse

public org.eclipse.jgit.lib.ObjectId revParse(String revName)
                                       throws GitException
Specified by:
revParse in interface IGitAPI
Throws:
GitException

setRemoteUrl

public void setRemoteUrl(String name,
                         String url)
                  throws GitException
Description copied from interface: IGitAPI
For a given repository, set a remote's URL

Specified by:
setRemoteUrl in interface IGitAPI
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

setupSubmoduleUrls

public void setupSubmoduleUrls(Revision rev,
                               hudson.model.TaskListener listener)
                        throws GitException
Description copied from interface: IGitAPI
Set up submodule URLs so that they correspond to the remote pertaining to the revision that has been checked out.

Specified by:
setupSubmoduleUrls in interface IGitAPI
Throws:
GitException

showRevision

public List<String> showRevision(org.eclipse.jgit.lib.ObjectId from,
                                 org.eclipse.jgit.lib.ObjectId to)
                          throws GitException
Description copied from interface: IGitAPI
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, changes for to commit are considered.

Specified by:
showRevision in interface IGitAPI
Returns:
The git show output, in raw format.
Throws:
GitException

submoduleClean

public void submoduleClean(boolean recursive)
                    throws GitException
Specified by:
submoduleClean in interface IGitAPI
Throws:
GitException

submoduleUpdate

public void submoduleUpdate(boolean recursive)
                     throws GitException
Specified by:
submoduleUpdate in interface IGitAPI
Throws:
GitException


Copyright © 2004-2013. All Rights Reserved.