org.jenkinsci.plugins.gitclient
Interface GitClient

All Known Subinterfaces:
IGitAPI
All Known Implementing Classes:
CliGitAPIImpl, GitAPI, JGitAPIImpl

public interface GitClient

Author:
Nicolas De Loof

Field Summary
static boolean verbose
           
 
Method Summary
 void add(String filePattern)
           
 void addNote(String note, String namespace)
           
 void addSubmodule(String remoteURL, String subdir)
          Create a submodule in subdir child directory for remote repository
 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 ref)
          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()
          Fully revert working copy to a clean state, i.e. run both git-reset(1) --hard then git-clean(1) for working copy to match a fresh clone.
 void clone(String url, String origin, boolean useShallowClone, String reference)
          Clone a remote repository
 void commit(String message)
          Deprecated. use commit(String, org.eclipse.jgit.lib.PersonIdent, org.eclipse.jgit.lib.PersonIdent) as this method is environment dependent to have GIT_AUTHOR/COMMITTER set
 void commit(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer)
           
 void deleteBranch(String name)
          (force) delete a branch.
 void deleteTag(String tagName)
           
 void fetch(String remoteName, org.eclipse.jgit.transport.RefSpec refspec)
          Fetch a remote repository.
 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()
          Expose the JGit repository this GitClient is using.
 List<IndexEntry> getSubmodules(String treeIsh)
           
 String getTagMessage(String tagName)
           
 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 rev)
           
 void prune(org.eclipse.jgit.transport.RemoteConfig repository)
           
 void push(String remoteName, String refspec)
           
 List<org.eclipse.jgit.lib.ObjectId> revList(String ref)
           
 List<org.eclipse.jgit.lib.ObjectId> revListAll()
           
 org.eclipse.jgit.lib.ObjectId revParse(String revName)
          Retrieve commit object that is direct child for revName revision reference.
 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 r)
           
 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.
 GitClient subGit(String subdir)
           
 void submoduleClean(boolean recursive)
           
 void submoduleUpdate(boolean recursive)
           
 void tag(String tagName, String comment)
          Create (or update) a tag.
 boolean tagExists(String tagName)
           
 

Field Detail

verbose

static final boolean verbose
Method Detail

getRepository

org.eclipse.jgit.lib.Repository getRepository()
                                              throws GitException
Expose the JGit repository this GitClient is using. Don't forget to call Repository.close(), to avoid JENKINS-12188.

Throws:
GitException

init

void init()
          throws GitException
Throws:
GitException

add

void add(String filePattern)
         throws GitException
Throws:
GitException

commit

void commit(String message)
            throws GitException
Deprecated. use commit(String, org.eclipse.jgit.lib.PersonIdent, org.eclipse.jgit.lib.PersonIdent) as this method is environment dependent to have GIT_AUTHOR/COMMITTER set

Throws:
GitException

commit

void commit(String message,
            org.eclipse.jgit.lib.PersonIdent author,
            org.eclipse.jgit.lib.PersonIdent committer)
            throws GitException
Throws:
GitException

hasGitRepo

boolean hasGitRepo()
                   throws GitException
Throws:
GitException

isCommitInRepo

boolean isCommitInRepo(org.eclipse.jgit.lib.ObjectId commit)
                       throws GitException
Throws:
GitException

getRemoteUrl

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)
Throws:
GitException - if executing the git command fails

setRemoteUrl

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

checkout

void checkout(String ref)
              throws GitException
Checks out the specified commit/tag/branch into the workspace.

Parameters:
ref - A git object references expression (either a sha1, tag or branch)
Throws:
GitException

checkout

void checkout(String ref,
              String branch)
              throws GitException
Checks out the specified commit/ref into the workspace, creating specified branch (equivalent to git checkout -b branch commit

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

clone

void clone(String url,
           String origin,
           boolean useShallowClone,
           String reference)
           throws GitException
Clone a remote repository

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

fetch

void fetch(String remoteName,
           org.eclipse.jgit.transport.RefSpec refspec)
           throws GitException
Fetch a remote repository. Assumes remote.remoteName.url has been set.

Throws:
GitException

push

void push(String remoteName,
          String refspec)
          throws GitException
Throws:
GitException

merge

void merge(org.eclipse.jgit.lib.ObjectId rev)
           throws GitException
Throws:
GitException

prune

void prune(org.eclipse.jgit.transport.RemoteConfig repository)
           throws GitException
Throws:
GitException

clean

void clean()
           throws GitException
Fully revert working copy to a clean state, i.e. run both git-reset(1) --hard then git-clean(1) for working copy to match a fresh clone.

Throws:
GitException

branch

void branch(String name)
            throws GitException
Throws:
GitException

deleteBranch

void deleteBranch(String name)
                  throws GitException
(force) delete a branch.

Throws:
GitException

getBranches

Set<Branch> getBranches()
                        throws GitException
Throws:
GitException

getRemoteBranches

Set<Branch> getRemoteBranches()
                              throws GitException
Throws:
GitException

tag

void tag(String tagName,
         String comment)
         throws GitException
Create (or update) a tag. If tag already exist it gets updated (equivalent to git tag --force)

Throws:
GitException

tagExists

boolean tagExists(String tagName)
                  throws GitException
Throws:
GitException

getTagMessage

String getTagMessage(String tagName)
                     throws GitException
Throws:
GitException

deleteTag

void deleteTag(String tagName)
               throws GitException
Throws:
GitException

getTagNames

Set<String> getTagNames(String tagPattern)
                        throws GitException
Throws:
GitException

getHeadRev

org.eclipse.jgit.lib.ObjectId getHeadRev(String remoteRepoUrl,
                                         String branch)
                                         throws GitException
Throws:
GitException

revParse

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
Throws:
GitException - when no such commit / revName is found in repository.

revListAll

List<org.eclipse.jgit.lib.ObjectId> revListAll()
                                               throws GitException
Throws:
GitException

revList

List<org.eclipse.jgit.lib.ObjectId> revList(String ref)
                                            throws GitException
Throws:
GitException

subGit

GitClient subGit(String subdir)
Returns:
a IGitAPI implementation to manage git submodule repository

hasGitModules

boolean hasGitModules()
                      throws GitException
Returns true if the repository has Git submodules.

Throws:
GitException

getSubmodules

List<IndexEntry> getSubmodules(String treeIsh)
                               throws GitException
Throws:
GitException

addSubmodule

void addSubmodule(String remoteURL,
                  String subdir)
                  throws GitException
Create a submodule in subdir child directory for remote repository

Throws:
GitException

submoduleUpdate

void submoduleUpdate(boolean recursive)
                     throws GitException
Throws:
GitException

submoduleClean

void submoduleClean(boolean recursive)
                    throws GitException
Throws:
GitException

setupSubmoduleUrls

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

Throws:
GitException

changelog

void changelog(String revFrom,
               String revTo,
               OutputStream fos)
               throws GitException
Adds the changelog entries for commits in the range revFrom..revTo.

Throws:
GitException

appendNote

void appendNote(String note,
                String namespace)
                throws GitException
Throws:
GitException

addNote

void addNote(String note,
             String namespace)
             throws GitException
Throws:
GitException

showRevision

List<String> showRevision(org.eclipse.jgit.lib.ObjectId r)
                          throws GitException
Throws:
GitException

showRevision

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.

Returns:
The git show output, in raw format.
Throws:
GitException


Copyright © 2004-2013. All Rights Reserved.