public class CliGitAPIImpl extends Object
Git
| Modifier and Type | Field and Description |
|---|---|
protected hudson.ProxyConfiguration |
proxy |
static int |
TIMEOUT
preventive Time-out for git command execution.
|
static boolean |
USE_SETSID
Constant which can block use of setsid in git calls for ssh credentialed operations.
|
protected File |
workspace |
CREDENTIALS_MATCHER, quietRemoteBranches, verbose| Modifier | Constructor and Description |
|---|---|
protected |
CliGitAPIImpl(String gitExe,
File workspace,
hudson.model.TaskListener listener,
hudson.EnvVars environment)
Constructor for CliGitAPIImpl.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(String filePattern)
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 |
addNote(String note,
String namespace)
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 repository
|
void |
appendNote(String note,
String namespace)
Appends to an existing git-note on the current HEAD commit.
|
void |
branch(String name)
branch.
|
ChangelogCommand |
changelog()
changelog.
|
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.
|
CheckoutCommand |
checkout()
checkout.
|
void |
checkout(String commit)
Checks out the specified commit/tag/branch into the workspace.
|
void |
checkout(String ref,
String branch)
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 ref
HEAD points to branch. |
void |
clean()
Remove untracked files and directories, including files listed
in the ignore rules.
|
void |
clean(boolean cleanSubmodule)
Remove untracked files and directories, including files listed
in the ignore rules.
|
void |
clearCredentials()
clearCredentials.
|
CloneCommand |
clone_()
clone_.
|
void |
clone(RemoteConfig source)
Deprecated.
|
void |
clone(RemoteConfig rc,
boolean useShallowClone)
Deprecated.
|
void |
clone(String url,
String origin,
boolean useShallowClone,
String reference)
Clone a remote repository
|
void |
commit(String message)
commit.
|
void |
commit(String message,
PersonIdent author,
PersonIdent committer)
commit.
|
void |
deleteBranch(String name)
(force) delete a branch.
|
void |
deleteRef(String refName)
Deletes a ref.
|
void |
deleteTag(String tagName)
deleteTag.
|
String |
describe(String commitIsh)
Equivalent of "git-describe --tags".
|
protected String |
extractBranchNameFromBranchSpec(String branchSpec)
This method takes a branch specification and normalizes it get unambiguous results.
|
FetchCommand |
fetch_()
fetch_.
|
void |
fetch()
Deprecated.
|
void |
fetch(RemoteConfig remoteRepository)
Deprecated.
|
void |
fetch(String remoteName,
RefSpec... refspec)
fetch.
|
void |
fetch(String remoteName,
RefSpec refspec)
fetch.
|
void |
fetch(String repository,
String refspec)
Deprecated.
|
void |
fetch(URIish url,
List<RefSpec> refspecs)
Fetch commits from url which match any of the passed in
refspecs.
|
void |
fixSubmoduleUrls(String remote,
hudson.model.TaskListener listener)
fixSubmoduleUrls.
|
String |
getAllLogEntries(String branch)
Deprecated.
|
Set<Branch> |
getBranches()
Returns the set of branches defined in this repository,
including local branches and remote branches.
|
List<Branch> |
getBranchesContaining(String revspec)
Deprecated.
|
List<Branch> |
getBranchesContaining(String revspec,
boolean allBranches)
Find all the branches that include the given commit.
|
String |
getDefaultRemote()
Get the default remote.
|
String |
getDefaultRemote(String _default_)
Returns name of default remote.
|
Map<String,ObjectId> |
getHeadRev(String url)
getHeadRev.
|
ObjectId |
getHeadRev(String url,
String branchSpec)
getHeadRev.
|
Set<String> |
getRefNames(String refPrefix)
List refs with the given prefix.
|
Set<Branch> |
getRemoteBranches()
Returns the remote branches defined in this repository.
|
Map<String,ObjectId> |
getRemoteReferences(String url,
String pattern,
boolean headsOnly,
boolean tagsOnly)
List references in a remote repository.
|
Map<String,String> |
getRemoteSymbolicReferences(String url,
String pattern)
List symbolic references in a remote repository.
|
Set<String> |
getRemoteTagNames(String tagPattern)
getRemoteTagNames.
|
String |
getRemoteUrl(String name)
From a given repository, get a remote's URL
|
String |
getRemoteUrl(String name,
String GIT_DIR)
Returns URL of remote name in repository GIT_DIR.
|
Repository |
getRepository()
Returns the
Repository used by this git instance. |
String |
getSubmodulePath(String name)
Get submodule path.
|
List<IndexEntry> |
getSubmodules(String treeIsh)
Finds all the submodule references in this repository at the specified tree.
|
String |
getSubmoduleUrl(String name)
Returns URL of the named submodule.
|
String |
getTagMessage(String tagName)
getTagMessage.
|
Set<String> |
getTagNames(String tagPattern)
getTagNames.
|
Set<GitObject> |
getTags()
Return name and object ID of all tags in current repository.
|
List<Tag> |
getTagsOnCommit(String revName)
Deprecated.
|
hudson.FilePath |
getWorkTree()
getWorkTree.
|
boolean |
hasGitModules()
hasGitModules.
|
boolean |
hasGitModules(String treeIsh)
Deprecated.
|
boolean |
hasGitRepo()
hasGitRepo.
|
boolean |
hasGitRepo(String GIT_DIR)
Returns true if the parameter GIT_DIR is a directory which
contains a git repository.
|
InitCommand |
init_()
init_.
|
void |
init()
Initialize an empty repository for further git operations.
|
boolean |
isBareRepository()
isBareRepository.
|
boolean |
isBareRepository(String GIT_DIR)
Detect whether a repository at the given path is bare or not.
|
boolean |
isCommitInRepo(ObjectId commit)
isCommitInRepo.
|
boolean |
isShallowRepository()
Returns true if this repository is configured as a shallow clone.
|
String |
launchCommand(hudson.util.ArgumentListBuilder args)
Launch command using the workspace as working directory
|
String |
launchCommand(String... args)
Launch command using the workspace as working directory
|
List<IndexEntry> |
lsTree(String treeIsh)
This method has been implemented as non-recursive historically, but
often that is not what the caller wants.
|
List<IndexEntry> |
lsTree(String treeIsh,
boolean recursive)
lsTree.
|
MergeCommand |
merge()
merge.
|
void |
merge(ObjectId rev)
merge.
|
void |
merge(String refSpec)
Deprecated.
|
ObjectId |
mergeBase(ObjectId id1,
ObjectId id2)
Deprecated.
|
void |
prune(RemoteConfig repository)
Prune stale remote tracking branches with "git remote prune" on the specified remote.
|
PushCommand |
push()
push.
|
void |
push(RemoteConfig repository,
String refspec)
Deprecated.
|
void |
push(String remoteName,
String refspec)
Deprecated.
|
void |
push(URIish url,
String refspec)
Deprecated.
|
RebaseCommand |
rebase()
rebase.
|
void |
ref(String refName)
Create (or update) a ref.
|
boolean |
refExists(String refName)
Check if a ref exists.
|
protected org.jenkinsci.plugins.gitclient.RemoteGitImpl |
remoteProxyFor(GitClient proxy)
remoteProxyFor.
|
void |
reset()
Deprecated.
|
void |
reset(boolean hard)
Reset the contents of the working directory of this
repository.
|
RevListCommand |
revList_()
revList_.
|
List<ObjectId> |
revList(String ref)
revList.
|
List<ObjectId> |
revListAll()
revListAll.
|
List<ObjectId> |
revListBranch(String branchId)
Deprecated.
|
ObjectId |
revParse(String revName)
Retrieve commit object that is direct child for
revName revision reference. |
void |
setAuthor(PersonIdent p)
setAuthor.
|
void |
setAuthor(String name,
String email)
Sets the identity of the author for future commits and merge operations.
|
void |
setCommitter(PersonIdent p)
setCommitter.
|
void |
setCommitter(String name,
String email)
Sets the identity of the committer for future commits and merge operations.
|
void |
setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
setCredentials.
|
void |
setProxy(hudson.ProxyConfiguration proxy)
setProxy.
|
void |
setRemoteUrl(String name,
String url)
For a given repository, set a remote's URL
|
void |
setRemoteUrl(String name,
String url,
String GIT_DIR)
Set remote repository name and URL.
|
void |
setSubmoduleUrl(String name,
String url)
Sets URL of the named submodule.
|
void |
setupSubmoduleUrls(Revision rev,
hudson.model.TaskListener listener)
Set up submodule URLs so that they correspond to the remote pertaining to
the revision that has been checked out.
|
void |
setupSubmoduleUrls(String remote,
hudson.model.TaskListener listener)
Deprecated.
|
List<String> |
showRevision(ObjectId r)
Given a Revision, show it as if it were an entry from git whatchanged, so that it
can be parsed by GitChangeLogParser.
|
List<String> |
showRevision(ObjectId from,
ObjectId to)
Given a Revision, show it as if it were an entry from git whatchanged, so that it
can be parsed by GitChangeLogParser.
|
List<String> |
showRevision(ObjectId from,
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.
|
List<String> |
showRevision(Revision r)
Deprecated.
|
GitClient |
subGit(String subdir)
subGit.
|
void |
submoduleClean(boolean recursive)
submoduleClean.
|
void |
submoduleInit()
submoduleInit.
|
void |
submoduleReset(boolean recursive,
boolean hard)
Reset submodules
|
void |
submoduleSync()
Sync submodule URLs
|
SubmoduleUpdateCommand |
submoduleUpdate()
Update submodules.
|
void |
submoduleUpdate(boolean recursive)
Run submodule update optionally recursively on all submodules
(equivalent of
git submodule update --recursive.) |
void |
submoduleUpdate(boolean recursive,
boolean remoteTracking)
Run submodule update optionally recursively on all submodules, optionally with remoteTracking submodules
(equivalent of
git 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)
Create (or update) a tag.
|
boolean |
tagExists(String tagName)
tagExists.
|
ObjectId |
validateRevision(String revName)
validateRevision.
|
<T> T |
withRepository(RepositoryCallback<T> callable)
Runs the computation that requires local access to
Repository. |
protected Object |
writeReplace()
When sent to remote, switch to the proxy.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitchangelog, checkoutBranchchangelog, checkout, checkout, clone, commit, merge, setAuthor, setCommitter, setCredentials, setProxy, submoduleUpdate, submoduleUpdate, submoduleUpdate, submoduleUpdate, withRepositorypublic static final boolean USE_SETSID
USE_SETSID=Boolean.valueOf(System.getProperty(CliGitAPIImpl.class.getName() + ".useSETSID", "false")).
Allow ssh authenticated git calls on Unix variants to be preceded
by setsid so that the git command is run without being associated
with a terminal. Some docker runtime cases, and some automated test
cases have shown that some versions of command line git or ssh will
not allow automatic answers to private key passphrase prompts
unless there is no controlling terminal associated with the process.public static final int TIMEOUT
We run git as an external process so can't guarantee it won't hang for whatever reason. Even though the plugin does its best to avoid git interactively asking for credentials, there are many of other cases where git may hang.
protected final File workspace
protected hudson.ProxyConfiguration proxy
public GitClient subGit(String subdir)
subdir - a String object.public void init()
throws GitException,
InterruptedException
GitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean hasGitRepo()
throws GitException,
InterruptedException
GitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean hasGitRepo(String GIT_DIR) throws GitException
GIT_DIR - a String object.GitException - if underlying git operation fails.public List<IndexEntry> getSubmodules(String treeIsh) throws GitException, InterruptedException
treeIsh - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public FetchCommand fetch_()
FetchCommand object.public void fetch(URIish url, List<RefSpec> refspecs) throws GitException, InterruptedException
remote.remoteName.url has been set.url - a URIish object.refspecs - a List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void fetch(String remoteName, RefSpec... refspec) throws GitException, InterruptedException
remoteName - a String object.refspec - a RefSpec object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void fetch(String remoteName, RefSpec refspec) throws GitException, InterruptedException
remoteName - a String object.refspec - a RefSpec object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void reset(boolean hard)
throws GitException,
InterruptedException
hard - reset as though "--hard" were passed to "git reset"GitException - if underlying git operation fails.InterruptedException - if interrupted.public CloneCommand clone_()
CloneCommand object.public MergeCommand merge()
MergeCommand object.public RebaseCommand rebase()
RebaseCommand object.public InitCommand init_()
InitCommand object.public void clean(boolean cleanSubmodule)
throws GitException,
InterruptedException
cleanSubmodule - flag to add extra -fGitException - if underlying git operation fails.InterruptedException - if interrupted.public void clean()
throws GitException,
InterruptedException
GitException - if underlying git operation fails.InterruptedException - if interrupted.public ObjectId revParse(String revName) throws GitException, InterruptedException
revName revision reference.revName - a commit sha1 or tag/branch refnameObjectId object.GitException - when no such commit / revName is found in repository.InterruptedException - if interrupted.public ObjectId validateRevision(String revName) throws GitException, InterruptedException
revName - a String object.ObjectId object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public String describe(String commitIsh) throws GitException, InterruptedException
commitIsh - a String object.String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void prune(RemoteConfig repository) throws GitException, InterruptedException
repository - a RemoteConfig object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public ChangelogCommand changelog()
ChangelogCommand object.public List<String> showRevision(ObjectId from, ObjectId to) throws GitException, InterruptedException
Changes are computed on the [from..to] range. If from is null, this prints
just one commit that to represents.
For merge commit, this method reports one diff per each parent. This makes this method
behave differently from GitClient.changelog().
from - a ObjectId object.to - a ObjectId object.raw format.GitException - if underlying git operation fails.InterruptedException - if interrupted.public List<String> showRevision(ObjectId from, ObjectId to, Boolean useRawOutput) throws GitException, InterruptedException
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 that to represents.
For merge commit, this method reports one diff per each parent. This makes this method
behave differently from GitClient.changelog().
from - a ObjectId object.to - a ObjectId object.useRawOutput - a {java.lang.Boolean} object.raw format.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleInit()
throws GitException,
InterruptedException
GitException - if underlying git operation fails.InterruptedException - if interrupted.public void addSubmodule(String remoteURL, String subdir) throws GitException, InterruptedException
remoteURL - a String object.subdir - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleSync()
throws GitException,
InterruptedException
GitException - if underlying git operation fails.InterruptedException - if interrupted.public SubmoduleUpdateCommand submoduleUpdate()
SubmoduleUpdateCommand object.public void submoduleReset(boolean recursive,
boolean hard)
throws GitException,
InterruptedException
recursive - if true, will recursively reset submodules (requres git>=1.6.5)hard - if true, the --hard argument will be passed to submodule resetGitException - if executing the git command failsInterruptedException - if git command interruptedpublic void submoduleClean(boolean recursive)
throws GitException,
InterruptedException
recursive - a boolean.GitException - if underlying git operation fails.InterruptedException - if interrupted.@CheckForNull public String getSubmoduleUrl(String name) throws GitException, InterruptedException
name - submodule name whose URL will be returnedGitException - if underlying git operation fails.InterruptedException - if interrupted.public void setSubmoduleUrl(String name, String url) throws GitException, InterruptedException
name - submodule name whose URL will be seturl - URL for the named submoduleGitException - if underlying git operation fails.InterruptedException - if interrupted.@CheckForNull public String getSubmodulePath(String name) throws GitException, InterruptedException
name - submodule name whose path is returnedGitException - on git errorInterruptedException - if interrupted@CheckForNull public String getRemoteUrl(String name) throws GitException, InterruptedException
name - The name of the remote (e.g. origin)String object.GitException - if executing the git command failsInterruptedException - if interrupted.public void setRemoteUrl(String name, String url) throws GitException, InterruptedException
name - The name of the remote (e.g. origin)url - The new value of the remote's URLGitException - if executing the git command failsInterruptedException - if interrupted.public void addRemoteUrl(String name, String url) throws GitException, InterruptedException
name - a String object.url - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public String getRemoteUrl(String name, String GIT_DIR) throws GitException, InterruptedException
name - name for the remote repository, for examnple, "origin"GIT_DIR - directory containing git repositoryGitException - if underlying git operation fails.InterruptedException - if interrupted.public void setRemoteUrl(String name, String url, String GIT_DIR) throws GitException, InterruptedException
name - name for the remote repository, for examnple, "origin"url - URL for the remote repository, for example git://github.com/jenkinsci/git-client-plugin.gitGIT_DIR - directory containing git repositoryGitException - if underlying git operation fails.InterruptedException - if interrupted.public String getDefaultRemote(String _default_) throws GitException, InterruptedException
_default_ - value to return if no remote is defined in this repositoryGitException - if underlying git operation fails.InterruptedException - if interrupted.public String getDefaultRemote() throws GitException, InterruptedException
GitException - if executing the git command failsInterruptedException - if interruptedpublic boolean isBareRepository(String GIT_DIR) throws GitException, InterruptedException
GIT_DIR - The path to the repository (must be to .git dir).GitException - on failureInterruptedException - if interruptedpublic boolean isShallowRepository()
public void fixSubmoduleUrls(String remote, hudson.model.TaskListener listener) throws GitException, InterruptedException
remote - a String object.listener - a TaskListener object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void setupSubmoduleUrls(Revision rev, hudson.model.TaskListener listener) throws GitException, InterruptedException
rev - a Revision object.listener - a TaskListener object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void tag(String tagName, String comment) throws GitException, InterruptedException
git tag --force)tagName - a String object.comment - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void appendNote(String note, String namespace) throws GitException, InterruptedException
GitClient.addNote(String, String)note - Content of the note.namespace - If unqualified, interpreted as "refs/notes/NAMESPACE" just like cgit.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void addNote(String note, String namespace) throws GitException, InterruptedException
note - Content of the note.namespace - If unqualified, interpreted as "refs/notes/NAMESPACE" just like cgit.GitException - if underlying git operation fails.InterruptedException - if interrupted.public String launchCommand(hudson.util.ArgumentListBuilder args) throws GitException, InterruptedException
args - arguments to the commandGitException - if launched command failsInterruptedException - if interruptedpublic String launchCommand(String... args) throws GitException, InterruptedException
args - command argumnentsGitException - on failureInterruptedException - if interruptedpublic PushCommand push()
PushCommand object.public Set<Branch> getBranches() throws GitException, InterruptedException
Set object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public Set<Branch> getRemoteBranches() throws GitException, InterruptedException
Set of remote branches in this repositoryGitException - if underlying git operation failsInterruptedException - if interruptedpublic CheckoutCommand checkout()
CheckoutCommand object.public boolean tagExists(String tagName) throws GitException, InterruptedException
tagName - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void deleteBranch(String name) throws GitException, InterruptedException
name - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void deleteTag(String tagName) throws GitException, InterruptedException
tagName - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public List<IndexEntry> lsTree(String treeIsh, boolean recursive) throws GitException, InterruptedException
treeIsh - a String object.recursive - a boolean.List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public RevListCommand revList_()
RevListCommand object.public List<ObjectId> revListAll() throws GitException, InterruptedException
List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public List<ObjectId> revList(String ref) throws GitException, InterruptedException
ref - a String object.List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean isCommitInRepo(ObjectId commit) throws InterruptedException
commit - a ObjectId object.InterruptedException - if interrupted.public void add(String filePattern) throws GitException, InterruptedException
filePattern - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void branch(String name) throws GitException, InterruptedException
name - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void commit(String message) throws GitException, InterruptedException
message - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void addCredentials(String url, com.cloudbees.plugins.credentials.common.StandardCredentials credentials)
url - the url for the credentials to be used against.credentials - the credentials to use.public void clearCredentials()
public void addDefaultCredentials(com.cloudbees.plugins.credentials.common.StandardCredentials credentials)
credentials - the credentials to use.GitClient.addCredentials(String, com.cloudbees.plugins.credentials.common.StandardCredentials)public void setAuthor(String name, String email) throws GitException
name - a String object.email - a String object.GitException - if underlying git operation fails.public void setCommitter(String name, String email) throws GitException
name - a String object.email - a String object.GitException - if underlying git operation fails.@NonNull public Repository getRepository() throws GitException
Repository used by this git instance.Repository object.GitException - if underlying git operation fails.public hudson.FilePath getWorkTree()
FilePath object.public Set<String> getRemoteTagNames(String tagPattern) throws GitException
tagPattern - a String object.Set object.GitException - if underlying git operation fails.public Set<String> getTagNames(String tagPattern) throws GitException
tagPattern - a String object.Set object.GitException - if underlying git operation fails.public String getTagMessage(String tagName) throws GitException, InterruptedException
tagName - a String object.String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void ref(String refName) throws GitException, InterruptedException
git update-ref ... HEAD).refName - the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.GitException - if underlying git operation fails.InterruptedException - if interrupted.public boolean refExists(String refName) throws GitException, InterruptedException
git show-ref to zero.refName - the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void deleteRef(String refName) throws GitException, InterruptedException
git update-ref -d.refName - the full name of the ref (e.g. "refs/myref"). Spaces will be replaced with underscores.GitException - if underlying git operation fails.InterruptedException - if interrupted.public Set<String> getRefNames(String refPrefix) throws GitException, InterruptedException
git for-each-ref --format="%(refname)".refPrefix - the literal prefix any ref returned will have. The empty string implies all.GitException - if underlying git operation fails.InterruptedException - if interrupted.public Map<String,ObjectId> getHeadRev(String url) throws GitException, InterruptedException
url - a String object.Map object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public ObjectId getHeadRev(String url, String branchSpec) throws GitException, InterruptedException
url - a String object.branchSpec - a String object.ObjectId object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public Map<String,ObjectId> getRemoteReferences(String url, String pattern, boolean headsOnly, boolean tagsOnly) throws GitException, InterruptedException
git ls-remote [--heads] [--tags] <repository> [<refs>].url - 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.GitException - if underlying git operation fails.InterruptedException - if interrupted.public Map<String,String> getRemoteSymbolicReferences(String url, String pattern) throws GitException, InterruptedException
GitClientgit ls-remote --symref <repository>
[<refs>]. Note: the response may be empty for multiple reasonsurl - Remote repository URL.pattern - Only references matching the given pattern are displayed.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void merge(String refSpec) throws GitException, InterruptedException
refSpec - the revision specification to be merged (for example, origin/master)GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void push(RemoteConfig repository, String refspec) throws GitException, InterruptedException
repository - git repository to receive commitsrefspec - commits to be pushedGitException - if underlying git operating failsInterruptedException - if interrupted@Deprecated public List<Branch> getBranchesContaining(String revspec) throws GitException, InterruptedException
revspec - substring to be searched for branch nameGitException - on failureInterruptedException - if interruptedpublic List<Branch> getBranchesContaining(String revspec, boolean allBranches) throws GitException, InterruptedException
revspec - commit id to query forallBranches - whether remote branches should be also queried (true) or not (false)GitException - on Git exceptionsInterruptedException - on thread interruption@Deprecated public ObjectId mergeBase(ObjectId id1, ObjectId id2) throws InterruptedException
id1 - a ObjectId object.id2 - a ObjectId object.ObjectId object.InterruptedException - if interrupted.@Deprecated public String getAllLogEntries(String branch) throws InterruptedException
branch - a String object.String object.InterruptedException - if interrupted.public Set<GitObject> getTags() throws GitException, InterruptedException
GitException - on Git exceptionsInterruptedException - on thread interruptionpublic boolean isBareRepository()
throws GitException,
InterruptedException
isBareRepository in interface IGitAPIGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public boolean hasGitModules(String treeIsh) throws GitException
hasGitModules in interface IGitAPItreeIsh - an ignored argument, kept for compatibilityGitException - if underlying git operation fails.GitClient.hasGitModules()@Deprecated public void setupSubmoduleUrls(String remote, hudson.model.TaskListener listener) throws GitException, InterruptedException
setupSubmoduleUrls in interface IGitAPIGitExceptionInterruptedException@Deprecated public void fetch(String repository, String refspec) throws GitException, InterruptedException
fetch in interface IGitAPIrepository - URL of the repository to be retrievedrefspec - definition of mapping from remote refs to local refsGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void fetch(RemoteConfig remoteRepository) throws InterruptedException
fetch in interface IGitAPIremoteRepository - remote configuration from which refs will be retrievedInterruptedException - if interrupted.@Deprecated public void fetch() throws GitException, InterruptedException
fetch in interface IGitAPIGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void reset() throws GitException, InterruptedException
reset in interface IGitAPIGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void push(URIish url, String refspec) throws GitException, InterruptedException
push in interface GitClienturl - a URIish object.refspec - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void push(String remoteName, String refspec) throws GitException, InterruptedException
push in interface GitClientremoteName - a String object.refspec - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void clone(RemoteConfig source) throws GitException, InterruptedException
clone in interface IGitAPIsource - remote repository to be clonedGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public void clone(RemoteConfig rc, boolean useShallowClone) throws GitException, InterruptedException
RemoteConfig rc to this repository.clone in interface IGitAPIrc - the remote config for the remote repositoryuseShallowClone - if true, use a shallow cloneGitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public List<ObjectId> revListBranch(String branchId) throws GitException, InterruptedException
revListBranch in interface IGitAPIbranchId - a String object.List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public List<String> showRevision(Revision r) throws GitException, InterruptedException
showRevision in interface IGitAPIr - a Revision object.List object.GitException - if underlying git operation fails.InterruptedException - if interrupted.@Deprecated public List<Tag> getTagsOnCommit(String revName) throws GitException, IOException
getTagsOnCommit in interface IGitAPIrevName - a String object.List object.GitException - if underlying git operation fails.IOException - if any IO failurepublic final List<IndexEntry> lsTree(String treeIsh) throws GitException, InterruptedException
lsTree in interface IGitAPItreeIsh - string representation of a treeIsh itemGitException - on failureInterruptedException - if interruptedprotected Object writeReplace() throws ObjectStreamException
Object object.ObjectStreamException - if current channel is nullpublic boolean hasGitModules()
throws GitException
hasGitModules in interface GitClientGitException - if underlying git operation fails.public List<String> showRevision(ObjectId r) throws GitException, InterruptedException
Changes are computed on the [from..to] range. If from is null, this prints
just one commit that to represents.
For merge commit, this method reports one diff per each parent. This makes this method
behave differently from GitClient.changelog().
showRevision in interface GitClientr - a ObjectId object.raw format.GitException - if underlying git operation fails.InterruptedException - if interrupted.protected String extractBranchNameFromBranchSpec(String branchSpec)
| branch spec | normalized | |
|---|---|---|
master | master* | |
feature1 | feature1* | |
feature1/master | master feature1/master* | |
origin/master | master* | |
repo2/feature1 | feature1* | |
refs/heads/feature1 | refs/heads/feature1 | |
| origin/namespaceA/fix15 | fix15 namespaceA/fix15* | |
refs/heads/namespaceA/fix15 | refs/heads/namespaceA/fix15 | |
remotes/origin/namespaceA/fix15 | refs/heads/namespaceA/fix15 |
branchSpec - a String object.public <T> T withRepository(RepositoryCallback<T> callable) throws IOException, InterruptedException
Repository.withRepository in interface GitClientT - type for the repository callbackcallable - the repository callback used as closure to instanceIOException - in case of IO errorInterruptedException - if interruptedpublic void commit(String message, PersonIdent author, PersonIdent committer) throws GitException, InterruptedException
commit in interface GitClientmessage - a String object.author - a PersonIdent object.committer - a PersonIdent object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void setAuthor(PersonIdent p)
setAuthor in interface GitClientp - a PersonIdent object.public void setCommitter(PersonIdent p)
setCommitter in interface GitClientp - a PersonIdent object.public void changelog(String revFrom, String revTo, OutputStream outputStream) throws GitException, InterruptedException
changelog in interface GitClientrevFrom - a String object.revTo - a String object.outputStream - a OutputStream object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void changelog(String revFrom, String revTo, Writer w) throws GitException, InterruptedException
GitClient.changelog() with appropriate parameters.changelog in interface GitClientrevFrom - a String object.revTo - a String object.w - a Writer object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void clone(String url, String origin, boolean useShallowClone, String reference) throws GitException, InterruptedException
clone in interface GitClienturl - URL for remote repository to cloneorigin - upstream track name, defaults to origin 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)GitException - if underlying git operation fails.InterruptedException - if interrupted.public void checkout(String commit) throws GitException, InterruptedException
git checkout branch.)checkout in interface GitClientcommit - A git object references expression (either a sha1, tag or branch)GitException - if underlying git operation fails.InterruptedException - if interrupted.public void checkout(String ref, String branch) throws GitException, InterruptedException
checkout in interface GitClientref - A git object references expression. For backward compatibility, null will checkout current HEADbranch - name of the branch to create from referenceGitException - if underlying git operation fails.InterruptedException - if interrupted.public void checkoutBranch(String branch, String ref) throws GitException, InterruptedException
HEAD points to branch. In other words, the workspace is on the specified branch.
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. The checkout
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).
checkoutBranch in interface GitClientbranch - a String object.ref - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void merge(ObjectId rev) throws GitException, InterruptedException
merge in interface GitClientrev - a ObjectId object.GitException - if underlying git operation fails.InterruptedException - if interrupted.protected org.jenkinsci.plugins.gitclient.RemoteGitImpl remoteProxyFor(GitClient proxy)
proxy - a GitClient object.RemoteGitImpl object.public void setCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials cred)
setCredentials in interface GitClientcred - a StandardUsernameCredentials object.public void setProxy(hudson.ProxyConfiguration proxy)
public void submoduleUpdate(boolean recursive)
throws GitException,
InterruptedException
git submodule update --recursive.)submoduleUpdate in interface GitClientrecursive - a boolean.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleUpdate(boolean recursive,
String reference)
throws GitException,
InterruptedException
git submodule update --recursive --reference 'reference'.)submoduleUpdate in interface GitClientrecursive - a boolean.reference - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleUpdate(boolean recursive,
boolean remoteTracking)
throws GitException,
InterruptedException
git submodule update --recursive --remote.)submoduleUpdate in interface GitClientrecursive - a boolean.remoteTracking - a boolean.GitException - if underlying git operation fails.InterruptedException - if interrupted.public void submoduleUpdate(boolean recursive,
boolean remoteTracking,
String reference)
throws GitException,
InterruptedException
git submodule update --recursive --remote --reference 'reference'.)submoduleUpdate in interface GitClientrecursive - a boolean.remoteTracking - a boolean.reference - a String object.GitException - if underlying git operation fails.InterruptedException - if interrupted.Copyright © 2013–2020. All rights reserved.