Class GitAPI
- java.lang.Object
-
- org.jenkinsci.plugins.gitclient.CliGitAPIImpl
-
- hudson.plugins.git.GitAPI
-
- All Implemented Interfaces:
IGitAPI
,Serializable
,GitClient
@Deprecated public class GitAPI extends CliGitAPIImpl
Deprecated.Backward compatible class to match the one some plugins used from git-plugin. Extends CliGitAPIImpl to implement deprecated IGitAPI methods, but delegates supported methods to the selected git implementation (based onGit.USE_CLI
). New implementations should useGitClient
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jenkinsci.plugins.gitclient.GitClient
GitClient.ConfigLevel
-
-
Field Summary
Fields Modifier and Type Field Description protected ProxyConfiguration
proxy
protected File
workspace
-
Fields inherited from class org.jenkinsci.plugins.gitclient.CliGitAPIImpl
TIMEOUT, USE_SETSID
-
Fields inherited from interface org.jenkinsci.plugins.gitclient.GitClient
CREDENTIALS_MATCHER, quietRemoteBranches, verbose
-
-
Constructor Summary
Constructors Constructor Description GitAPI(String gitExe, FilePath repository, TaskListener listener, EnvVars environment)
Deprecated.GitAPI(String gitExe, FilePath repository, TaskListener listener, EnvVars environment, String reference)
Deprecated.GitAPI(String gitExe, File repository, TaskListener listener, EnvVars environment)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
add(String filePattern)
Deprecated.add.void
branch(String name)
Deprecated.branch.void
changelog(String revFrom, String revTo, OutputStream outputStream)
changelog.void
changelog(String revFrom, String revTo, Writer w)
Adds the changelog entries for commits in the range revFrom..revTo.void
checkout(String ref)
Deprecated.Checks out the specified commit/tag/branch into the workspace.void
checkout(String ref, String branch)
Deprecated.Creates a new branch that points to the specified ref.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()
Deprecated.Remove untracked files and directories, including files listed in the ignore rules.void
clone(String url, String origin, boolean useShallowClone, String reference)
Clone a remote repositoryvoid
clone(org.eclipse.jgit.transport.RemoteConfig source)
Deprecated.void
clone(org.eclipse.jgit.transport.RemoteConfig rc, boolean useShallowClone)
Deprecated.void
commit(String message)
Deprecated.commit.void
commit(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer)
Deprecated.commit.void
deleteBranch(String name)
Deprecated.(force) delete a branch.void
deleteTag(String tagName)
Deprecated.deleteTag.protected String
extractBranchNameFromBranchSpec(String branchSpec)
This method takes a branch specification and normalizes it get unambiguous results.void
fetch()
Deprecated.void
fetch(String repository, String refspec)
Deprecated.void
fetch(String remoteName, org.eclipse.jgit.transport.RefSpec refspec)
Deprecated.fetch.void
fetch(String remoteName, org.eclipse.jgit.transport.RefSpec... refspec)
Deprecated.fetch.void
fetch(org.eclipse.jgit.transport.RemoteConfig remoteRepository)
Deprecated.void
fetch(org.eclipse.jgit.transport.URIish url, List<org.eclipse.jgit.transport.RefSpec> refspecs)
Deprecated.Fetch commits from url which match any of the passed in refspecs.Set<Branch>
getBranches()
Deprecated.Returns the set of branches defined in this repository, including local branches and remote branches.HostKeyVerifierFactory
getHostKeyFactory()
Set<Branch>
getRemoteBranches()
Deprecated.Returns the remote branches defined in this repository.String
getRemoteUrl(String name)
Deprecated.From a given repository, get a remote's URLorg.eclipse.jgit.lib.Repository
getRepository()
Deprecated.Returns theRepository
used by this git instance.String
getTagMessage(String tagName)
Deprecated.getTagMessage.List<Tag>
getTagsOnCommit(String revName)
Deprecated.boolean
hasGitModules()
hasGitModules.boolean
hasGitModules(String treeIsh)
Deprecated.boolean
hasGitRepo()
Deprecated.Returns true if this workspace has a git repository.boolean
hasGitRepo(boolean checkParentDirectories)
Deprecated.Returns true if this workspace has a git repository.void
init()
Deprecated.Initialize an empty repository for further git operations.boolean
isBareRepository()
isBareRepository.boolean
isCommitInRepo(org.eclipse.jgit.lib.ObjectId commit)
Deprecated.isCommitInRepo.List<IndexEntry>
lsTree(String treeIsh)
This method has been implemented as non-recursive historically, but often that is not what the caller wants.void
merge(org.eclipse.jgit.lib.ObjectId rev)
merge.void
push(String remoteName, String refspec)
Deprecated.push.void
push(org.eclipse.jgit.transport.URIish url, String refspec)
Deprecated.protected org.jenkinsci.plugins.gitclient.RemoteGitImpl
remoteProxyFor(GitClient proxy)
remoteProxyFor.void
reset()
Deprecated.List<org.eclipse.jgit.lib.ObjectId>
revListBranch(String branchId)
Deprecated.org.eclipse.jgit.lib.ObjectId
revParse(String revName)
Deprecated.Retrieve commit object that is direct child forrevName
revision reference.void
setAuthor(org.eclipse.jgit.lib.PersonIdent p)
setAuthor.void
setCommitter(org.eclipse.jgit.lib.PersonIdent p)
setCommitter.void
setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
setCredentials.void
setHostKeyFactory(HostKeyVerifierFactory verifier)
void
setProxy(ProxyConfiguration proxy)
setProxy.void
setRemoteUrl(String name, String url)
Deprecated.For a given repository, set a remote's URLvoid
setupSubmoduleUrls(String remote, TaskListener listener)
Deprecated.List<String>
showRevision(Revision r)
Deprecated.List<String>
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.GitClient
subGit(String subdir)
Deprecated.subGit.void
submoduleUpdate(boolean recursive)
Run submodule update optionally recursively on all submodules (equivalent ofgit submodule update --recursive
.)void
submoduleUpdate(boolean recursive, boolean remoteTracking)
Run submodule update optionally recursively on all submodules, optionally with remoteTracking submodules (equivalent ofgit submodule update --recursive --remote
.)void
submoduleUpdate(boolean recursive, boolean remoteTracking, String reference)
Run submodule update optionally recursively on all submodules, optionally with remoteTracking, with a specific reference passed to git clone if needing to --init.void
submoduleUpdate(boolean recursive, String reference)
Run submodule update optionally recursively on all submodules, with a specific reference passed to git clone if needing to --init.void
tag(String tagName, String comment)
Deprecated.Create (or update) a tag.boolean
tagExists(String tagName)
Deprecated.tagExists.<T> T
withRepository(RepositoryCallback<T> callable)
Runs the computation that requires local access toRepository
.protected Object
writeReplace()
When sent to remote, switch to the proxy.-
Methods inherited from class org.jenkinsci.plugins.gitclient.CliGitAPIImpl
addCredentials, addDefaultCredentials, addNote, addRemoteUrl, addSubmodule, appendNote, changelog, checkout, clean, clearCredentials, clone_, config, deleteRef, describe, fetch_, fixSubmoduleUrls, getAllLogEntries, getBranchesContaining, getBranchesContaining, getDefaultRemote, getDefaultRemote, getHeadRev, getHeadRev, getRefNames, getRemoteReferences, getRemoteSymbolicReferences, getRemoteTagNames, getRemoteUrl, getSSHExecutable, getSubmodulePath, getSubmodules, getSubmoduleUrl, getTagNames, getTags, getWorkTree, hasGitRepo, init_, isBareRepository, isCliGitVerAtLeast, isShallowRepository, launchCommand, launchCommand, lsTree, maintenance, merge, merge, mergeBase, prune, push, push, rebase, ref, refExists, reset, revList, revList_, revListAll, setAuthor, setCommitter, setRemoteUrl, setSubmoduleUrl, setupSubmoduleUrls, showRevision, showRevision, submoduleClean, submoduleInit, submoduleReset, submoduleSync, submoduleUpdate, validateRevision
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jenkinsci.plugins.gitclient.GitClient
changelog, clone, merge, setAuthor, setCommitter, setCredentials, setProxy, submoduleUpdate, submoduleUpdate, submoduleUpdate, submoduleUpdate, withRepository
-
Methods inherited from interface hudson.plugins.git.IGitAPI
changelog, checkoutBranch
-
-
-
-
Field Detail
-
workspace
protected final File workspace
-
proxy
protected ProxyConfiguration proxy
-
-
Constructor Detail
-
GitAPI
@Deprecated public GitAPI(String gitExe, FilePath repository, TaskListener listener, EnvVars environment) throws IOException, InterruptedException
Deprecated.Constructor for GitAPI.- Parameters:
gitExe
- name of git executable (git or git.exe or jgit)repository
- aFilePath
for the repository directorylistener
- aTaskListener
which monitors the git workenvironment
- theEnvVars
environment for the build- Throws:
IOException
- if any IO failureInterruptedException
- if interrupted
-
GitAPI
@Deprecated public GitAPI(String gitExe, FilePath repository, TaskListener listener, EnvVars environment, String reference) throws IOException, InterruptedException
Deprecated.Constructor for GitAPI.- Parameters:
gitExe
- name of git executable (git or git.exe or jgit)repository
- aFilePath
for the repository directorylistener
- aTaskListener
which monitors the git workenvironment
- theEnvVars
environment for the buildreference
- SHA1 for checkout- Throws:
IOException
- if any IO failureInterruptedException
- if interrupted.
-
GitAPI
@Deprecated public GitAPI(String gitExe, File repository, TaskListener listener, EnvVars environment) throws IOException, InterruptedException
Deprecated.Constructor for GitAPI.- Parameters:
gitExe
- name of git executable (git or git.exe or jgit)repository
- aFilePath
for the repository directorylistener
- aTaskListener
which monitors the git workenvironment
- theEnvVars
environment for the build- Throws:
IOException
- if any IO failureInterruptedException
- if interrupted.
-
-
Method Detail
-
add
public void add(String filePattern) throws GitException, InterruptedException
Deprecated.add.- Specified by:
add
in interfaceGitClient
- Overrides:
add
in classCliGitAPIImpl
- Parameters:
filePattern
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getRemoteUrl
public String getRemoteUrl(String name) throws GitException, InterruptedException
Deprecated.From a given repository, get a remote's URL- Specified by:
getRemoteUrl
in interfaceGitClient
- Overrides:
getRemoteUrl
in classCliGitAPIImpl
- Parameters:
name
- The name of the remote (e.g. origin)- Returns:
- a
String
object. - Throws:
GitException
- if executing the git command failsInterruptedException
- if interrupted.
-
push
public void push(String remoteName, String refspec) throws GitException, InterruptedException
Deprecated.push.- Specified by:
push
in interfaceGitClient
- Parameters:
remoteName
- aString
object.refspec
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getTagMessage
public String getTagMessage(String tagName) throws GitException, InterruptedException
Deprecated.getTagMessage.- Specified by:
getTagMessage
in interfaceGitClient
- Overrides:
getTagMessage
in classCliGitAPIImpl
- Parameters:
tagName
- aString
object.- Returns:
- a
String
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
subGit
public GitClient subGit(String subdir)
Deprecated.subGit.- Specified by:
subGit
in interfaceGitClient
- Overrides:
subGit
in classCliGitAPIImpl
- Parameters:
subdir
- aString
object.- Returns:
- a IGitAPI implementation to manage git submodule repository
-
setRemoteUrl
public void setRemoteUrl(String name, String url) throws GitException, InterruptedException
Deprecated.For a given repository, set a remote's URL- Specified by:
setRemoteUrl
in interfaceGitClient
- Overrides:
setRemoteUrl
in classCliGitAPIImpl
- 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.
-
getBranches
public Set<Branch> getBranches() throws GitException, InterruptedException
Deprecated.Returns the set of branches defined in this repository, including local branches and remote branches. Remote branches are prefixed by "remotes/".- Specified by:
getBranches
in interfaceGitClient
- Overrides:
getBranches
in classCliGitAPIImpl
- Returns:
- a
Set
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getRemoteBranches
public Set<Branch> getRemoteBranches() throws GitException, InterruptedException
Deprecated.Returns the remote branches defined in this repository.- Specified by:
getRemoteBranches
in interfaceGitClient
- Overrides:
getRemoteBranches
in classCliGitAPIImpl
- Returns:
Set
of remote branches in this repository- Throws:
GitException
- if underlying git operation failsInterruptedException
- if interrupted
-
init
public void init() throws GitException, InterruptedException
Deprecated.Initialize an empty repository for further git operations.- Specified by:
init
in interfaceGitClient
- Overrides:
init
in classCliGitAPIImpl
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
deleteBranch
public void deleteBranch(String name) throws GitException, InterruptedException
Deprecated.(force) delete a branch.- Specified by:
deleteBranch
in interfaceGitClient
- Overrides:
deleteBranch
in classCliGitAPIImpl
- Parameters:
name
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
checkout
public void checkout(String ref, String branch) throws GitException, InterruptedException
Deprecated.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 interfaceGitClient
- 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.
-
hasGitRepo
public boolean hasGitRepo() throws GitException, InterruptedException
Deprecated.Returns true if this workspace has a git repository. Also returns true if this workspace contains an empty .git directory and a parent directory has a git repository.- Specified by:
hasGitRepo
in interfaceGitClient
- Overrides:
hasGitRepo
in classCliGitAPIImpl
- Returns:
- true if this workspace has a git repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
hasGitRepo
public boolean hasGitRepo(boolean checkParentDirectories) throws GitException, InterruptedException
Deprecated.Returns true if this workspace has a git repository. If checkParentDirectories is true, searches parent directories. If checkParentDirectories is false, checks workspace directory only.- Specified by:
hasGitRepo
in interfaceGitClient
- Overrides:
hasGitRepo
in classCliGitAPIImpl
- 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
public boolean isCommitInRepo(org.eclipse.jgit.lib.ObjectId commit) throws GitException, InterruptedException
Deprecated.isCommitInRepo.- Specified by:
isCommitInRepo
in interfaceGitClient
- Overrides:
isCommitInRepo
in classCliGitAPIImpl
- Parameters:
commit
- aObjectId
object.- Returns:
- true if commit is in repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
commit
public void commit(String message) throws GitException, InterruptedException
Deprecated.commit.- Specified by:
commit
in interfaceGitClient
- Overrides:
commit
in classCliGitAPIImpl
- Parameters:
message
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
commit
public void commit(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer) throws GitException, InterruptedException
Deprecated.commit.- Specified by:
commit
in interfaceGitClient
- Parameters:
message
- aString
object.author
- aPersonIdent
object.committer
- aPersonIdent
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
checkout
public void checkout(String ref) throws GitException, InterruptedException
Deprecated.Checks out the specified commit/tag/branch into the workspace. (equivalent ofgit checkout branch
.)- Specified by:
checkout
in interfaceGitClient
- Parameters:
ref
- A git object references expression (either a sha1, tag or branch)- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
deleteTag
public void deleteTag(String tagName) throws GitException, InterruptedException
Deprecated.deleteTag.- Specified by:
deleteTag
in interfaceGitClient
- Overrides:
deleteTag
in classCliGitAPIImpl
- Parameters:
tagName
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getRepository
@NonNull public org.eclipse.jgit.lib.Repository getRepository() throws GitException
Deprecated.Returns theRepository
used by this git instance.- Specified by:
getRepository
in interfaceGitClient
- Overrides:
getRepository
in classCliGitAPIImpl
- Returns:
- a
Repository
object. - Throws:
GitException
- if underlying git operation fails.
-
tag
public void tag(String tagName, String comment) throws GitException, InterruptedException
Deprecated.Create (or update) a tag. If tag already exist it gets updated (equivalent togit tag --force
)- Specified by:
tag
in interfaceGitClient
- Overrides:
tag
in classCliGitAPIImpl
- Parameters:
tagName
- aString
object.comment
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
fetch
public void fetch(org.eclipse.jgit.transport.URIish url, List<org.eclipse.jgit.transport.RefSpec> refspecs) throws GitException, InterruptedException
Deprecated.Fetch commits from url which match any of the passed in refspecs. Assumesremote.remoteName.url
has been set.- Specified by:
fetch
in interfaceGitClient
- Overrides:
fetch
in classCliGitAPIImpl
- Parameters:
url
- aURIish
object.refspecs
- aList
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
fetch
public void fetch(String remoteName, org.eclipse.jgit.transport.RefSpec... refspec) throws GitException, InterruptedException
Deprecated.fetch.- Specified by:
fetch
in interfaceGitClient
- Overrides:
fetch
in classCliGitAPIImpl
- Parameters:
remoteName
- aString
object.refspec
- aRefSpec
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
fetch
public void fetch(String remoteName, org.eclipse.jgit.transport.RefSpec refspec) throws GitException, InterruptedException
Deprecated.fetch.- Specified by:
fetch
in interfaceGitClient
- Overrides:
fetch
in classCliGitAPIImpl
- Parameters:
remoteName
- aString
object.refspec
- aRefSpec
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
tagExists
public boolean tagExists(String tagName) throws GitException, InterruptedException
Deprecated.tagExists.- Specified by:
tagExists
in interfaceGitClient
- Overrides:
tagExists
in classCliGitAPIImpl
- Parameters:
tagName
- aString
object.- Returns:
- true if tag exists in repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
clean
public void clean() throws GitException, InterruptedException
Deprecated.Remove untracked files and directories, including files listed in the ignore rules.- Specified by:
clean
in interfaceGitClient
- Overrides:
clean
in classCliGitAPIImpl
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
revParse
public org.eclipse.jgit.lib.ObjectId revParse(String revName) throws GitException, InterruptedException
Deprecated.Retrieve commit object that is direct child forrevName
revision reference.- Specified by:
revParse
in interfaceGitClient
- Overrides:
revParse
in classCliGitAPIImpl
- 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.
-
branch
public void branch(String name) throws GitException, InterruptedException
Deprecated.branch.- Specified by:
branch
in interfaceGitClient
- Overrides:
branch
in classCliGitAPIImpl
- Parameters:
name
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
isBareRepository
public boolean isBareRepository() throws GitException, InterruptedException
isBareRepository.- Specified by:
isBareRepository
in interfaceIGitAPI
- Returns:
- true if this repository is a bare repository
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getHostKeyFactory
public HostKeyVerifierFactory getHostKeyFactory()
-
setHostKeyFactory
public void setHostKeyFactory(HostKeyVerifierFactory verifier)
-
hasGitModules
@Deprecated public boolean hasGitModules(String treeIsh) throws GitException
Deprecated.Returns true if this repository has submodules.- Specified by:
hasGitModules
in interfaceIGitAPI
- 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()
-
setupSubmoduleUrls
@Deprecated public void setupSubmoduleUrls(String remote, TaskListener listener) throws GitException, InterruptedException
Deprecated.- Specified by:
setupSubmoduleUrls
in interfaceIGitAPI
- Throws:
GitException
InterruptedException
-
fetch
@Deprecated public void fetch(String repository, String refspec) throws GitException, InterruptedException
Deprecated.Retrieve commits based on refspec from repository.- Specified by:
fetch
in interfaceIGitAPI
- Parameters:
repository
- URL of the repository to be retrievedrefspec
- definition of mapping from remote refs to local refs- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
fetch
@Deprecated public void fetch(org.eclipse.jgit.transport.RemoteConfig remoteRepository) throws InterruptedException
Deprecated.Retrieve commits from RemoteConfig.- Specified by:
fetch
in interfaceIGitAPI
- Parameters:
remoteRepository
- remote configuration from which refs will be retrieved- Throws:
InterruptedException
- if interrupted.
-
fetch
@Deprecated public void fetch() throws GitException, InterruptedException
Deprecated.fetch.- Specified by:
fetch
in interfaceIGitAPI
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
reset
@Deprecated public void reset() throws GitException, InterruptedException
Deprecated.reset.- Specified by:
reset
in interfaceIGitAPI
- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
push
@Deprecated public void push(org.eclipse.jgit.transport.URIish url, String refspec) throws GitException, InterruptedException
Deprecated.push.- Specified by:
push
in interfaceGitClient
- Parameters:
url
- aURIish
object.refspec
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
clone
@Deprecated public void clone(org.eclipse.jgit.transport.RemoteConfig source) throws GitException, InterruptedException
Deprecated.Clone repository from source to this repository.- Specified by:
clone
in interfaceIGitAPI
- Parameters:
source
- remote repository to be cloned- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
clone
@Deprecated public void clone(org.eclipse.jgit.transport.RemoteConfig rc, boolean useShallowClone) throws GitException, InterruptedException
Deprecated.Clone repository fromRemoteConfig
rc to this repository.- Specified by:
clone
in interfaceIGitAPI
- Parameters:
rc
- the remote config for the remote repositoryuseShallowClone
- if true, use a shallow clone- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
revListBranch
@Deprecated public List<org.eclipse.jgit.lib.ObjectId> revListBranch(String branchId) throws GitException, InterruptedException
Deprecated.revListBranch.- Specified by:
revListBranch
in interfaceIGitAPI
- Parameters:
branchId
- aString
object.- Returns:
- a
List
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
showRevision
@Deprecated public List<String> showRevision(Revision r) throws GitException, InterruptedException
Deprecated.showRevision.- Specified by:
showRevision
in interfaceIGitAPI
- Parameters:
r
- aRevision
object.- Returns:
- a
List
object. - Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
getTagsOnCommit
@Deprecated public List<Tag> getTagsOnCommit(String revName) throws GitException, IOException
Deprecated.getTagsOnCommit.- Specified by:
getTagsOnCommit
in interfaceIGitAPI
- Parameters:
revName
- aString
object.- Returns:
- a
List
object. - Throws:
GitException
- if underlying git operation fails.IOException
- if any IO failure
-
lsTree
public final List<IndexEntry> lsTree(String treeIsh) throws GitException, InterruptedException
This method has been implemented as non-recursive historically, but often that is not what the caller wants.- Specified by:
lsTree
in interfaceIGitAPI
- Parameters:
treeIsh
- string representation of a treeIsh item- Returns:
- list of IndexEntry items starting at treeIsh
- Throws:
GitException
- on failureInterruptedException
- if interrupted
-
writeReplace
protected Object writeReplace() throws ObjectStreamException
When sent to remote, switch to the proxy.- Returns:
- a
Object
object. - Throws:
ObjectStreamException
- if current channel is null
-
hasGitModules
public boolean hasGitModules() throws GitException
hasGitModules.- Specified by:
hasGitModules
in interfaceGitClient
- 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 thatto
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 interfaceGitClient
- Parameters:
r
- aObjectId
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 spec normalized main
main*
feature1
feature1*
feature1/main
mainfeature1/main
*origin/main
main*
repo2/feature1
feature1*
refs/heads/feature1
refs/heads/feature1
origin/namespaceA/fix15 fix15namespaceA/fix15
*refs/heads/namespaceA/fix15
refs/heads/namespaceA/fix15
remotes/origin/namespaceA/fix15
refs/heads/namespaceA/fix15
*) TODO: Normalize to "refs/heads/"- Parameters:
branchSpec
- aString
object.- Returns:
- normalized branch name
-
withRepository
public <T> T withRepository(RepositoryCallback<T> callable) throws IOException, InterruptedException
Runs the computation that requires local access toRepository
.- Specified by:
withRepository
in interfaceGitClient
- 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 interrupted
-
setAuthor
public void setAuthor(org.eclipse.jgit.lib.PersonIdent p)
setAuthor.
-
setCommitter
public void setCommitter(org.eclipse.jgit.lib.PersonIdent p)
setCommitter.- Specified by:
setCommitter
in interfaceGitClient
- Parameters:
p
- aPersonIdent
object.
-
changelog
public void changelog(String revFrom, String revTo, OutputStream outputStream) throws GitException, InterruptedException
changelog.- Specified by:
changelog
in interfaceGitClient
- Parameters:
revFrom
- aString
object.revTo
- aString
object.outputStream
- aOutputStream
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
changelog
public void changelog(String revFrom, String revTo, Writer w) throws GitException, InterruptedException
Adds the changelog entries for commits in the range revFrom..revTo. This is just a short cut for callingGitClient.changelog()
with appropriate parameters.- Specified by:
changelog
in interfaceGitClient
- Parameters:
revFrom
- aString
object.revTo
- aString
object.w
- aWriter
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
clone
public void clone(String url, String origin, boolean useShallowClone, String reference) throws GitException, InterruptedException
Clone a remote repository- Specified by:
clone
in interfaceGitClient
- 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.
-
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. 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
GitClient.checkout(String, String)
.- Specified by:
checkoutBranch
in interfaceGitClient
- Parameters:
branch
- aString
object.ref
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
merge
public void merge(org.eclipse.jgit.lib.ObjectId rev) throws GitException, InterruptedException
merge.- Specified by:
merge
in interfaceGitClient
- Parameters:
rev
- aObjectId
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
remoteProxyFor
protected org.jenkinsci.plugins.gitclient.RemoteGitImpl remoteProxyFor(GitClient proxy)
remoteProxyFor.- Parameters:
proxy
- aGitClient
object.- Returns:
- a
RemoteGitImpl
object.
-
setCredentials
public void setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
setCredentials.- Specified by:
setCredentials
in interfaceGitClient
- Parameters:
cred
- aStandardUsernameCredentials
object.
-
setProxy
public void setProxy(ProxyConfiguration proxy)
setProxy.- Specified by:
setProxy
in interfaceGitClient
- Parameters:
proxy
- aProxyConfiguration
object.
-
submoduleUpdate
public void submoduleUpdate(boolean recursive) throws GitException, InterruptedException
Run submodule update optionally recursively on all submodules (equivalent ofgit submodule update --recursive
.)- Specified by:
submoduleUpdate
in interfaceGitClient
- Parameters:
recursive
- a boolean.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
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 ofgit submodule update --recursive --reference 'reference'
.)- Specified by:
submoduleUpdate
in interfaceGitClient
- Parameters:
recursive
- a boolean.reference
- aString
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 ofgit submodule update --recursive --remote
.)- Specified by:
submoduleUpdate
in interfaceGitClient
- 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 ofgit submodule update --recursive --remote --reference 'reference'
.)- Specified by:
submoduleUpdate
in interfaceGitClient
- Parameters:
recursive
- a boolean.remoteTracking
- a boolean.reference
- aString
object.- Throws:
GitException
- if underlying git operation fails.InterruptedException
- if interrupted.
-
-