Class GitChangeDetector
- java.lang.Object
-
- com.atlassian.bamboo.plugins.git.v2.AbstractGitExecutor
-
- com.atlassian.bamboo.plugins.git.v2.GitChangeDetector
-
- All Implemented Interfaces:
IdentifyingExecutor<VcsChangeDetector>
,VcsChangeDetector
public class GitChangeDetector extends AbstractGitExecutor implements VcsChangeDetector
-
-
Field Summary
-
Fields inherited from class com.atlassian.bamboo.plugins.git.v2.AbstractGitExecutor
buildDirectoryManager, buildLoggingContext, customVariableContext, DEFAULT_BRANCH, i18nResolver, sshProxyService, trustedKeyHelper
-
-
Constructor Summary
Constructors Constructor Description GitChangeDetector(CapabilityContext capabilityContext, CredentialsAccessor credentialsAccessor, CustomVariableContext customVariableContext, BuildDirectoryManager buildDirectoryManager, com.atlassian.sal.api.message.I18nResolver i18nResolver, TrustedKeyHelper trustedKeyHelper, SshProxyService sshProxyService, BuildLoggerManager buildLoggerManager, BuildLoggingContext buildLoggingContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BuildRepositoryChanges
collectChangesForInitialBuild(@NotNull PlanKey planKey, @NotNull VcsRepositoryData vcsRepositoryData, @NotNull VcsBranch otherBranch, boolean otherBranchUnreliable)
This method is used to generate the list of commits for an initial build of a plan branch.@NotNull BuildRepositoryChanges
collectChangesForRevision(@NotNull PlanKey planKey, @NotNull VcsRepositoryData repositoryData, @NotNull String customRevision)
@NotNull BuildRepositoryChanges
collectChangesSinceRevision(@NotNull PlanKey planKey, @NotNull VcsRepositoryData repositoryData, @NotNull PlanVcsRevisionData lastRevisionData)
static CommitContext
createUnknownChangesEntry(com.atlassian.sal.api.message.I18nResolver i18nResolver, @Nullable String startRevision, String endRevision)
static String
determineStartOfRevisionRange(GitOperationHelper helper, File cacheDirectory, @Nullable String preferredRevision, String fallbackRevision)
static void
ensureRevisionExists(GitOperationHelper helper, File cacheDirectory, String hashOrRefToFetch, String targetRevision)
@Nullable ContextualVcsId<VcsChangeDetector>
getVcsIdForExecutor(@NotNull VcsRepositoryData vcsRepositoryData)
Returned id has to fulfill the following: Given two VcsRepositoryData objects A and B, and executor e returning equal ContextualVcsId (in terms of equals()), for any operation foo() provided by the executor, the calls e::foo(A) and e::foo(B) should be equivalent.-
Methods inherited from class com.atlassian.bamboo.plugins.git.v2.AbstractGitExecutor
fetchCacheWithRetry, fetchWithRetry, getAccessData, getCacheDirectory, getCachePath, getGitCapability, getSharedCredentialsIdField, getSshCapability, getSubstitutedAccessData, getSubstitutedAccessDataBuilder, getWorkingDirectory, isUsingSharedCredentials, rethrowOrRemoveDirectory, substituteString
-
-
-
-
Constructor Detail
-
GitChangeDetector
@Inject public GitChangeDetector(CapabilityContext capabilityContext, CredentialsAccessor credentialsAccessor, CustomVariableContext customVariableContext, BuildDirectoryManager buildDirectoryManager, com.atlassian.sal.api.message.I18nResolver i18nResolver, TrustedKeyHelper trustedKeyHelper, SshProxyService sshProxyService, BuildLoggerManager buildLoggerManager, BuildLoggingContext buildLoggingContext)
-
-
Method Detail
-
collectChangesSinceRevision
@NotNull public @NotNull BuildRepositoryChanges collectChangesSinceRevision(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull PlanVcsRevisionData lastRevisionData) throws RepositoryException
- Specified by:
collectChangesSinceRevision
in interfaceVcsChangeDetector
- Throws:
RepositoryException
-
collectChangesForRevision
@NotNull public @NotNull BuildRepositoryChanges collectChangesForRevision(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull VcsRepositoryData repositoryData, @NotNull @NotNull String customRevision) throws RepositoryException
- Specified by:
collectChangesForRevision
in interfaceVcsChangeDetector
- Throws:
RepositoryException
-
collectChangesForInitialBuild
public BuildRepositoryChanges collectChangesForInitialBuild(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull VcsRepositoryData vcsRepositoryData, @NotNull @NotNull VcsBranch otherBranch, boolean otherBranchUnreliable) throws RepositoryException
Description copied from interface:VcsChangeDetector
This method is used to generate the list of commits for an initial build of a plan branch. In particular, this _can_ be the result of comparing current branch with another branch, but it's not a strict contract, i.e. depending on vcs type, there might exist better way to determine optimum commit list. Default implementations returns the last commit revision and empty commit list.- Specified by:
collectChangesForInitialBuild
in interfaceVcsChangeDetector
otherBranch
- branch that can be used as reference when generating the commit list. Guaranteed to be not null if the repository type supports branches.otherBranchUnreliable
- indicates that 'otherBranch' is not a reliable reference point- Throws:
RepositoryException
-
ensureRevisionExists
public static void ensureRevisionExists(GitOperationHelper helper, File cacheDirectory, String hashOrRefToFetch, String targetRevision) throws RepositoryException
- Throws:
RepositoryException
-
determineStartOfRevisionRange
public static String determineStartOfRevisionRange(GitOperationHelper helper, File cacheDirectory, @Nullable @Nullable String preferredRevision, String fallbackRevision)
-
createUnknownChangesEntry
public static CommitContext createUnknownChangesEntry(com.atlassian.sal.api.message.I18nResolver i18nResolver, @Nullable @Nullable String startRevision, String endRevision)
-
getVcsIdForExecutor
@Nullable public @Nullable ContextualVcsId<VcsChangeDetector> getVcsIdForExecutor(@NotNull @NotNull VcsRepositoryData vcsRepositoryData)
Description copied from interface:IdentifyingExecutor
Returned id has to fulfill the following: Given two VcsRepositoryData objects A and B, and executor e returning equal ContextualVcsId (in terms of equals()), for any operation foo() provided by the executor, the calls e::foo(A) and e::foo(B) should be equivalent. To be more precise: given any time point t and any variable context v, calling a::foo(A) should yield the same results as calling e::foo(B). Given the above it follows that - calculation of the id should take into account global and plan variables. This means, that calling this method on the same object in different variable context can (possibly must) yield different results. - equal ids need not (and should not) guarantee equal call results over indefinite time. In particular, result of e:foo(A).equals(e::foo(A)) is allowed to be false, since 2 calls to e::foo(A) do not happen at the same time. Example: 2 git repositories with the same url and credentials are considered equal in context ofVcsBranchDetector
. If they also point to the same branch, they are considered equal in context ofVcsChangeDetector
- Specified by:
getVcsIdForExecutor
in interfaceIdentifyingExecutor<VcsChangeDetector>
- Returns:
- the id of repository, can be null if no feasible identification algorithm exists
-
-