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
FieldsFields inherited from class com.atlassian.bamboo.plugins.git.AbstractGitOperationHelper
accessData, buildLogger, CHANGESET_LIMIT, DEFAULT_TRANSFER_TIMEOUT, FQREF_PREFIXES, i18nResolver, trustedKeyHelper -
Constructor Summary
ConstructorsConstructorDescriptionNativeGitOperationHelper(@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 voidafterRepositoryAccess(@NotNull GitRepositoryAccessData accessData) protected GitRepositoryAccessDatabeforeRepositoryAccess(@NotNull GitRepositoryAccessData accessData) Wrap with proxy if needed.@NotNull Stringcheckout(@Nullable File cacheDirectory, @NotNull File sourceDirectory, @NotNull String targetRevision, @Nullable String previousRevision) @NotNull Stringcheckout(@Nullable File cacheDirectory, @NotNull File sourceDirectory, @NotNull String targetRevision, @Nullable String ignored, boolean fetchLfsFiles) booleancheckRevisionExistsInCacheRepository(@NotNull File repositoryDirectory, @NotNull String targetRevision) protected voidcloseProxy(@NotNull GitRepositoryAccessData accessData) @NotNull Stringcommit(@NotNull File sourceDirectory, @NotNull String message, @NotNull String committerName, @NotNull String committerEmail, boolean stageModifications) voidcreateBranch(@NotNull File sourceDirectory, @NotNull String branchName) static @NotNull FilecreateCredentialsFile(String repositoryUrlWithPassword) voidcreateLightweightTag(@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) voidfetch(@NotNull File sourceDirectory, @NotNull HashAndSource hashAndSource, boolean useShallow) voidfetch(@NotNull File sourceDirectory, @NotNull HashAndSource hashAndSource, boolean useShallow, boolean fetchTagsByDefault) voidfetch(@NotNull File sourceDirectory, @NotNull HashAndSource hashAndSource, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) voidvoidfetch(@NotNull File sourceDirectory, @NotNull String targetBranchOrRevision, boolean useShallow, boolean fetchTagsByDefault) voidfetch(@NotNull File sourceDirectory, @NotNull String targetBranchOrRevision, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) getBranchForSha(@NotNull File sourceDirectory, String revision, String configuredBranch) @NotNull CommitContextGets the commit for the revision, given a working directory.getCurrentBranch(@NotNull File checkoutPath) @NotNull StringgetCurrentRevision(@NotNull File sourceDirectory) getOpenBranches(@NotNull GitRepositoryAccessData repositoryData) @Nullable StringgetShaOfRefIfExists(@NotNull File sourceDirectory, @NotNull String ref) getTagsForRepository(@NotNull GitRepositoryAccessData accessData) identificationVariables(@NotNull String name, @NotNull String email) booleanisAncestor(@NotNull Path gitWorkspace, @NotNull GitHash rev1, @NotNull GitHash rev2) Returns true if you can reach rev1 by following parent relationship starting from rev2.booleanbooleanmerge(@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 HashAndSourceobtainLatestRevision(@NotNull File repositoryDirectory, GitRef ref, String path) voidpushBranchOrTag(@NotNull File sourceDirectory, @NotNull String refName) voidpushRevision(@NotNull File sourceDirectory, @NotNull String revision, @Nullable String currentBranch) voidstageChanges(@NotNull File sourceDirectory, @NotNull Collection<String> filePaths) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.bamboo.plugins.git.GitOperationHelper
commit
-
Field Details
-
ALL_REFS
-
sshProxyService
-
-
Constructor Details
-
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:
pushRevisionin interfaceGitOperationHelper- Throws:
RepositoryException
-
pushBranchOrTag
public void pushBranchOrTag(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String refName) throws RepositoryException - Specified by:
pushBranchOrTagin 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:
commitin interfaceGitOperationHelper- Throws:
RepositoryException
-
stageChanges
public void stageChanges(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull Collection<String> filePaths) throws RepositoryException - Specified by:
stageChangesin 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:
mergein 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:
mergeAndReturnHeadin 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:
checkoutin 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:
checkoutin interfaceGitOperationHelper- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetBranchOrRevision, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException - Specified by:
fetchin 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:
fetchin interfaceGitOperationHelper- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetBranchOrRevision, boolean useShallow) throws RepositoryException - Specified by:
fetchin interfaceGitOperationHelper- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource hashAndSource, boolean useShallow) throws RepositoryException - Specified by:
fetchin interfaceGitOperationHelper- Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource hashAndSource, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException - Specified by:
fetchin 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:
fetchin interfaceGitOperationHelper- Throws:
RepositoryException
-
getOpenBranches
@NotNull public @NotNull List<VcsBranch> getOpenBranches(@NotNull @NotNull GitRepositoryAccessData repositoryData) throws RepositoryException - Specified by:
getOpenBranchesin interfaceGitOperationHelper- Throws:
RepositoryException
-
getBranchForSha
@NotNull public @NotNull Optional<String> getBranchForSha(@NotNull @NotNull File sourceDirectory, String revision, String configuredBranch) throws RepositoryException - Specified by:
getBranchForShain 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:
obtainLatestRevisionin 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:GitOperationHelperReturns true if you can reach rev1 by following parent relationship starting from rev2.- Specified by:
isAncestorin interfaceGitOperationHelper- Throws:
RepositoryException
-
getCurrentRevision
@NotNull public @NotNull String getCurrentRevision(@NotNull @NotNull File sourceDirectory) throws RepositoryException - Specified by:
getCurrentRevisionin interfaceGitOperationHelper- Throws:
RepositoryException
-
getCurrentBranch
- Specified by:
getCurrentBranchin interfaceGitOperationHelper- Throws:
RepositoryException
-
getTagsForRepository
public List<TagAndRevision> getTagsForRepository(@NotNull @NotNull GitRepositoryAccessData accessData) throws RepositoryException - Specified by:
getTagsForRepositoryin interfaceGitOperationHelper- Throws:
RepositoryException
-
isClean
- Specified by:
isCleanin interfaceGitOperationHelper- Throws:
RepositoryException
-
getShaOfRefIfExists
@Nullable public @Nullable String getShaOfRefIfExists(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String ref) - Specified by:
getShaOfRefIfExistsin interfaceGitOperationHelper
-
obtainLatestRevision
- Specified by:
obtainLatestRevisionin interfaceGitOperationHelper- Throws:
RepositoryException
-
checkRevisionExistsInCacheRepository
public boolean checkRevisionExistsInCacheRepository(@NotNull @NotNull File repositoryDirectory, @NotNull @NotNull String targetRevision) throws RepositoryException - Specified by:
checkRevisionExistsInCacheRepositoryin interfaceGitOperationHelper- Throws:
RepositoryException
-
getCommit
@NotNull public @NotNull CommitContext getCommit(File directory, String targetRevision) throws RepositoryException Description copied from interface:GitOperationHelperGets the commit for the revision, given a working directory.- Specified by:
getCommitin 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:
extractCommitsin interfaceGitOperationHelper- Throws:
RepositoryException
-
extractCommits
public BuildRepositoryChanges extractCommits(File cacheDirectory, @NotNull @NotNull String startingRevision, String endingRevision, @Nullable @Nullable String path) throws RepositoryException - Specified by:
extractCommitsin interfaceGitOperationHelper- Throws:
RepositoryException
-
extractCommitsBetweenBranches
public BuildRepositoryChanges extractCommitsBetweenBranches(File cacheDirectory, VcsBranch otherBranch, boolean limitChangeList) throws RepositoryException - Specified by:
extractCommitsBetweenBranchesin interfaceGitOperationHelper- Throws:
RepositoryException
-
createBranch
public void createBranch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String branchName) throws RepositoryException - Specified by:
createBranchin interfaceGitOperationHelper- Throws:
RepositoryException
-
createLightweightTag
public void createLightweightTag(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String tagName, @NotNull @NotNull String revision) throws RepositoryException - Specified by:
createLightweightTagin interfaceGitOperationHelper- Throws:
RepositoryException
-