Package com.atlassian.bamboo.plugins.git
Class NativeGitOperationHelper
java.lang.Object
com.atlassian.bamboo.plugins.git.AbstractGitOperationHelper
com.atlassian.bamboo.plugins.git.NativeGitOperationHelper
- All Implemented Interfaces:
GitOperationHelper
public class NativeGitOperationHelper
extends AbstractGitOperationHelper
implements GitOperationHelper
-
Field Summary
Fields inherited from class com.atlassian.bamboo.plugins.git.AbstractGitOperationHelper
accessData, buildLogger, CHANGESET_LIMIT, DEFAULT_TRANSFER_TIMEOUT, FQREF_PREFIXES, i18nResolver, trustedKeyHelper
-
Constructor Summary
ConstructorDescriptionNativeGitOperationHelper
(@NotNull GitRepository repository, @NotNull GitRepositoryAccessData accessData, @NotNull SshProxyService sshProxyService, @NotNull BuildLogger buildLogger, @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull TrustedKeyHelper trustedKeyHelper) NativeGitOperationHelper
(@NotNull AbstractGitExecutor repository, @NotNull GitRepositoryAccessData accessData, @NotNull SshProxyService sshProxyService, @NotNull BuildLogger buildLogger, @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull TrustedKeyHelper trustedKeyHelper) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterRepositoryAccess
(@NotNull GitRepositoryAccessData accessData) protected GitRepositoryAccessData
beforeRepositoryAccess
(@NotNull GitRepositoryAccessData accessData) Wrap with proxy if needed.@NotNull String
checkout
(@Nullable File cacheDirectory, @NotNull File sourceDirectory, @NotNull String targetRevision, @Nullable String previousRevision) @NotNull String
checkout
(@Nullable File cacheDirectory, @NotNull File sourceDirectory, @NotNull String targetRevision, @Nullable String ignored, boolean fetchLfsFiles) boolean
checkRevisionExistsInCacheRepository
(@NotNull File repositoryDirectory, @NotNull String targetRevision) protected void
closeProxy
(@NotNull GitRepositoryAccessData accessData) @NotNull String
commit
(@NotNull File sourceDirectory, @NotNull String message, @NotNull String committerName, @NotNull String committerEmail, boolean stageModifications) void
createBranch
(@NotNull File sourceDirectory, @NotNull String branchName) static @NotNull File
createCredentialsFile
(String repositoryUrlWithPassword) void
createLightweightTag
(@NotNull File sourceDirectory, @NotNull String tagName, @NotNull String revision) extractCommits
(File cacheDirectory, @NotNull String startingRevision, String endingRevision) extractCommits
(File cacheDirectory, @NotNull String startingRevision, String endingRevision, @Nullable String path) extractCommitsBetweenBranches
(File cacheDirectory, VcsBranch otherBranch, boolean limitChangeList) void
fetch
(@NotNull File sourceDirectory, @NotNull HashAndSource hashAndSource, boolean useShallow) void
fetch
(@NotNull File sourceDirectory, @NotNull HashAndSource hashAndSource, boolean useShallow, boolean fetchTagsByDefault) void
fetch
(@NotNull File sourceDirectory, @NotNull HashAndSource hashAndSource, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) void
void
fetch
(@NotNull File sourceDirectory, @NotNull String targetBranchOrRevision, boolean useShallow, boolean fetchTagsByDefault) void
fetch
(@NotNull File sourceDirectory, @NotNull String targetBranchOrRevision, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) getBranchForSha
(@NotNull File sourceDirectory, String revision, String configuredBranch) @NotNull CommitContext
Gets the commit for the revision, given a working directory.getCurrentBranch
(@NotNull File checkoutPath) @NotNull String
getCurrentRevision
(@NotNull File sourceDirectory) getOpenBranches
(@NotNull GitRepositoryAccessData repositoryData, File workingDir) @Nullable String
getShaOfRefIfExists
(@NotNull File sourceDirectory, @NotNull String ref) getTagsForRepository
(@NotNull GitRepositoryAccessData accessData) identificationVariables
(@NotNull String name, @NotNull String email) boolean
isAncestor
(@NotNull Path gitWorkspace, @NotNull GitHash rev1, @NotNull GitHash rev2) Returns true if you can reach rev1 by following parent relationship starting from rev2.boolean
boolean
merge
(@NotNull File workspaceDir, @NotNull String targetRevision, @NotNull String committerName, @NotNull String committerEmail) mergeAndReturnHead
(@NotNull File workspaceDir, @NotNull String currentRevision, @NotNull String targetRevision, @NotNull String committerName, @NotNull String committerEmail) @NotNull HashAndSource
obtainLatestRevision
(@NotNull File repositoryDirectory, GitRef ref, String path) void
pushBranchOrTag
(@NotNull File sourceDirectory, @NotNull String refName) void
pushRevision
(@NotNull File sourceDirectory, @NotNull String revision, @Nullable String currentBranch) void
stageChanges
(@NotNull File sourceDirectory, @NotNull Collection<String> filePaths) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.bamboo.plugins.git.GitOperationHelper
commit
-
Field Details
-
ALL_REFS
-
sshProxyService
-
-
Constructor Details
-
NativeGitOperationHelper
public NativeGitOperationHelper(@NotNull @NotNull GitRepository repository, @NotNull @NotNull GitRepositoryAccessData accessData, @NotNull @NotNull SshProxyService sshProxyService, @NotNull @NotNull BuildLogger buildLogger, @NotNull @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull @NotNull TrustedKeyHelper trustedKeyHelper) throws RepositoryException - Throws:
RepositoryException
-
NativeGitOperationHelper
public NativeGitOperationHelper(@NotNull @NotNull AbstractGitExecutor repository, @NotNull @NotNull GitRepositoryAccessData accessData, @NotNull @NotNull SshProxyService sshProxyService, @NotNull @NotNull BuildLogger buildLogger, @NotNull @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull @NotNull TrustedKeyHelper trustedKeyHelper) throws RepositoryException - Throws:
RepositoryException
-
-
Method Details
-
pushRevision
public void pushRevision(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String revision, @Nullable @Nullable String currentBranch) throws RepositoryException - Specified by:
pushRevision
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
pushBranchOrTag
public void pushBranchOrTag(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String refName) throws RepositoryException - Specified by:
pushBranchOrTag
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
commit
@NotNull public @NotNull String commit(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String message, @NotNull @NotNull String committerName, @NotNull @NotNull String committerEmail, boolean stageModifications) throws RepositoryException - Specified by:
commit
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
stageChanges
public void stageChanges(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull Collection<String> filePaths) throws RepositoryException - Specified by:
stageChanges
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
identificationVariables
-
beforeRepositoryAccess
protected GitRepositoryAccessData beforeRepositoryAccess(@NotNull @NotNull GitRepositoryAccessData accessData) throws RepositoryException Wrap with proxy if needed. Hide password for https within file.- Throws:
RepositoryException
-
createCredentialsFile
@NotNull public static @NotNull File createCredentialsFile(String repositoryUrlWithPassword) throws IOException - Throws:
IOException
-
afterRepositoryAccess
protected void afterRepositoryAccess(@NotNull @NotNull GitRepositoryAccessData accessData) throws RepositoryException - Throws:
RepositoryException
-
merge
public boolean merge(@NotNull @NotNull File workspaceDir, @NotNull @NotNull String targetRevision, @NotNull @NotNull String committerName, @NotNull @NotNull String committerEmail) throws RepositoryException - Specified by:
merge
in interfaceGitOperationHelper
- Returns:
- true if modified files exist in the directory or current revision in the directory has changed
- Throws:
RepositoryException
-
mergeAndReturnHead
public Pair<Boolean,String> mergeAndReturnHead(@NotNull @NotNull File workspaceDir, @NotNull @NotNull String currentRevision, @NotNull @NotNull String targetRevision, @NotNull @NotNull String committerName, @NotNull @NotNull String committerEmail) throws RepositoryException - Specified by:
mergeAndReturnHead
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
closeProxy
-
checkout
@NotNull public @NotNull String checkout(@Nullable @Nullable File cacheDirectory, @NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, @Nullable @Nullable String ignored, boolean fetchLfsFiles) throws RepositoryException - Specified by:
checkout
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
checkout
@NotNull public @NotNull String checkout(@Nullable @Nullable File cacheDirectory, @NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, @Nullable @Nullable String previousRevision) throws RepositoryException - Specified by:
checkout
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetBranchOrRevision, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException - Specified by:
fetch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetBranchOrRevision, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) throws RepositoryException - Specified by:
fetch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetBranchOrRevision, boolean useShallow) throws RepositoryException - Specified by:
fetch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource hashAndSource, boolean useShallow) throws RepositoryException - Specified by:
fetch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource hashAndSource, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException - Specified by:
fetch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource hashAndSource, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) throws RepositoryException - Specified by:
fetch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
getOpenBranches
@NotNull public @NotNull List<VcsBranch> getOpenBranches(@NotNull @NotNull GitRepositoryAccessData repositoryData, File workingDir) throws RepositoryException - Specified by:
getOpenBranches
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
getBranchForSha
@NotNull public @NotNull Optional<String> getBranchForSha(@NotNull @NotNull File sourceDirectory, String revision, String configuredBranch) throws RepositoryException - Specified by:
getBranchForSha
in interfaceGitOperationHelper
- Returns:
- branch that contains sha and matches the name of configuredBranch
- Throws:
RepositoryException
-
obtainLatestRevision
public Optional<GitHash> obtainLatestRevision(@NotNull @NotNull File repositoryDirectory, GitRef ref, String path) throws RepositoryException - Specified by:
obtainLatestRevision
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
isAncestor
public boolean isAncestor(@NotNull @NotNull Path gitWorkspace, @NotNull @NotNull GitHash rev1, @NotNull @NotNull GitHash rev2) throws RepositoryException Description copied from interface:GitOperationHelper
Returns true if you can reach rev1 by following parent relationship starting from rev2.- Specified by:
isAncestor
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
getCurrentRevision
@NotNull public @NotNull String getCurrentRevision(@NotNull @NotNull File sourceDirectory) throws RepositoryException - Specified by:
getCurrentRevision
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
getCurrentBranch
- Specified by:
getCurrentBranch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
getTagsForRepository
public List<TagAndRevision> getTagsForRepository(@NotNull @NotNull GitRepositoryAccessData accessData) throws RepositoryException - Specified by:
getTagsForRepository
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
isClean
- Specified by:
isClean
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
getShaOfRefIfExists
@Nullable public @Nullable String getShaOfRefIfExists(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String ref) - Specified by:
getShaOfRefIfExists
in interfaceGitOperationHelper
-
obtainLatestRevision
- Specified by:
obtainLatestRevision
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
checkRevisionExistsInCacheRepository
public boolean checkRevisionExistsInCacheRepository(@NotNull @NotNull File repositoryDirectory, @NotNull @NotNull String targetRevision) throws RepositoryException - Specified by:
checkRevisionExistsInCacheRepository
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
getCommit
@NotNull public @NotNull CommitContext getCommit(File directory, String targetRevision) throws RepositoryException Description copied from interface:GitOperationHelper
Gets the commit for the revision, given a working directory.- Specified by:
getCommit
in interfaceGitOperationHelper
- Throws:
RepositoryException
- if the revision can't be found
-
extractCommits
public BuildRepositoryChanges extractCommits(File cacheDirectory, @NotNull @NotNull String startingRevision, String endingRevision) throws RepositoryException - Specified by:
extractCommits
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
extractCommits
public BuildRepositoryChanges extractCommits(File cacheDirectory, @NotNull @NotNull String startingRevision, String endingRevision, @Nullable @Nullable String path) throws RepositoryException - Specified by:
extractCommits
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
extractCommitsBetweenBranches
public BuildRepositoryChanges extractCommitsBetweenBranches(File cacheDirectory, VcsBranch otherBranch, boolean limitChangeList) throws RepositoryException - Specified by:
extractCommitsBetweenBranches
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
createBranch
public void createBranch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String branchName) throws RepositoryException - Specified by:
createBranch
in interfaceGitOperationHelper
- Throws:
RepositoryException
-
createLightweightTag
public void createLightweightTag(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String tagName, @NotNull @NotNull String revision) throws RepositoryException - Specified by:
createLightweightTag
in interfaceGitOperationHelper
- Throws:
RepositoryException
-