Interface GitClient
- All Known Subinterfaces:
IGitAPI
- All Known Implementing Classes:
CliGitAPIImpl
,GitAPI
,JGitAPIImpl
Since 1.1, this interface is remotable, meaning it can be referenced from a remote closure call.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Level of git configuration that will be adjusted by configuration changes. -
Field Summary
Modifier and TypeFieldDescriptionstatic final com.cloudbees.plugins.credentials.CredentialsMatcher
The supported credential types.static final boolean
ConstantquietRemoteBranches=Boolean.getBoolean(GitClient.class.getName() + ".quietRemoteBranches")
static final boolean
Constantverbose=Boolean.getBoolean(IGitAPI.class.getName() + ".verbose")
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add.void
addCredentials
(String url, com.cloudbees.plugins.credentials.common.StandardCredentials credentials) Adds credentials to be used against a specific url.void
addDefaultCredentials
(com.cloudbees.plugins.credentials.common.StandardCredentials credentials) Adds credentials to be used when there are not url specific credentials defined.void
Adds a new git-note on the current HEAD commit.void
addRemoteUrl
(String name, String url) addRemoteUrl.void
addSubmodule
(String remoteURL, String subdir) Create a submodule in subdir child directory for remote repositoryvoid
appendNote
(String note, String namespace) Appends to an existing git-note on the current HEAD commit.void
branch.Returns aChangelogCommand
to build up the git-log invocation.void
changelog
(String revFrom, String revTo, OutputStream os) Deprecated.void
Adds the changelog entries for commits in the range revFrom..revTo.checkout()
checkout.void
Deprecated.usecheckout()
andCheckoutCommand
void
Deprecated.usecheckout()
andCheckoutCommand
void
checkoutBranch
(String branch, String ref) 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 refHEAD
points to branch.void
clean()
Fully revert working copy to a clean state, i.e.void
clean
(boolean cleanSubmodule) Fully revert working copy to a clean state, i.e.void
Remove all credentials from the client.void
Clone a remote repositoryclone_()
Returns aCloneCommand
to build up the git-log invocation.void
commit.void
commit
(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer) Deprecated.void
config
(GitClient.ConfigLevel configLevel, String key, String value) Execute git config at the specified configuration level.void
deleteBranch
(String name) (force) delete a branch.void
Deletes a ref.void
deleteTag.Equivalent of "git-describe --tags".void
Deprecated.usefetch_()
and configure aFetchCommand
void
Deprecated.usefetch_()
and configure aFetchCommand
void
Deprecated.usefetch_()
and configure aFetchCommand
fetch_()
fetch_.getBranches.getBranchesContaining
(String revspec, boolean allBranches) Find all the branches that include the given commit.getHeadRev
(String url) getHeadRev.org.eclipse.jgit.lib.ObjectId
getHeadRev
(String remoteRepoUrl, String branch) getHeadRev.getRefNames
(String refPrefix) List refs with the given prefix.getRemoteBranches.getRemoteReferences
(String remoteRepoUrl, String pattern, boolean headsOnly, boolean tagsOnly) List references in a remote repository.getRemoteSymbolicReferences
(String remoteRepoUrl, String pattern) List symbolic references in a remote repository.getRemoteTagNames
(String tagPattern) getRemoteTagNames.getRemoteUrl
(String name) From a given repository, get a remote's URLorg.eclipse.jgit.lib.Repository
Deprecated.as of 1.1 This method was deprecated to makeGitClient
remotable.getSubmodules
(String treeIsh) Finds all the submodule references in this repository at the specified tree.getTagMessage
(String tagName) getTagMessage.getTagNames
(String tagPattern) getTagNames.getTags()
Return name and object ID of all tags in current repository.The working tree of this repository.boolean
Returns true if the repository has Git submodules.boolean
Return true if the current workspace has a git repository.boolean
hasGitRepo
(boolean checkParentDirectories) Return true if the current workspace has a git repository.void
init()
init.init_()
init_.boolean
isCommitInRepo
(org.eclipse.jgit.lib.ObjectId commit) isCommitInRepo.boolean
maintenance
(String task) Executes git maintenance commands based on the git version.merge()
merge.void
merge
(org.eclipse.jgit.lib.ObjectId rev) Deprecated.usemerge()
and configure aMergeCommand
void
prune
(org.eclipse.jgit.transport.RemoteConfig repository) Prune stale remote tracking branches with "git remote prune" on the specified remote.push()
push.void
Deprecated.usepush()
and configure aPushCommand
void
Deprecated.usepush()
and configure aPushCommand
rebase()
rebase.void
Create (or update) a ref.boolean
Check if a ref exists.List<org.eclipse.jgit.lib.ObjectId>
revList.revList_()
revList_.List<org.eclipse.jgit.lib.ObjectId>
revListAll.org.eclipse.jgit.lib.ObjectId
Retrieve commit object that is direct child forrevName
revision reference.void
Sets the identity of the author for future commits and merge operations.void
setAuthor
(org.eclipse.jgit.lib.PersonIdent p) setAuthor.void
setCommitter
(String name, String email) Sets the identity of the committer for future commits and merge operations.void
setCommitter
(org.eclipse.jgit.lib.PersonIdent p) setCommitter.void
setCredentials
(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred) setCredentials.void
setProxy
(ProxyConfiguration proxy) setProxy.void
setRemoteUrl
(String name, String url) For a given repository, set a remote's URLvoid
setupSubmoduleUrls
(Revision rev, TaskListener listener) Set up submodule URLs so that they correspond to the remote pertaining to the revision that has been checked out.showRevision
(org.eclipse.jgit.lib.ObjectId r) Given a Revision, show it as if it were an entry from git whatchanged, so that it can be parsed by GitChangeLogParser.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.showRevision
(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to, Boolean useRawOutput) Given a Revision, show it as if it were an entry from git whatchanged, so that it can be parsed by GitChangeLogParser.subGit.void
submoduleClean
(boolean recursive) submoduleClean.void
submoduleInit.submoduleUpdate.void
submoduleUpdate
(boolean recursive) Deprecated.void
submoduleUpdate
(boolean recursive, boolean remoteTracking) Deprecated.void
submoduleUpdate
(boolean recursive, boolean remoteTracking, String reference) Deprecated.void
submoduleUpdate
(boolean recursive, String reference) Deprecated.void
Create (or update) a tag.boolean
tagExists.<T> T
withRepository
(RepositoryCallback<T> callable) Runs the computation that requires local access toRepository
.
-
Field Details
-
verbose
static final boolean verboseConstantverbose=Boolean.getBoolean(IGitAPI.class.getName() + ".verbose")
-
quietRemoteBranches
static final boolean quietRemoteBranchesConstantquietRemoteBranches=Boolean.getBoolean(GitClient.class.getName() + ".quietRemoteBranches")
-
CREDENTIALS_MATCHER
static final com.cloudbees.plugins.credentials.CredentialsMatcher CREDENTIALS_MATCHERThe supported credential types.- Since:
- 1.2.0
-
-
Method Details
-
clearCredentials
void clearCredentials()Remove all credentials from the client.- Since:
- 1.2.0
-
addCredentials
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.- Since:
- 1.2.0
-
addDefaultCredentials
void addDefaultCredentials(com.cloudbees.plugins.credentials.common.StandardCredentials credentials) Adds credentials to be used when there are not url specific credentials defined.- Parameters:
credentials
- the credentials to use.- Since:
- 1.2.0
- See Also:
-
setAuthor
Sets the identity of the author for future commits and merge operations.- Parameters:
name
- aString
object.email
- aString
object.- Throws:
GitException
- if underlying git operation fails.
-
setAuthor
setAuthor.- Parameters:
p
- aPersonIdent
object.- Throws:
GitException
- if underlying git operation fails.
-
setCommitter
Sets the identity of the committer for future commits and merge operations.- Parameters:
name
- aString
object.email
- aString
object.- Throws:
GitException
- if underlying git operation fails.
-
setCommitter
setCommitter.- Parameters:
p
- aPersonIdent
object.- Throws:
GitException
- if underlying git operation fails.
-
getRepository
Deprecated.as of 1.1 This method was deprecated to makeGitClient
remotable. When called on a proxy object, this method throwsNotSerializableException
. UsewithRepository(RepositoryCallback)
to pass in the closure instead. This prevents the repository leak (JENKINS-12188), too.Expose the JGit repository this GitClient is using. Don't forget to callRepository.close()
, to avoid JENKINS-12188.- Returns:
- a
Repository
object. - Throws:
GitException
- if underlying git operation fails.
-
withRepository
<T> T withRepository(RepositoryCallback<T> callable) throws GitException, IOException, InterruptedException Runs the computation that requires local access toRepository
.- Type Parameters:
T
- type for the repository callback- Parameters:
callable
- the repository callback used as closure to instance- Returns:
- a T object.
- Throws:
IOException
- in case of IO errorInterruptedException
- if interruptedGitException
-
getWorkTree
FilePath getWorkTree()The working tree of this repository.- Returns:
- a
FilePath
object.
-
init
init.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
add
add.- Parameters:
filePattern
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
commit
commit.- Parameters:
message
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
commit
@Deprecated void commit(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer) throws GitException, InterruptedException Deprecated.commit.- Parameters:
message
- aString
object.author
- aPersonIdent
object.committer
- aPersonIdent
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
hasGitRepo
Return true if the current workspace has a git repository.- Returns:
- true if this workspace has a git repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
hasGitRepo
Return 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 upward for a git repository- Returns:
- true if this workspace has a git repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
isCommitInRepo
boolean isCommitInRepo(org.eclipse.jgit.lib.ObjectId commit) throws GitException, InterruptedException isCommitInRepo.- Parameters:
commit
- aObjectId
object.- Returns:
- true if commit is in repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getRemoteUrl
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 failsInterruptedException
- if interrupted.
-
setRemoteUrl
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 failsInterruptedException
- if interrupted.
-
addRemoteUrl
addRemoteUrl.- Parameters:
name
- aString
object.url
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
checkout
Deprecated.usecheckout()
andCheckoutCommand
Checks out the specified commit/tag/branch into the workspace. (equivalent ofgit checkout branch
.)- Parameters:
ref
- A git object references expression (either a sha1, tag or branch)- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
checkout
Deprecated.usecheckout()
andCheckoutCommand
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.- Parameters:
ref
- A git object references expression. For backward compatibility,null
will checkout current HEADbranch
- name of the branch to create from reference- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
checkout
CheckoutCommand checkout()checkout.- Returns:
- a
CheckoutCommand
object.
-
checkoutBranch
void checkoutBranch(@CheckForNull 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
checkout(String, String)
family of methods, as this method is affected far less by the current state of the repository. Thecheckout
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
checkout(String, String)
.- Parameters:
branch
- aString
object.ref
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.- Since:
- 1.0.6
-
clone
void clone(String url, String origin, boolean useShallowClone, String reference) throws GitException, InterruptedException Clone a remote repository- Parameters:
url
- URL for remote repository to cloneorigin
- upstream track name, defaults toorigin
by conventionuseShallowClone
- option to create a shallow clone, that has some restriction but will make clone operationreference
- (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.
-
clone_
CloneCommand clone_()Returns aCloneCommand
to build up the git-log invocation.- Returns:
- a
CloneCommand
object.
-
fetch
@Deprecated void fetch(org.eclipse.jgit.transport.URIish url, List<org.eclipse.jgit.transport.RefSpec> refspecs) throws GitException, InterruptedException Deprecated.usefetch_()
and configure aFetchCommand
Fetch commits from url which match any of the passed in refspecs. Assumesremote.remoteName.url
has been set.- Parameters:
url
- aURIish
object.refspecs
- aList
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
fetch
@Deprecated void fetch(String remoteName, org.eclipse.jgit.transport.RefSpec... refspec) throws GitException, InterruptedException Deprecated.usefetch_()
and configure aFetchCommand
fetch.- Parameters:
remoteName
- aString
object.refspec
- aRefSpec
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
fetch
@Deprecated void fetch(String remoteName, org.eclipse.jgit.transport.RefSpec refspec) throws GitException, InterruptedException Deprecated.usefetch_()
and configure aFetchCommand
fetch.- Parameters:
remoteName
- aString
object.refspec
- aRefSpec
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
fetch_
FetchCommand fetch_()fetch_.- Returns:
- a
FetchCommand
object.
-
push
Deprecated.usepush()
and configure aPushCommand
push.- Parameters:
remoteName
- aString
object.refspec
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
push
@Deprecated void push(org.eclipse.jgit.transport.URIish url, String refspec) throws GitException, InterruptedException Deprecated.usepush()
and configure aPushCommand
push.- Parameters:
url
- aURIish
object.refspec
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
push
PushCommand push()push.- Returns:
- a
PushCommand
object.
-
merge
Deprecated.usemerge()
and configure aMergeCommand
merge.- Parameters:
rev
- aObjectId
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
merge
MergeCommand merge()merge.- Returns:
- a
MergeCommand
object.
-
rebase
RebaseCommand rebase()rebase.- Returns:
- a
RebaseCommand
object.
-
init_
InitCommand init_()init_.- Returns:
- a
InitCommand
object.
-
prune
void prune(org.eclipse.jgit.transport.RemoteConfig repository) throws GitException, InterruptedException Prune stale remote tracking branches with "git remote prune" on the specified remote.- Parameters:
repository
- aRemoteConfig
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
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.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
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.- Parameters:
cleanSubmodule
- flag to add extra -f- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
branch
branch.- Parameters:
name
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
deleteBranch
(force) delete a branch.- Parameters:
name
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getBranches
getBranches.- Returns:
- a
Set
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getRemoteBranches
getRemoteBranches.- Returns:
- a
Set
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
tag
Create (or update) a tag. If tag already exist it gets updated (equivalent togit tag --force
)- Parameters:
tagName
- aString
object.comment
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
tagExists
tagExists.- Parameters:
tagName
- aString
object.- Returns:
- true if tag exists in repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getTagMessage
getTagMessage.- Parameters:
tagName
- aString
object.- Returns:
- a
String
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
deleteTag
deleteTag.- Parameters:
tagName
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getTagNames
getTagNames.- Parameters:
tagPattern
- aString
object.- Returns:
- a
Set
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getRemoteTagNames
getRemoteTagNames.- Parameters:
tagPattern
- aString
object.- Returns:
- a
Set
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
ref
Create (or update) a ref. The ref will reference HEAD (equivalent togit 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
Check if a ref exists. Equivalent to comparing the return code ofgit 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 otherwise.
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
deleteRef
Deletes a ref. Has no effect if the ref does not exist, equivalent togit 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
List refs with the given prefix. Equivalent togit 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.
-
getHeadRev
Map<String,org.eclipse.jgit.lib.ObjectId> getHeadRev(String url) throws GitException, InterruptedException getHeadRev.- Parameters:
url
- aString
object.- Returns:
- a
Map
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getHeadRev
org.eclipse.jgit.lib.ObjectId getHeadRev(String remoteRepoUrl, String branch) throws GitException, InterruptedException getHeadRev.- Parameters:
remoteRepoUrl
- aString
object.branch
- aString
object.- Returns:
- a
ObjectId
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getRemoteReferences
Map<String,org.eclipse.jgit.lib.ObjectId> getRemoteReferences(String remoteRepoUrl, String pattern, boolean headsOnly, boolean tagsOnly) throws GitException, InterruptedException List references in a remote repository. Equivalent togit ls-remote [--heads] [--tags] <repository> [<refs>]
.- Parameters:
remoteRepoUrl
- 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
Map<String,String> getRemoteSymbolicReferences(String remoteRepoUrl, String pattern) throws GitException, InterruptedException List symbolic references in a remote repository. Equivalent togit ls-remote --symref <repository> [<refs>]
. Note: the response may be empty for multiple reasons- Parameters:
remoteRepoUrl
- 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 or if the command line git version does not support reporting symbolic references.
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
revParse
Retrieve commit object that is direct child forrevName
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.InterruptedException
- if interrupted.
-
revList_
RevListCommand revList_()revList_.- Returns:
- a
RevListCommand
object.
-
revListAll
revListAll.- Returns:
- a
List
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
revList
revList.- Parameters:
ref
- aString
object.- Returns:
- a
List
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
subGit
subGit.- Parameters:
subdir
- aString
object.- Returns:
- a IGitAPI implementation to manage git submodule repository
-
hasGitModules
Returns true if the repository has Git submodules.- Returns:
- true if this repository has submodules
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getSubmodules
Finds all the submodule references in this repository at the specified tree.- Parameters:
treeIsh
- aString
object.- Returns:
- never null.
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
addSubmodule
Create a submodule in subdir child directory for remote repository- Parameters:
remoteURL
- aString
object.subdir
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
submoduleUpdate
Deprecated.Run submodule update optionally recursively on all submodules (equivalent ofgit submodule update --recursive
.)- Parameters:
recursive
- a boolean.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
submoduleUpdate
@Deprecated void submoduleUpdate(boolean recursive, String reference) throws GitException, InterruptedException Deprecated.Run submodule update optionally recursively on all submodules, with a specific reference passed to git clone if needing to --init. (equivalent ofgit submodule update --recursive --reference 'reference'
.)- Parameters:
recursive
- a boolean.reference
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
submoduleUpdate
@Deprecated void submoduleUpdate(boolean recursive, boolean remoteTracking) throws GitException, InterruptedException Deprecated.Run submodule update optionally recursively on all submodules, optionally with remoteTracking submodules (equivalent ofgit submodule update --recursive --remote
.)- Parameters:
recursive
- a boolean.remoteTracking
- a boolean.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
submoduleUpdate
@Deprecated void submoduleUpdate(boolean recursive, boolean remoteTracking, String reference) throws GitException, InterruptedException Deprecated.Run submodule update optionally recursively on all submodules, optionally with remoteTracking, with a specific reference passed to git clone if needing to --init. (equivalent ofgit submodule update --recursive --remote --reference 'reference'
.)- Parameters:
recursive
- a boolean.remoteTracking
- a boolean.reference
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
submoduleUpdate
SubmoduleUpdateCommand submoduleUpdate()submoduleUpdate.- Returns:
- a
SubmoduleUpdateCommand
object.
-
submoduleClean
submoduleClean.- Parameters:
recursive
- a boolean.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
submoduleInit
submoduleInit.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
setupSubmoduleUrls
void setupSubmoduleUrls(Revision rev, TaskListener listener) throws GitException, InterruptedException Set up submodule URLs so that they correspond to the remote pertaining to the revision that has been checked out.- Parameters:
rev
- aRevision
object.listener
- aTaskListener
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
changelog
@Deprecated void changelog(String revFrom, String revTo, OutputStream os) throws GitException, InterruptedException Deprecated.changelog.- Parameters:
revFrom
- aString
object.revTo
- aString
object.os
- aOutputStream
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
changelog
Adds the changelog entries for commits in the range revFrom..revTo. This is just a short cut for callingchangelog()
with appropriate parameters.- Parameters:
revFrom
- aString
object.revTo
- aString
object.os
- aWriter
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
changelog
Returns aChangelogCommand
to build up the git-log invocation.- Returns:
- a
ChangelogCommand
object. - Throws:
GitException
-
appendNote
Appends to an existing git-note on the current HEAD commit. If a note doesn't exist, it works just likeaddNote(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.InterruptedException
- if interrupted.
-
addNote
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.InterruptedException
- if interrupted.
-
showRevision
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 thatto
represents.For merge commit, this method reports one diff per each parent. This makes this method behave differently from
changelog()
.- Parameters:
r
- aObjectId
object.- Returns:
- The git whatchanged output, in
raw
format. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
showRevision
List<String> showRevision(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to) 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 thatto
represents.For merge commit, this method reports one diff per each parent. This makes this method behave differently from
changelog()
.- Parameters:
from
- aObjectId
object.to
- aObjectId
object.- Returns:
- The git whatchanged output, in
raw
format. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
showRevision
List<String> showRevision(org.eclipse.jgit.lib.ObjectId from, org.eclipse.jgit.lib.ObjectId to, Boolean useRawOutput) 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.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 thatto
represents.For merge commit, this method reports one diff per each parent. This makes this method behave differently from
changelog()
.- Parameters:
from
- aObjectId
object.to
- aObjectId
object.useRawOutput
- a {java.lang.Boolean} object.- Returns:
- The git whatchanged output, in
raw
format. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
describe
Equivalent of "git-describe --tags". Find a nearby tag (including unannotated ones) and come up with a short identifier to describe the tag.- Parameters:
commitIsh
- aString
object.- Returns:
- a
String
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
setCredentials
void setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred) setCredentials.- Parameters:
cred
- aStandardUsernameCredentials
object.
-
setProxy
setProxy.- Parameters:
proxy
- aProxyConfiguration
object.
-
getBranchesContaining
List<Branch> getBranchesContaining(String revspec, boolean allBranches) throws GitException, InterruptedException Find all the branches that include the given commit.- Parameters:
revspec
- commit id to query forallBranches
- whether remote branches should be also queried (true
) or not (false
)- Returns:
- list of branches the specified commit belongs to
- Throws:
GitException
- on Git exceptionsInterruptedException
- on thread interruption
-
getTags
Return name and object ID of all tags in current repository.- Returns:
- set of tags in current repository
- Throws:
GitException
- on Git exceptionsInterruptedException
- on thread interruption
-
maintenance
Executes git maintenance commands based on the git version.- Parameters:
task
- aString
object. i.e (prefetch/gc/commit-graph/incremental-repack/loose-objects)- Returns:
- Boolean if maintenance has been executed or not.
- Throws:
InterruptedException
- if underlying git operation fails.
-
config
void config(GitClient.ConfigLevel configLevel, String key, String value) throws GitException, InterruptedException Execute git config at the specified configuration level. If value is null, the key will be removed from the configuration.- Parameters:
configLevel
- configuration level that will be modified. If null, thenGitClient.ConfigLevel.LOCAL
will be used.key
- configuration section expressed assection[.subsection].name
value
- configuration value. If null, the key will be removed from the configuration (unset)- Throws:
GitException
- on Git exceptionInterruptedException
- on thread interruption
-
changelog(String, String, Writer)