public class JGitOperationHelper extends AbstractGitOperationHelper
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
JGitOperationHelper.WithFetchConnectionCallback<E extends Throwable,T> |
protected static interface |
JGitOperationHelper.WithRepositoryCallback<E extends Throwable,V> |
protected static interface |
JGitOperationHelper.WithTransportCallback<E extends Throwable,T> |
accessData, buildLogger, CHANGESET_LIMIT, DEFAULT_TRANSFER_TIMEOUT, FQREF_PREFIXES, i18nResolver, trustedKeyHelper| Constructor and Description |
|---|
JGitOperationHelper(GitRepositoryAccessData accessData,
BuildLogger buildLogger,
com.atlassian.sal.api.message.I18nResolver i18nResolver,
TrustedKeyHelper trustedKeyHelper) |
| Modifier and Type | Method and Description |
|---|---|
String |
checkout(File cacheDirectory,
File sourceDirectory,
String targetRevision,
String previousRevision) |
boolean |
checkRevisionExistsInCacheRepository(File repositoryDirectory,
String targetRevision) |
String |
commit(File sourceDirectory,
String message,
String comitterName,
String comitterEmail) |
protected org.eclipse.jgit.lib.Repository |
createLocalRepository(File workingDirectory,
File cacheDirectory) |
BuildRepositoryChanges |
extractCommits(File directory,
String startingRevision,
String endingRevision) |
BuildRepositoryChanges |
extractCommits(File cacheDirectory,
String startingRevision,
String endingRevision,
String path) |
void |
fetch(File sourceDirectory,
HashAndSource refAndHash,
boolean useShallow) |
void |
fetch(File sourceDirectory,
String targetRevision,
boolean useShallow) |
Optional<String> |
getBranchForSha(File sourceDirectory,
String revision,
String configuredBranch) |
CommitContext |
getCommit(File directory,
String targetRevision)
Gets the commit for the revision, given a working directory.
|
String |
getCurrentRevision(File sourceDirectory) |
List<VcsBranch> |
getOpenBranches(GitRepositoryAccessData repositoryData,
File workingDir) |
protected String |
getRevision(File sourceDirectory,
String revision) |
String |
getShaOfRefIfExists(File sourceDirectory,
String ref) |
boolean |
isAncestor(Path gitWorkspace,
GitHash rev1,
GitHash rev2)
Returns true if you can reach rev1 by following parent relationship starting from rev2.
|
boolean |
merge(File workspaceDir,
String targetRevision,
String committerName,
String committerEmail) |
Pair<Boolean,String> |
mergeAndReturnHead(File workspaceDir,
String currentRevision,
String targetRevision,
String committerName,
String committerEmail) |
HashAndSource |
obtainLatestRevision() |
Optional<GitHash> |
obtainLatestRevision(File repositoryDirectory,
GitRef ref,
String path) |
void |
pushRevision(File sourceDirectory,
String revision)
Pushes arbitrary revision (refspec?) back to the upstream repo.
|
protected <E extends Throwable,T> |
withFetchConnection(org.eclipse.jgit.lib.Repository repository,
GitRepositoryAccessData accessData,
JGitOperationHelper.WithFetchConnectionCallback<E,T> callback) |
protected <E extends Throwable,T> |
withFetchConnection(org.eclipse.jgit.transport.Transport transport,
JGitOperationHelper.WithFetchConnectionCallback<E,T> callback) |
protected <E extends Throwable,T> |
withTransport(org.eclipse.jgit.lib.Repository repository,
GitRepositoryAccessData accessData,
JGitOperationHelper.WithTransportCallback<E,T> callback) |
public JGitOperationHelper(GitRepositoryAccessData accessData, @NotNull BuildLogger buildLogger, @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull TrustedKeyHelper trustedKeyHelper)
public String commit(@NotNull File sourceDirectory, @NotNull String message, @NotNull String comitterName, @NotNull String comitterEmail) throws RepositoryException
RepositoryExceptionpublic boolean merge(@NotNull
File workspaceDir,
@NotNull
String targetRevision,
@NotNull
String committerName,
@NotNull
String committerEmail)
public Pair<Boolean,String> mergeAndReturnHead(@NotNull File workspaceDir, @NotNull String currentRevision, @NotNull String targetRevision, @NotNull String committerName, @NotNull String committerEmail) throws RepositoryException
RepositoryExceptionpublic void pushRevision(@NotNull
File sourceDirectory,
@NotNull
String revision)
throws RepositoryException
RepositoryException@NotNull public String checkout(@Nullable File cacheDirectory, @NotNull File sourceDirectory, @NotNull String targetRevision, @Nullable String previousRevision) throws RepositoryException
RepositoryExceptionpublic void fetch(@NotNull
File sourceDirectory,
@NotNull
String targetRevision,
boolean useShallow)
throws RepositoryException
RepositoryExceptionpublic void fetch(@NotNull
File sourceDirectory,
@NotNull
HashAndSource refAndHash,
boolean useShallow)
throws RepositoryException
RepositoryException@NotNull public String getCurrentRevision(@NotNull File sourceDirectory) throws RepositoryException
RepositoryExceptionprotected String getRevision(File sourceDirectory, @NotNull String revision) throws RepositoryException
RepositoryException@Nullable public String getShaOfRefIfExists(@NotNull File sourceDirectory, @NotNull String ref)
@NotNull public HashAndSource obtainLatestRevision() throws RepositoryException
RepositoryException@NotNull public List<VcsBranch> getOpenBranches(@NotNull GitRepositoryAccessData repositoryData, File workingDir) throws RepositoryException
RepositoryExceptionpublic boolean checkRevisionExistsInCacheRepository(@NotNull
File repositoryDirectory,
@NotNull
String targetRevision)
throws IOException,
RepositoryException
repositoryDirectory - directory where repository is fetchedtargetRevision - revision to find in repositoryIOException - thrown when revision not found (MissingObjectException)RepositoryExceptionprotected org.eclipse.jgit.lib.Repository createLocalRepository(File workingDirectory, @Nullable File cacheDirectory) throws IOException
IOExceptionpublic BuildRepositoryChanges extractCommits(@NotNull File directory, @Nullable String startingRevision, @Nullable String endingRevision) throws RepositoryException
RepositoryExceptionpublic BuildRepositoryChanges extractCommits(File cacheDirectory, @NotNull String startingRevision, String endingRevision, String path) throws RepositoryException
RepositoryException@NotNull public Optional<String> getBranchForSha(@NotNull File sourceDirectory, String revision, String configuredBranch) throws RepositoryException
RepositoryException - if revision doesn't exist in repositorypublic Optional<GitHash> obtainLatestRevision(@NotNull File repositoryDirectory, GitRef ref, String path)
public boolean isAncestor(@NotNull
Path gitWorkspace,
@NotNull
GitHash rev1,
@NotNull
GitHash rev2)
throws RepositoryException
GitOperationHelperRepositoryException@NotNull public CommitContext getCommit(File directory, String targetRevision) throws RepositoryException
GitOperationHelperRepositoryException - if the revision can't be found@Nullable protected <E extends Throwable,T> T withTransport(@NotNull org.eclipse.jgit.lib.Repository repository, @NotNull GitRepositoryAccessData accessData, @NotNull JGitOperationHelper.WithTransportCallback<E,T> callback) throws E extends Throwable, RepositoryException
E extends ThrowableRepositoryExceptionprotected <E extends Throwable,T> T withFetchConnection(@NotNull org.eclipse.jgit.transport.Transport transport, @NotNull JGitOperationHelper.WithFetchConnectionCallback<E,T> callback) throws E extends Throwable, org.eclipse.jgit.errors.NotSupportedException, org.eclipse.jgit.errors.TransportException
E extends Throwableorg.eclipse.jgit.errors.NotSupportedExceptionorg.eclipse.jgit.errors.TransportExceptionprotected <E extends Throwable,T> T withFetchConnection(@NotNull org.eclipse.jgit.lib.Repository repository, @NotNull GitRepositoryAccessData accessData, @NotNull JGitOperationHelper.WithFetchConnectionCallback<E,T> callback) throws E extends Throwable, RepositoryException, org.eclipse.jgit.errors.NotSupportedException, org.eclipse.jgit.errors.TransportException
E extends ThrowableRepositoryExceptionorg.eclipse.jgit.errors.NotSupportedExceptionorg.eclipse.jgit.errors.TransportExceptionCopyright © 2017 Atlassian Software Systems Pty Ltd. All rights reserved.