Package com.atlassian.bamboo.plugins.git
Class JGitOperationHelper
java.lang.Object
com.atlassian.bamboo.plugins.git.AbstractGitOperationHelper
com.atlassian.bamboo.plugins.git.JGitOperationHelper
- All Implemented Interfaces:
GitOperationHelper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceprotected static interfaceprotected static interface -
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
ConstructorsConstructorDescriptionJGitOperationHelper(GitRepositoryAccessData accessData, @NotNull BuildLogger buildLogger, @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull TrustedKeyHelper trustedKeyHelper) -
Method Summary
Modifier and TypeMethodDescription@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 previousRevision, boolean fetchLfsFiles) booleancheckRevisionExistsInCacheRepository(@NotNull File repositoryDirectory, @NotNull String targetRevision) @NotNull Stringcommit(@NotNull File sourceDirectory, @NotNull String message, @NotNull String committerName, @NotNull String committerEmail, boolean stageModifications) voidcreateBranch(@NotNull File sourceDirectory, @NotNull String branchName) voidcreateLightweightTag(@NotNull File sourceDirectory, @NotNull String tagName, @NotNull String revision) protected org.eclipse.jgit.lib.RepositorycreateLocalRepository(File workingDirectory, @Nullable File cacheDirectory) extractCommits(@NotNull File directory, @Nullable String startingRevision, @Nullable String endingRevision) extractCommits(File cacheDirectory, @NotNull String startingRevision, String endingRevision, String path) extractCommitsBetweenBranches(File cacheDirectory, VcsBranch otherBranch, boolean limitChangeList) voidfetch(@NotNull File sourceDirectory, @NotNull HashAndSource refAndHash, boolean useShallow) voidfetch(@NotNull File sourceDirectory, @NotNull HashAndSource refAndHash, boolean useShallow, boolean fetchTagsByDefault) voidfetch(@NotNull File sourceDirectory, @NotNull HashAndSource refAndHash, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) voidvoidfetch(@NotNull File sourceDirectory, @NotNull String targetRevision, boolean useShallow, boolean fetchTagsByDefault) voidfetch(@NotNull File sourceDirectory, @NotNull String targetRevision, 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) protected StringgetRevision(File sourceDirectory, @NotNull String revision) @Nullable StringgetShaOfRefIfExists(@NotNull File sourceDirectory, @NotNull String ref) getTagsForRepository(@NotNull GitRepositoryAccessData accessData) 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 branchName) voidpushRevision(@NotNull File sourceDirectory, @NotNull String revision, @Nullable String currentBranch) Pushes arbitrary revision (refspec?)voidstageChanges(@NotNull File sourceDirectory, @NotNull Collection<String> filePaths) protected <E extends Throwable,T>
TwithFetchConnection(@NotNull org.eclipse.jgit.lib.Repository repository, @NotNull GitRepositoryAccessData accessData, @NotNull JGitOperationHelper.WithFetchConnectionCallback<E, T> callback) protected <E extends Throwable,T>
TwithFetchConnection(@NotNull org.eclipse.jgit.transport.Transport transport, @NotNull JGitOperationHelper.WithFetchConnectionCallback<E, T> callback) protected <E extends Throwable,T>
TwithTransport(@NotNull org.eclipse.jgit.lib.Repository repository, @NotNull GitRepositoryAccessData accessData, @NotNull JGitOperationHelper.WithTransportCallback<E, T> callback) 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
-
PUSH_IS_NOT_SUPPORTED
- See Also:
-
-
Constructor Details
-
JGitOperationHelper
public JGitOperationHelper(GitRepositoryAccessData accessData, @NotNull @NotNull BuildLogger buildLogger, @NotNull @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull @NotNull TrustedKeyHelper trustedKeyHelper)
-
-
Method Details
-
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 - Throws:
RepositoryException
-
stageChanges
public void stageChanges(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull Collection<String> filePaths) -
merge
-
mergeAndReturnHead
-
pushRevision
public void pushRevision(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String revision, @Nullable @Nullable String currentBranch) Pushes arbitrary revision (refspec?) back to the upstream repo. -
pushBranchOrTag
-
checkout
@NotNull public @NotNull String checkout(@Nullable @Nullable File cacheDirectory, @NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, @Nullable @Nullable String previousRevision, boolean fetchLfsFiles) throws RepositoryException - 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 - Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException - Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) throws RepositoryException - Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource refAndHash, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException - Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, boolean useShallow) throws RepositoryException - Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource refAndHash, boolean useShallow) throws RepositoryException - Throws:
RepositoryException
-
fetch
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource refAndHash, boolean useShallow, boolean fetchTagsByDefault, boolean fetchLfsFiles) throws RepositoryException - Throws:
RepositoryException
-
getCurrentRevision
@NotNull public @NotNull String getCurrentRevision(@NotNull @NotNull File sourceDirectory) throws RepositoryException - Throws:
RepositoryException
-
getTagsForRepository
public List<TagAndRevision> getTagsForRepository(@NotNull @NotNull GitRepositoryAccessData accessData) -
getCurrentBranch
- Throws:
RepositoryException
-
isClean
- Throws:
RepositoryException
-
getRevision
protected String getRevision(File sourceDirectory, @NotNull @NotNull String revision) throws RepositoryException - Throws:
RepositoryException
-
getShaOfRefIfExists
-
obtainLatestRevision
- Throws:
RepositoryException
-
getOpenBranches
@NotNull public @NotNull List<VcsBranch> getOpenBranches(@NotNull @NotNull GitRepositoryAccessData repositoryData) throws RepositoryException - Throws:
RepositoryException
-
checkRevisionExistsInCacheRepository
public boolean checkRevisionExistsInCacheRepository(@NotNull @NotNull File repositoryDirectory, @NotNull @NotNull String targetRevision) throws IOException - Parameters:
repositoryDirectory- directory where repository is fetchedtargetRevision- revision to find in repository- Returns:
- true if revision found
- Throws:
IOException- thrown when revision not found (MissingObjectException)
-
extractCommitsBetweenBranches
public BuildRepositoryChanges extractCommitsBetweenBranches(File cacheDirectory, VcsBranch otherBranch, boolean limitChangeList) -
createLocalRepository
protected org.eclipse.jgit.lib.Repository createLocalRepository(File workingDirectory, @Nullable @Nullable File cacheDirectory) throws IOException - Throws:
IOException
-
extractCommits
public BuildRepositoryChanges extractCommits(@NotNull @NotNull File directory, @Nullable @Nullable String startingRevision, @Nullable @Nullable String endingRevision) throws RepositoryException - Throws:
RepositoryException
-
extractCommits
public BuildRepositoryChanges extractCommits(File cacheDirectory, @NotNull @NotNull String startingRevision, String endingRevision, String path) throws RepositoryException - Throws:
RepositoryException
-
getBranchForSha
@NotNull public @NotNull Optional<String> getBranchForSha(@NotNull @NotNull File sourceDirectory, String revision, String configuredBranch) - Returns:
- branch that contains sha and matches the name of configuredBranch
-
obtainLatestRevision
-
isAncestor
public boolean isAncestor(@NotNull @NotNull Path gitWorkspace, @NotNull @NotNull GitHash rev1, @NotNull @NotNull GitHash rev2) Description copied from interface:GitOperationHelperReturns true if you can reach rev1 by following parent relationship starting from rev2. -
createBranch
public void createBranch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String branchName) throws RepositoryException - Throws:
RepositoryException
-
createLightweightTag
-
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.- Throws:
RepositoryException- if the revision can't be found
-
withTransport
@Nullable protected <E extends Throwable,T> T withTransport(@NotNull @NotNull org.eclipse.jgit.lib.Repository repository, @NotNull @NotNull GitRepositoryAccessData accessData, @NotNull @NotNull JGitOperationHelper.WithTransportCallback<E, T> callback) throws E, RepositoryException- Throws:
ERepositoryException
-
withFetchConnection
protected <E extends Throwable,T> T withFetchConnection(@NotNull @NotNull org.eclipse.jgit.transport.Transport transport, @NotNull @NotNull JGitOperationHelper.WithFetchConnectionCallback<E, T> callback) throws E, org.eclipse.jgit.errors.NotSupportedException, org.eclipse.jgit.errors.TransportException- Throws:
Eorg.eclipse.jgit.errors.NotSupportedExceptionorg.eclipse.jgit.errors.TransportException
-
withFetchConnection
protected <E extends Throwable,T> T withFetchConnection(@NotNull @NotNull org.eclipse.jgit.lib.Repository repository, @NotNull @NotNull GitRepositoryAccessData accessData, @NotNull @NotNull JGitOperationHelper.WithFetchConnectionCallback<E, T> callback) throws E, RepositoryException, org.eclipse.jgit.errors.NotSupportedException, org.eclipse.jgit.errors.TransportException- Throws:
ERepositoryExceptionorg.eclipse.jgit.errors.NotSupportedExceptionorg.eclipse.jgit.errors.TransportException
-