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,
@NotNull BuildLogger buildLogger,
@NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver,
@NotNull TrustedKeyHelper trustedKeyHelper) |
Modifier and Type | Method and Description |
---|---|
@NotNull String |
checkout(@Nullable File cacheDirectory,
@NotNull File sourceDirectory,
@NotNull String targetRevision,
@Nullable String previousRevision) |
boolean |
checkRevisionExistsInCacheRepository(@NotNull File repositoryDirectory,
@NotNull String targetRevision) |
@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) |
void |
createLightweightTag(@NotNull File sourceDirectory,
@NotNull String tagName,
@NotNull String revision) |
protected org.eclipse.jgit.lib.Repository |
createLocalRepository(File workingDirectory,
@Nullable File cacheDirectory) |
BuildRepositoryChanges |
extractCommits(@NotNull File directory,
@Nullable String startingRevision,
@Nullable String endingRevision) |
BuildRepositoryChanges |
extractCommits(File cacheDirectory,
@NotNull String startingRevision,
String endingRevision,
String path) |
BuildRepositoryChanges |
extractCommitsBetweenBranches(File cacheDirectory,
VcsBranch otherBranch,
boolean limitChangeList) |
void |
fetch(@NotNull File sourceDirectory,
@NotNull HashAndSource refAndHash,
boolean useShallow) |
void |
fetch(@NotNull File sourceDirectory,
@NotNull HashAndSource refAndHash,
boolean useShallow,
boolean fetchTagsByDefault) |
void |
fetch(@NotNull File sourceDirectory,
@NotNull String targetRevision,
boolean useShallow) |
void |
fetch(@NotNull File sourceDirectory,
@NotNull String targetRevision,
boolean useShallow,
boolean fetchTagsByDefault) |
@NotNull Optional<String> |
getBranchForSha(@NotNull File sourceDirectory,
String revision,
String configuredBranch) |
@NotNull CommitContext |
getCommit(File directory,
String targetRevision)
Gets the commit for the revision, given a working directory.
|
String |
getCurrentBranch(@NotNull File checkoutPath) |
@NotNull String |
getCurrentRevision(@NotNull File sourceDirectory) |
@NotNull List<VcsBranch> |
getOpenBranches(@NotNull GitRepositoryAccessData repositoryData,
File workingDir) |
protected String |
getRevision(File sourceDirectory,
@NotNull String revision) |
@Nullable String |
getShaOfRefIfExists(@NotNull File sourceDirectory,
@NotNull String ref) |
List<TagAndRevision> |
getTagsForRepository(@NotNull GitRepositoryAccessData accessData) |
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 |
isClean(@NotNull File sourceDirectory) |
boolean |
merge(@NotNull File workspaceDir,
@NotNull String targetRevision,
@NotNull String committerName,
@NotNull String committerEmail) |
Pair<Boolean,String> |
mergeAndReturnHead(@NotNull File workspaceDir,
@NotNull String currentRevision,
@NotNull String targetRevision,
@NotNull String committerName,
@NotNull String committerEmail) |
@NotNull HashAndSource |
obtainLatestRevision() |
Optional<GitHash> |
obtainLatestRevision(@NotNull File repositoryDirectory,
GitRef ref,
String path) |
void |
pushBranchOrTag(@NotNull File sourceDirectory,
@NotNull String branchName) |
void |
pushRevision(@NotNull File sourceDirectory,
@NotNull String revision,
@Nullable String currentBranch)
Pushes arbitrary revision (refspec?) back to the upstream repo.
|
void |
stageChanges(@NotNull File sourceDirectory,
@NotNull Collection<String> filePaths) |
protected <E extends Throwable,T> |
withFetchConnection(@NotNull org.eclipse.jgit.lib.Repository repository,
@NotNull GitRepositoryAccessData accessData,
@NotNull JGitOperationHelper.WithFetchConnectionCallback<E,T> callback) |
protected <E extends Throwable,T> |
withFetchConnection(@NotNull org.eclipse.jgit.transport.Transport transport,
@NotNull JGitOperationHelper.WithFetchConnectionCallback<E,T> callback) |
protected <E extends Throwable,T> |
withTransport(@NotNull org.eclipse.jgit.lib.Repository repository,
@NotNull GitRepositoryAccessData accessData,
@NotNull JGitOperationHelper.WithTransportCallback<E,T> callback) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
commit
public JGitOperationHelper(GitRepositoryAccessData accessData, @NotNull @NotNull BuildLogger buildLogger, @NotNull @NotNull com.atlassian.sal.api.message.I18nResolver i18nResolver, @NotNull @NotNull TrustedKeyHelper trustedKeyHelper)
@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
RepositoryException
public void stageChanges(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull Collection<String> filePaths) throws RepositoryException
RepositoryException
public boolean merge(@NotNull @NotNull File workspaceDir, @NotNull @NotNull String targetRevision, @NotNull @NotNull String committerName, @NotNull @NotNull String committerEmail)
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
RepositoryException
public void pushRevision(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String revision, @Nullable @Nullable String currentBranch) throws RepositoryException
RepositoryException
public void pushBranchOrTag(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String branchName) throws RepositoryException
RepositoryException
@NotNull public @NotNull String checkout(@Nullable @Nullable File cacheDirectory, @NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, @Nullable @Nullable String previousRevision) throws RepositoryException
RepositoryException
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException
RepositoryException
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource refAndHash, boolean useShallow, boolean fetchTagsByDefault) throws RepositoryException
RepositoryException
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String targetRevision, boolean useShallow) throws RepositoryException
RepositoryException
public void fetch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull HashAndSource refAndHash, boolean useShallow) throws RepositoryException
RepositoryException
@NotNull public @NotNull String getCurrentRevision(@NotNull @NotNull File sourceDirectory) throws RepositoryException
RepositoryException
public List<TagAndRevision> getTagsForRepository(@NotNull @NotNull GitRepositoryAccessData accessData) throws RepositoryException
RepositoryException
public String getCurrentBranch(@NotNull @NotNull File checkoutPath) throws RepositoryException
RepositoryException
public boolean isClean(@NotNull @NotNull File sourceDirectory) throws RepositoryException
RepositoryException
protected String getRevision(File sourceDirectory, @NotNull @NotNull String revision) throws RepositoryException
RepositoryException
@Nullable public @Nullable String getShaOfRefIfExists(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String ref)
@NotNull public @NotNull HashAndSource obtainLatestRevision() throws RepositoryException
RepositoryException
@NotNull public @NotNull List<VcsBranch> getOpenBranches(@NotNull @NotNull GitRepositoryAccessData repositoryData, File workingDir) throws RepositoryException
RepositoryException
public boolean checkRevisionExistsInCacheRepository(@NotNull @NotNull File repositoryDirectory, @NotNull @NotNull String targetRevision) throws IOException, RepositoryException
repositoryDirectory
- directory where repository is fetchedtargetRevision
- revision to find in repositoryIOException
- thrown when revision not found (MissingObjectException)RepositoryException
public BuildRepositoryChanges extractCommitsBetweenBranches(File cacheDirectory, VcsBranch otherBranch, boolean limitChangeList)
protected org.eclipse.jgit.lib.Repository createLocalRepository(File workingDirectory, @Nullable @Nullable File cacheDirectory) throws IOException
IOException
public BuildRepositoryChanges extractCommits(@NotNull @NotNull File directory, @Nullable @Nullable String startingRevision, @Nullable @Nullable String endingRevision) throws RepositoryException
RepositoryException
public BuildRepositoryChanges extractCommits(File cacheDirectory, @NotNull @NotNull String startingRevision, String endingRevision, String path) throws RepositoryException
RepositoryException
@NotNull public @NotNull Optional<String> getBranchForSha(@NotNull @NotNull File sourceDirectory, String revision, String configuredBranch) throws RepositoryException
RepositoryException
public Optional<GitHash> obtainLatestRevision(@NotNull @NotNull File repositoryDirectory, GitRef ref, String path)
public boolean isAncestor(@NotNull @NotNull Path gitWorkspace, @NotNull @NotNull GitHash rev1, @NotNull @NotNull GitHash rev2) throws RepositoryException
GitOperationHelper
RepositoryException
public void createBranch(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String branchName) throws RepositoryException
RepositoryException
public void createLightweightTag(@NotNull @NotNull File sourceDirectory, @NotNull @NotNull String tagName, @NotNull @NotNull String revision) throws RepositoryException
RepositoryException
@NotNull public @NotNull CommitContext getCommit(File directory, String targetRevision) throws RepositoryException
GitOperationHelper
RepositoryException
- if the revision can't be found@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 extends Throwable, RepositoryException
E extends Throwable
RepositoryException
protected <E extends Throwable,T> T withFetchConnection(@NotNull @NotNull org.eclipse.jgit.transport.Transport transport, @NotNull @NotNull JGitOperationHelper.WithFetchConnectionCallback<E,T> callback) throws E extends Throwable, org.eclipse.jgit.errors.NotSupportedException, org.eclipse.jgit.errors.TransportException
E extends Throwable
org.eclipse.jgit.errors.NotSupportedException
org.eclipse.jgit.errors.TransportException
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 extends Throwable, RepositoryException, org.eclipse.jgit.errors.NotSupportedException, org.eclipse.jgit.errors.TransportException
E extends Throwable
RepositoryException
org.eclipse.jgit.errors.NotSupportedException
org.eclipse.jgit.errors.TransportException
Copyright © 2022 Atlassian Software Systems Pty Ltd. All rights reserved.