Class GitWorkingCopyManager
java.lang.Object
com.atlassian.bamboo.plugins.git.v2.AbstractGitExecutor
com.atlassian.bamboo.plugins.git.v2.GitWorkingCopyManager
- All Implemented Interfaces:
MergingVcsWorkingCopyManager,NoContextVcsWorkingCopyManager,StatusProvidingVcsWorkingCopyManager,UpdatingVcsWorkingCopyManager,VcsExecutorWithRequirements,VcsWorkingCopyManager
public class GitWorkingCopyManager
extends AbstractGitExecutor
implements MergingVcsWorkingCopyManager, UpdatingVcsWorkingCopyManager, NoContextVcsWorkingCopyManager, StatusProvidingVcsWorkingCopyManager, VcsExecutorWithRequirements
-
Field Summary
Fields inherited from class com.atlassian.bamboo.plugins.git.v2.AbstractGitExecutor
buildDirectoryManager, buildLoggingContext, customVariableContext, DEFAULT_BRANCH, i18nResolver, sshProxyService, trustedKeyHelper -
Constructor Summary
ConstructorsConstructorDescriptionGitWorkingCopyManager(CapabilityContext capabilityContext, CustomVariableContext customVariableContext, BuildDirectoryManager buildDirectoryManager, com.atlassian.sal.api.message.I18nResolver i18nResolver, TrustedKeyHelper trustedKeyHelper, SshProxyService sshProxyService, AgentContext agentContext, BuildLoggerManager buildLoggerManager, VcsBranchIntegrationHelper branchIntegrationHelper, BuildLoggingContext buildLoggingContext, GitConfigurationProvider gitConfigurationProvider) -
Method Summary
Modifier and TypeMethodDescription@NotNull VcsWorkingCopycheckoutAndMerge(@NotNull CommonContext commonContext, @NotNull VcsRepositoryData vcsRepositoryData, @NotNull VcsBranch targetBranch, @NotNull PlanVcsRevisionData revisionOnTarget, @NotNull VcsBranch sourceBranch, @NotNull PlanVcsRevisionData sourceRevision, @NotNull File targetPath) Checks out the targetBranch and merges sourceBranch to it.@NotNull VcsWorkingCopycommitLocal(@NotNull VcsWorkingCopy workingCopy, @NotNull VcsRepositoryData vcsRepositoryData, @NotNull String commitMessage) Create a local commit.@NotNull Set<Requirement> getRequirements(@NotNull VcsRepositoryData vcsRepositoryData) @NotNull VcsWorkingCopygetWorkingCopyInfo(@NotNull VcsRepositoryData repositoryData, @NotNull File checkoutPath) Provide repository working copy information for the given checkout path.@NotNull VcsWorkingCopyretrieveSourceCode(@NotNull CommonContext commonContext, @NotNull VcsRepositoryData repositoryData, @NotNull PlanVcsRevisionData targetRevision, @NotNull File targetPath) Checkout or update a working copy to a revision.voidstageChanges(@NotNull VcsWorkingCopy workingCopy, @NotNull VcsRepositoryData repositoryData, @NotNull Collection<String> pathsToAdd) Stage changes for committing.@NotNull VcsWorkingCopyupdateRemote(@NotNull VcsWorkingCopy workingCopy, @NotNull VcsRepositoryData vcsRepositoryData, @Nullable String commitMessage) Update remote repository.@NotNull VcsWorkingCopyupdateToLatestRevision(@NotNull CommonContext commonContext, @NotNull VcsRepositoryData repositoryData, @NotNull File targetPath) Checkout or update a working copy to the latest revision.@NotNull VcsWorkingCopyupdateToLatestRevision(@NotNull VcsRepositoryData repositoryData, @NotNull File targetPath) Checkout or update a working copy to the latest revision.@NotNull VcsWorkingCopyupdateToLatestRevisionForSpecs(@NotNull VcsRepositoryData repositoryData, @NotNull File targetPath) Checkout or update a working copy to the latest revision.Methods inherited from class com.atlassian.bamboo.plugins.git.v2.AbstractGitExecutor
cacheRootDirectoryExists, fetchCacheWithRetry, fetchWithRetry, getAccessData, getCacheDirectory, getCachePath, getGitCapability, getSshCapability, getSubstitutedAccessData, getSubstitutedAccessDataBuilder, getWorkingDirectory, rethrowOrRemoveDirectory, substituteStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.bamboo.vcs.runtime.MergingVcsWorkingCopyManager
canDoMerge, getMergingRequirements
-
Constructor Details
-
GitWorkingCopyManager
@Inject public GitWorkingCopyManager(CapabilityContext capabilityContext, CustomVariableContext customVariableContext, BuildDirectoryManager buildDirectoryManager, com.atlassian.sal.api.message.I18nResolver i18nResolver, TrustedKeyHelper trustedKeyHelper, SshProxyService sshProxyService, AgentContext agentContext, BuildLoggerManager buildLoggerManager, VcsBranchIntegrationHelper branchIntegrationHelper, BuildLoggingContext buildLoggingContext, GitConfigurationProvider gitConfigurationProvider)
-
-
Method Details
-
getWorkingCopyInfo
@NotNull public @NotNull VcsWorkingCopy getWorkingCopyInfo(@NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull File checkoutPath) throws RepositoryException Description copied from interface:StatusProvidingVcsWorkingCopyManagerProvide repository working copy information for the given checkout path.- Specified by:
getWorkingCopyInfoin interfaceStatusProvidingVcsWorkingCopyManager- Parameters:
repositoryData- configuration of the repositorycheckoutPath- path, where repository was checked out- Returns:
- working copy information
- Throws:
RepositoryException- if any error occurs, or e.g. the path is not a valid checkout path for the repository
-
getRequirements
@NotNull public @NotNull Set<Requirement> getRequirements(@NotNull @NotNull VcsRepositoryData vcsRepositoryData) - Specified by:
getRequirementsin interfaceVcsExecutorWithRequirements
-
retrieveSourceCode
@NotNull public @NotNull VcsWorkingCopy retrieveSourceCode(@NotNull @NotNull CommonContext commonContext, @NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull PlanVcsRevisionData targetRevision, @NotNull @NotNull File targetPath) throws RepositoryException Description copied from interface:VcsWorkingCopyManagerCheckout or update a working copy to a revision.- Specified by:
retrieveSourceCodein interfaceVcsWorkingCopyManager- Parameters:
commonContext- - a current build or deployment contextrepositoryData- - configuration of a repository to check out/updatetargetRevision- - revision to check out or update totargetPath- - workings copy's path. Note that some legacy implementation may ignore this parameter. (seeFixedDirectoryWorkingCopyManager)- Returns:
- object representing created/updated working copy
- Throws:
RepositoryException
-
updateToLatestRevision
@NotNull public @NotNull VcsWorkingCopy updateToLatestRevision(@NotNull @NotNull CommonContext commonContext, @NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull File targetPath) throws RepositoryException Description copied from interface:VcsWorkingCopyManagerCheckout or update a working copy to the latest revision.- Specified by:
updateToLatestRevisionin interfaceVcsWorkingCopyManager- Parameters:
commonContext- - a current build or deployment contextrepositoryData- - configuration of a repository to check out/updatetargetPath- - workings copy's path. Note that some legacy implementation may ignore this parameter. (seeFixedDirectoryWorkingCopyManager)- Returns:
- object representing created/updated working copy
- Throws:
RepositoryException
-
updateToLatestRevision
@NotNull public @NotNull VcsWorkingCopy updateToLatestRevision(@NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull File targetPath) throws RepositoryException Description copied from interface:NoContextVcsWorkingCopyManagerCheckout or update a working copy to the latest revision.- Specified by:
updateToLatestRevisionin interfaceNoContextVcsWorkingCopyManager- Parameters:
repositoryData- - configuration of a repository to checkout/updatetargetPath- - workings copy's path. Note that some legacy implementation may ignore this parameter. (seeFixedDirectoryWorkingCopyManager)- Returns:
- object representing created/updated working copy
- Throws:
RepositoryException
-
updateToLatestRevisionForSpecs
@NotNull public @NotNull VcsWorkingCopy updateToLatestRevisionForSpecs(@NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull File targetPath) throws RepositoryException Description copied from interface:NoContextVcsWorkingCopyManagerCheckout or update a working copy to the latest revision. The method is desired to work with Specs.- Specified by:
updateToLatestRevisionForSpecsin interfaceNoContextVcsWorkingCopyManager- Parameters:
repositoryData- - configuration of a repository to checkout/updatetargetPath- - workings copy's path. Note that some legacy implementation may ignore this parameter. (seeFixedDirectoryWorkingCopyManager)- Returns:
- object representing created/updated working copy
- Throws:
RepositoryException
-
checkoutAndMerge
@NotNull public @NotNull VcsWorkingCopy checkoutAndMerge(@NotNull @NotNull CommonContext commonContext, @NotNull @NotNull VcsRepositoryData vcsRepositoryData, @NotNull @NotNull VcsBranch targetBranch, @NotNull @NotNull PlanVcsRevisionData revisionOnTarget, @NotNull @NotNull VcsBranch sourceBranch, @NotNull @NotNull PlanVcsRevisionData sourceRevision, @NotNull @NotNull File targetPath) throws RepositoryException Description copied from interface:MergingVcsWorkingCopyManagerChecks out the targetBranch and merges sourceBranch to it. Depending on the vcs type, this can create local commit.- Specified by:
checkoutAndMergein interfaceMergingVcsWorkingCopyManager- Parameters:
vcsRepositoryData- configuration of the repository. Note that the following parameters override branch stored in repository data.targetBranch- - target branch (branch to checkout and merge to)revisionOnTarget- - revision to checkout and merge tosourceBranch- - branch to merge fromsourceRevision- - revision to merge fromtargetPath- - workings copy's path- Returns:
- state of the working copy, including new revision if applicable
- Throws:
RepositoryException
-
stageChanges
public void stageChanges(@NotNull @NotNull VcsWorkingCopy workingCopy, @NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull Collection<String> pathsToAdd) throws RepositoryException Description copied from interface:UpdatingVcsWorkingCopyManagerStage changes for committing. If staging is not required or supported by repository, this method should do nothing.Staging logic may differ between repository types.
- Specified by:
stageChangesin interfaceUpdatingVcsWorkingCopyManager- Parameters:
workingCopy- workspace to perform the stagingrepositoryData- configuration of repositorypathsToAdd- paths, relative to working copy directory, to stage for committing; if empty, all modified files from working copy directory should be staged- Throws:
RepositoryException
-
commitLocal
@NotNull public @NotNull VcsWorkingCopy commitLocal(@NotNull @NotNull VcsWorkingCopy workingCopy, @NotNull @NotNull VcsRepositoryData vcsRepositoryData, @NotNull @NotNull String commitMessage) throws RepositoryException Description copied from interface:UpdatingVcsWorkingCopyManagerCreate a local commit. The exact meaning of this operation depends on repository type. In particular, it can be no-op for certain repository types, for example SVN. Intended use: creating a private revision that can be used later in the build.- Specified by:
commitLocalin interfaceUpdatingVcsWorkingCopyManager- Parameters:
workingCopy-vcsRepositoryData-commitMessage-- Returns:
- updated state of local working copy
- Throws:
RepositoryException
-
updateRemote
@NotNull public @NotNull VcsWorkingCopy updateRemote(@NotNull @NotNull VcsWorkingCopy workingCopy, @NotNull @NotNull VcsRepositoryData vcsRepositoryData, @Nullable @Nullable String commitMessage) throws RepositoryException Description copied from interface:UpdatingVcsWorkingCopyManagerUpdate remote repository. The exact meaning of this operation depends on repository type. In DVCS case this should push pre-existing local commit to remote repository. In traditional vcs, like Subversion, this should execute commit operation. Intended use: publishing changes to the world.- Specified by:
updateRemotein interfaceUpdatingVcsWorkingCopyManager- Parameters:
workingCopy-vcsRepositoryData-commitMessage- - implementors are free to ignore this parameter.- Returns:
- updated state of local working copy
- Throws:
RepositoryException
-