public class GitClientProxy extends Object
GitClient
. Uses Reflections to
implement version-dependant functions without causing compiler and/or runtime errors.Modifier and Type | Field and Description |
---|---|
static hudson.util.VersionNumber |
MINIMAL_VERSION_NUMBER |
Constructor and Description |
---|
GitClientProxy(hudson.model.AbstractBuild<?,?> build,
hudson.model.BuildListener listener,
boolean dryRun)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String filePattern)
Stage files for commit.
|
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()
Fully revert working copy to a clean state, i.e.
|
void |
commit(String message)
Commit staged files to the local repository.
|
void |
deleteBranch(String name)
Delete a local branch.
|
Set<hudson.plugins.git.Branch> |
getBranches()
Returns the existing local and remote branches.
|
org.eclipse.jgit.lib.ObjectId |
getHeadRev(String branch)
Returns the ref for the head commit of the specified remote branch.
|
List<String> |
getRemoteBranchNamesContaining(String revspec)
Find all the remote branches that include the given commit.
|
void |
merge(org.eclipse.jgit.lib.ObjectId rev,
org.eclipse.jgit.api.MergeCommand.FastForwardMode fastForwardMode,
org.jenkinsci.plugins.gitclient.MergeCommand.Strategy strategy,
GenericMergeCommand.StrategyOption strategyOption,
boolean autoCommit)
Merge the given revision to the current branch using the provided merge settings.
|
void |
push(String remoteAlias,
String refspec)
Push local objects to a remote repository.
|
org.eclipse.jgit.lib.ObjectId |
revParse(String revName)
Retrieve commit object that is direct child for revName revision reference.
|
void |
setGitflowActionName(String gitflowActionName)
Set the name of the Gitflow action.
|
void |
tag(String tagName,
String comment)
Create (or update) a tag.
|
public static final hudson.util.VersionNumber MINIMAL_VERSION_NUMBER
public GitClientProxy(hudson.model.AbstractBuild<?,?> build, hudson.model.BuildListener listener, boolean dryRun) throws IOException, InterruptedException
build
- the build that is in progress.listener
- can be used to send any message.dryRun
- is the build dryRun or not.IOException
- if the version of the Git or the Git Client plugin is not supported.InterruptedException
- if the build is interrupted during execution.public void add(String filePattern) throws InterruptedException
filePattern
- the name/path pattern of the files to be staged.InterruptedException
- if the build is interrupted during execution.public void commit(String message) throws InterruptedException
message
- the commit message.InterruptedException
- if the build is interrupted during execution.public void checkoutBranch(String branch, String ref) throws InterruptedException
The method's Javadoc has been copied from GitClient.checkoutBranch(String, String)
.
branch
- the name of the branch.ref
- the start point for the branch - either a commit ref or a branch.InterruptedException
- if the build is interrupted during execution.GitClient.checkoutBranch(String, String)
public void push(String remoteAlias, String refspec) throws InterruptedException
remoteAlias
- the alias for the remote repository.refspec
- specifies what local source ref to push to what remote target ref.InterruptedException
- if the build is interrupted during execution.public void merge(org.eclipse.jgit.lib.ObjectId rev, org.eclipse.jgit.api.MergeCommand.FastForwardMode fastForwardMode, org.jenkinsci.plugins.gitclient.MergeCommand.Strategy strategy, GenericMergeCommand.StrategyOption strategyOption, boolean autoCommit) throws InterruptedException
rev
- the revision to be merged.fastForwardMode
- the fast forward mode for the merge.strategy
- the merge strategy.strategyOption
- the option for the merge strategy.autoCommit
- sets the merge option --commit
if true
, otherwise sets the merge option --no-commit
.InterruptedException
- if the build is interrupted during execution.public void clean() throws InterruptedException
The method's Javadoc has been copied from GitClient.clean()
.
InterruptedException
- if the build is interrupted during execution.GitClient.clean()
public void deleteBranch(String name) throws InterruptedException
name
- the name of the branch.InterruptedException
- if the build is interrupted during execution.public Set<hudson.plugins.git.Branch> getBranches() throws InterruptedException
InterruptedException
- if the build is interrupted during execution.public void tag(String tagName, String comment) throws InterruptedException
The method's Javadoc has been copied from GitClient.tag(String, String)
.
tagName
- the name of the tag.comment
- the commit message for the tag.InterruptedException
- if the build is interrupted during execution.GitClient.tag(String, String)
public org.eclipse.jgit.lib.ObjectId getHeadRev(String branch) throws InterruptedException
This method fixes/prevents a bug in the GitClient.getHeadRev(String, String)
method: When the branch
is provided with a simple branch name that contains
slashes, the original method might mix up branches. E.g.: When looking for branch
release/1.0
, the head rev of hotfix/1.0
may be returned.
branch
- the name of the branch.null
.InterruptedException
- if the build is interrupted during execution.public org.eclipse.jgit.lib.ObjectId revParse(String revName) throws InterruptedException
revName
- a commit sha1 or tag/branch refnameInterruptedException
- if the build is interrupted during execution.GitClient.revParse(String)
public List<String> getRemoteBranchNamesContaining(String revspec) throws hudson.plugins.git.GitException, InterruptedException
revspec
- commit id to query forhudson.plugins.git.GitException
- on Git exceptionsInterruptedException
- on thread interruptionGitClient.getBranchesContaining(String, boolean)
public void setGitflowActionName(String gitflowActionName)
gitflowActionName
- the name of the Gitflow action.Copyright © 2014–2017 Silpion IT-Solutions GmbH. All rights reserved.