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 ProxyConfigurationproxyprotected Fileworkspace-
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 voidadd(String filePattern)Deprecated.add.voidbranch(String name)Deprecated.branch.voidchangelog(String revFrom, String revTo, OutputStream outputStream)changelog.voidchangelog(String revFrom, String revTo, Writer w)Adds the changelog entries for commits in the range revFrom..revTo.voidcheckout(String ref)Deprecated.Checks out the specified commit/tag/branch into the workspace.voidcheckout(String ref, String branch)Deprecated.Creates a new branch that points to the specified ref.voidcheckoutBranch(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 refHEADpoints to branch.voidclean()Deprecated.Remove untracked files and directories, including files listed in the ignore rules.voidclone(String url, String origin, boolean useShallowClone, String reference)Clone a remote repositoryvoidclone(org.eclipse.jgit.transport.RemoteConfig source)Deprecated.voidclone(org.eclipse.jgit.transport.RemoteConfig rc, boolean useShallowClone)Deprecated.voidcommit(String message)Deprecated.commit.voidcommit(String message, org.eclipse.jgit.lib.PersonIdent author, org.eclipse.jgit.lib.PersonIdent committer)Deprecated.commit.voiddeleteBranch(String name)Deprecated.(force) delete a branch.voiddeleteTag(String tagName)Deprecated.deleteTag.protected StringextractBranchNameFromBranchSpec(String branchSpec)This method takes a branch specification and normalizes it get unambiguous results.voidfetch()Deprecated.voidfetch(String repository, String refspec)Deprecated.voidfetch(String remoteName, org.eclipse.jgit.transport.RefSpec refspec)Deprecated.fetch.voidfetch(String remoteName, org.eclipse.jgit.transport.RefSpec... refspec)Deprecated.fetch.voidfetch(org.eclipse.jgit.transport.RemoteConfig remoteRepository)Deprecated.voidfetch(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.HostKeyVerifierFactorygetHostKeyFactory()Set<Branch>getRemoteBranches()Deprecated.Returns the remote branches defined in this repository.StringgetRemoteUrl(String name)Deprecated.From a given repository, get a remote's URLorg.eclipse.jgit.lib.RepositorygetRepository()Deprecated.Returns theRepositoryused by this git instance.StringgetTagMessage(String tagName)Deprecated.getTagMessage.List<Tag>getTagsOnCommit(String revName)Deprecated.booleanhasGitModules()hasGitModules.booleanhasGitModules(String treeIsh)Deprecated.booleanhasGitRepo()Deprecated.Returns true if this workspace has a git repository.booleanhasGitRepo(boolean checkParentDirectories)Deprecated.Returns true if this workspace has a git repository.voidinit()Deprecated.Initialize an empty repository for further git operations.booleanisBareRepository()isBareRepository.booleanisCommitInRepo(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.voidmerge(org.eclipse.jgit.lib.ObjectId rev)merge.voidpush(String remoteName, String refspec)Deprecated.push.voidpush(org.eclipse.jgit.transport.URIish url, String refspec)Deprecated.protected org.jenkinsci.plugins.gitclient.RemoteGitImplremoteProxyFor(GitClient proxy)remoteProxyFor.voidreset()Deprecated.List<org.eclipse.jgit.lib.ObjectId>revListBranch(String branchId)Deprecated.org.eclipse.jgit.lib.ObjectIdrevParse(String revName)Deprecated.Retrieve commit object that is direct child forrevNamerevision reference.voidsetAuthor(org.eclipse.jgit.lib.PersonIdent p)setAuthor.voidsetCommitter(org.eclipse.jgit.lib.PersonIdent p)setCommitter.voidsetCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)setCredentials.voidsetHostKeyFactory(HostKeyVerifierFactory verifier)voidsetProxy(ProxyConfiguration proxy)setProxy.voidsetRemoteUrl(String name, String url)Deprecated.For a given repository, set a remote's URLvoidsetupSubmoduleUrls(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.GitClientsubGit(String subdir)Deprecated.subGit.voidsubmoduleUpdate(boolean recursive)Run submodule update optionally recursively on all submodules (equivalent ofgit submodule update --recursive.)voidsubmoduleUpdate(boolean recursive, boolean remoteTracking)Run submodule update optionally recursively on all submodules, optionally with remoteTracking submodules (equivalent ofgit submodule update --recursive --remote.)voidsubmoduleUpdate(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.voidsubmoduleUpdate(boolean recursive, String reference)Run submodule update optionally recursively on all submodules, with a specific reference passed to git clone if needing to --init.voidtag(String tagName, String comment)Deprecated.Create (or update) a tag.booleantagExists(String tagName)Deprecated.tagExists.<T> TwithRepository(RepositoryCallback<T> callable)Runs the computation that requires local access toRepository.protected ObjectwriteReplace()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- aFilePathfor the repository directorylistener- aTaskListenerwhich monitors the git workenvironment- theEnvVarsenvironment 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- aFilePathfor the repository directorylistener- aTaskListenerwhich monitors the git workenvironment- theEnvVarsenvironment 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- aFilePathfor the repository directorylistener- aTaskListenerwhich monitors the git workenvironment- theEnvVarsenvironment 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:
addin interfaceGitClient- Overrides:
addin classCliGitAPIImpl- Parameters:
filePattern- aStringobject.- 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:
getRemoteUrlin interfaceGitClient- Overrides:
getRemoteUrlin classCliGitAPIImpl- Parameters:
name- The name of the remote (e.g. origin)- Returns:
- a
Stringobject. - 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:
pushin interfaceGitClient- Parameters:
remoteName- aStringobject.refspec- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getTagMessage
public String getTagMessage(String tagName) throws GitException, InterruptedException
Deprecated.getTagMessage.- Specified by:
getTagMessagein interfaceGitClient- Overrides:
getTagMessagein classCliGitAPIImpl- Parameters:
tagName- aStringobject.- Returns:
- a
Stringobject. - Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
subGit
public GitClient subGit(String subdir)
Deprecated.subGit.- Specified by:
subGitin interfaceGitClient- Overrides:
subGitin classCliGitAPIImpl- Parameters:
subdir- aStringobject.- 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:
setRemoteUrlin interfaceGitClient- Overrides:
setRemoteUrlin 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:
getBranchesin interfaceGitClient- Overrides:
getBranchesin classCliGitAPIImpl- Returns:
- a
Setobject. - 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:
getRemoteBranchesin interfaceGitClient- Overrides:
getRemoteBranchesin classCliGitAPIImpl- Returns:
Setof remote branches in this repository- Throws:
GitException- if underlying git operation failsInterruptedException- if interrupted
-
init
public void init() throws GitException, InterruptedExceptionDeprecated.Initialize an empty repository for further git operations.- Specified by:
initin interfaceGitClient- Overrides:
initin 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:
deleteBranchin interfaceGitClient- Overrides:
deleteBranchin classCliGitAPIImpl- Parameters:
name- aStringobject.- 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:
checkoutin interfaceGitClient- Parameters:
ref- A git object references expression. For backward compatibility,nullwill 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, InterruptedExceptionDeprecated.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:
hasGitRepoin interfaceGitClient- Overrides:
hasGitRepoin 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, InterruptedExceptionDeprecated.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:
hasGitRepoin interfaceGitClient- Overrides:
hasGitRepoin 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, InterruptedExceptionDeprecated.isCommitInRepo.- Specified by:
isCommitInRepoin interfaceGitClient- Overrides:
isCommitInRepoin classCliGitAPIImpl- Parameters:
commit- aObjectIdobject.- 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:
commitin interfaceGitClient- Overrides:
commitin classCliGitAPIImpl- Parameters:
message- aStringobject.- 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:
commitin interfaceGitClient- Parameters:
message- aStringobject.author- aPersonIdentobject.committer- aPersonIdentobject.- 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:
checkoutin 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:
deleteTagin interfaceGitClient- Overrides:
deleteTagin classCliGitAPIImpl- Parameters:
tagName- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
getRepository
@NonNull public org.eclipse.jgit.lib.Repository getRepository() throws GitExceptionDeprecated.Returns theRepositoryused by this git instance.- Specified by:
getRepositoryin interfaceGitClient- Overrides:
getRepositoryin classCliGitAPIImpl- Returns:
- a
Repositoryobject. - 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:
tagin interfaceGitClient- Overrides:
tagin classCliGitAPIImpl- Parameters:
tagName- aStringobject.comment- aStringobject.- 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, InterruptedExceptionDeprecated.Fetch commits from url which match any of the passed in refspecs. Assumesremote.remoteName.urlhas been set.- Specified by:
fetchin interfaceGitClient- Overrides:
fetchin classCliGitAPIImpl- Parameters:
url- aURIishobject.refspecs- aListobject.- 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:
fetchin interfaceGitClient- Overrides:
fetchin classCliGitAPIImpl- Parameters:
remoteName- aStringobject.refspec- aRefSpecobject.- 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:
fetchin interfaceGitClient- Overrides:
fetchin classCliGitAPIImpl- Parameters:
remoteName- aStringobject.refspec- aRefSpecobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
tagExists
public boolean tagExists(String tagName) throws GitException, InterruptedException
Deprecated.tagExists.- Specified by:
tagExistsin interfaceGitClient- Overrides:
tagExistsin classCliGitAPIImpl- Parameters:
tagName- aStringobject.- Returns:
- true if tag exists in repository
- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
clean
public void clean() throws GitException, InterruptedExceptionDeprecated.Remove untracked files and directories, including files listed in the ignore rules.- Specified by:
cleanin interfaceGitClient- Overrides:
cleanin 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 forrevNamerevision reference.- Specified by:
revParsein interfaceGitClient- Overrides:
revParsein classCliGitAPIImpl- Parameters:
revName- a commit sha1 or tag/branch refname- Returns:
- a
ObjectIdobject. - 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:
branchin interfaceGitClient- Overrides:
branchin classCliGitAPIImpl- Parameters:
name- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
isBareRepository
public boolean isBareRepository() throws GitException, InterruptedExceptionisBareRepository.- Specified by:
isBareRepositoryin 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:
hasGitModulesin 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:
setupSubmoduleUrlsin interfaceIGitAPI- Throws:
GitExceptionInterruptedException
-
fetch
@Deprecated public void fetch(String repository, String refspec) throws GitException, InterruptedException
Deprecated.Retrieve commits based on refspec from repository.- Specified by:
fetchin 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:
fetchin 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:
fetchin interfaceIGitAPI- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
reset
@Deprecated public void reset() throws GitException, InterruptedException
Deprecated.reset.- Specified by:
resetin 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:
pushin interfaceGitClient- Parameters:
url- aURIishobject.refspec- aStringobject.- 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:
clonein 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 fromRemoteConfigrc to this repository.- Specified by:
clonein 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:
revListBranchin interfaceIGitAPI- Parameters:
branchId- aStringobject.- Returns:
- a
Listobject. - 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:
showRevisionin interfaceIGitAPI- Parameters:
r- aRevisionobject.- Returns:
- a
Listobject. - 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:
getTagsOnCommitin interfaceIGitAPI- Parameters:
revName- aStringobject.- Returns:
- a
Listobject. - 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:
lsTreein 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
Objectobject. - Throws:
ObjectStreamException- if current channel is null
-
hasGitModules
public boolean hasGitModules() throws GitExceptionhasGitModules.- Specified by:
hasGitModulesin 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
fromis null, this prints just one commit thattorepresents.For merge commit, this method reports one diff per each parent. This makes this method behave differently from
GitClient.changelog().- Specified by:
showRevisionin interfaceGitClient- Parameters:
r- aObjectIdobject.- Returns:
- The git whatchanged output, in
rawformat. - 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 mainmain*feature1feature1*feature1/mainmainfeature1/main*origin/mainmain*repo2/feature1feature1*refs/heads/feature1refs/heads/feature1origin/namespaceA/fix15 fix15namespaceA/fix15*refs/heads/namespaceA/fix15refs/heads/namespaceA/fix15remotes/origin/namespaceA/fix15refs/heads/namespaceA/fix15
*) TODO: Normalize to "refs/heads/"- Parameters:
branchSpec- aStringobject.- 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:
withRepositoryin 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:
setCommitterin interfaceGitClient- Parameters:
p- aPersonIdentobject.
-
changelog
public void changelog(String revFrom, String revTo, OutputStream outputStream) throws GitException, InterruptedException
changelog.- Specified by:
changelogin interfaceGitClient- Parameters:
revFrom- aStringobject.revTo- aStringobject.outputStream- aOutputStreamobject.- 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:
changelogin interfaceGitClient- Parameters:
revFrom- aStringobject.revTo- aStringobject.w- aWriterobject.- 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:
clonein interfaceGitClient- Parameters:
url- URL for remote repository to cloneorigin- upstream track name, defaults tooriginby 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
HEADpoints 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. Thecheckoutmethods, 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:
checkoutBranchin interfaceGitClient- Parameters:
branch- aStringobject.ref- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
merge
public void merge(org.eclipse.jgit.lib.ObjectId rev) throws GitException, InterruptedExceptionmerge.- Specified by:
mergein interfaceGitClient- Parameters:
rev- aObjectIdobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
remoteProxyFor
protected org.jenkinsci.plugins.gitclient.RemoteGitImpl remoteProxyFor(GitClient proxy)
remoteProxyFor.- Parameters:
proxy- aGitClientobject.- Returns:
- a
RemoteGitImplobject.
-
setCredentials
public void setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
setCredentials.- Specified by:
setCredentialsin interfaceGitClient- Parameters:
cred- aStandardUsernameCredentialsobject.
-
setProxy
public void setProxy(ProxyConfiguration proxy)
setProxy.- Specified by:
setProxyin interfaceGitClient- Parameters:
proxy- aProxyConfigurationobject.
-
submoduleUpdate
public void submoduleUpdate(boolean recursive) throws GitException, InterruptedExceptionRun submodule update optionally recursively on all submodules (equivalent ofgit submodule update --recursive.)- Specified by:
submoduleUpdatein 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, InterruptedExceptionRun 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:
submoduleUpdatein interfaceGitClient- Parameters:
recursive- a boolean.reference- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
submoduleUpdate
public void submoduleUpdate(boolean recursive, boolean remoteTracking) throws GitException, InterruptedExceptionRun submodule update optionally recursively on all submodules, optionally with remoteTracking submodules (equivalent ofgit submodule update --recursive --remote.)- Specified by:
submoduleUpdatein 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, InterruptedExceptionRun 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:
submoduleUpdatein interfaceGitClient- Parameters:
recursive- a boolean.remoteTracking- a boolean.reference- aStringobject.- Throws:
GitException- if underlying git operation fails.InterruptedException- if interrupted.
-
-