public interface ScmCommandFactory
commands
which provide basic SCM functionality such as creating repositories, retrieving
commits and viewing diffs. Each method accepts a set of CommandParameters
which are used to control the
command's behaviour and output.
In general, commands fall into two categories:
PageRequest
describing the page of output that should be returned and return
an object graph when the command is executedVoid
(usually null
) when the
command is executed
Note: The repository
against which created commands will operate was specified when the factory
was retrieved from the ScmService
, and cannot be changed.
Plugin developers: This is probably not the interface you want to use. The API provides services whose functionality is backed by the SCM. Using those services automatically chooses the correct SCM based on the repository, and provides a more stable, compatible API. In general, the functionality of this command factory is exposed by:
The documentation for each method on this interface includes a link to the API service method or methods which expose it.Modifier and Type | Method and Description |
---|---|
Command<Page<Blame>> |
blame(BlameCommandParameters parameters,
PageRequest pageRequest)
Retrieves blame (also sometimes referred to as annotations) for a file at a given revision.
|
Command<Void> |
branches(BranchesCommandParameters parameters,
BranchCallback callback)
|
Command<Page<Branch>> |
branches(BranchesCommandParameters parameters,
PageRequest pageRequest)
|
Command<Void> |
changes(ChangesCommandParameters parameters,
ChangeCallback callback)
|
Command<Page<Change>> |
changes(ChangesCommandParameters parameters,
PageRequest pageRequest)
|
Command<Page<Changeset>> |
changesets(ChangesetsCommandParameters parameters,
PageRequest pageRequest)
Retrieves a page of
changesets given a set of commit IDs , where each changeset includes the first page of changes
between a requested commit and its first parent. |
Command<Commit> |
commit(CommitCommandParameters parameters)
Retrieves
details for the specified commit. |
Command<Void> |
commits(CommitsCommandParameters parameters,
CommitCallback callback)
Streams commits which match the provided
parameters to the provided callback. |
Command<Page<Commit>> |
commits(CommitsCommandParameters parameters,
PageRequest pageRequest)
Retrieves a
page of commits matching the specified parameters . |
Command<MinimalCommit> |
commonAncestor(CommonAncestorCommandParameters parameters)
Retrieves the common ancestor for the provided commits
|
Command<Branch> |
defaultBranch()
Resolves the default branch for the specified repository.
|
Command<Void> |
diff(DiffCommandParameters parameters,
DiffContentCallback callback)
Streams a diff between two
commits . |
Command<Void> |
diff(DiffCommandParameters parameters,
TypeAwareOutputSupplier outputSupplier)
Streams a diff between two
commits . |
Command<Void> |
directory(DirectoryCommandParameters parameters,
ContentTreeCallback callback,
PageRequest pageRequest)
Streams the
tree nodes (files, subdirectories and submodules) in the specified
directory . |
Command<Void> |
file(FileCommandParameters parameters,
FileContentCallback callback,
PageRequest pageRequest)
Streams the contents of the
specified file . |
Command<Void> |
heads(RefCallback callback)
Deprecated.
in 6.4 for removal in 8.0. Use
refs(com.atlassian.bitbucket.scm.RefsCommandParameters, com.atlassian.bitbucket.repository.RefCallback) instead. |
Command<Void> |
rawFile(RawFileCommandParameters parameters,
TypeAwareOutputSupplier outputSupplier)
Streams the raw content of the given file after performing a best effort detection of its
MIME type.
|
Command<Void> |
refs(RefsCommandParameters parameters,
RefCallback callback)
Streams all of the
refs in the repository. |
Command<RepositorySize> |
repositorySize(Repository repository,
RepositorySizeCommandParameters parameters)
Calculates the
size for the specified repository. |
Command<Map<String,String>> |
resolveCommits(ResolveCommitsCommandParameters parameters)
Resolves revisions provided on
parameters to the referenced commit ID. |
Command<Ref> |
resolveRef(ResolveRefCommandParameters parameters)
Resolves the specified
refId , which may be a:
branch name
tag name
commit hash
If the refId should be resolved to a specific type, that type should be set to allow the SCM to restrict its search. |
Command<Map<String,Ref>> |
resolveRefs(ResolveRefsCommandParameters parameters)
Resolves refs from the ref IDs provided on
parameters , which may be one of
branch name
tag name
commit hash
Callers can specify on the parameters whether a provided ID is expected to resolve to a
branch , tag ,
or a ref of unknown type . |
Command<Long> |
size(SizeCommandParameters parameters)
Retrieves the size of the file at the requested path at the specified commit.
|
Command<Page<Tag>> |
tags(TagsCommandParameters parameters,
PageRequest pageRequest)
|
Command<Void> |
tags(TagsCommandParameters parameters,
TagCallback callback)
Streams
tags ordered either alphabetically or by modification and optionally filtered. |
Command<Void> |
traverseCommits(TraversalCallback callback)
Streams all of the commits in the repository reachable from any branch or tag, traversed in topological order.
|
Command<ContentTreeNode.Type> |
type(TypeCommandParameters parameters)
Retrieves the
type for the specified path
at the requested revision, if the path is present. |
@Nonnull Command<Page<Blame>> blame(@Nonnull BlameCommandParameters parameters, @Nonnull PageRequest pageRequest)
The PageRequest
provided determines the lines in the file for which blame is calculated,
and only lines within the scope of the page request will be returned. However, because adjacent lines may be
spanned
by a single author
, the number
of distinct Blame
objects returned will frequently be less than the limit
.
parameters
- parameters describing the file and revision used to calculate blamepageRequest
- describes the set of lines in the file to calculate blame forBlame
for the specified file and
revision for the requested set of linesBlameCommandParameters
,
ContentService.getBlame(Repository, String, String, PageRequest)
,
ContentService.streamFile(Repository, String, String, PageRequest, boolean, FileContentCallback)
@Nonnull Command<Void> branches(@Nonnull BranchesCommandParameters parameters, @Nonnull BranchCallback callback)
Command
which, when executed, will stream branches
ordered either
alphabetically or by modification and optionally filtered.
When no explicit order is requested, the default ordering depends on whether a filter was provided:
alphabetical
ordermodification
orderparameters
- parameters describing desired order and filter textcallback
- the callback to receive streamed branchesBranchesCommandParameters
,
RefService.getBranches(RepositoryBranchesRequest, PageRequest)
@Nonnull Command<Page<Branch>> branches(@Nonnull BranchesCommandParameters parameters, @Nonnull PageRequest pageRequest)
page
of branches
ordered either alphabetically or by modification and
optionally filtered.
When no explicit order is requested, the default ordering depends on whether a filter was provided:
alphabetical
ordermodification
orderparameters
- parameters describing desired order and filter textpageRequest
- describes the set of branches to returnBranchesCommandParameters
,
RefService.getBranches(RepositoryBranchesRequest, PageRequest)
@Nonnull Command<Void> changes(@Nonnull ChangesCommandParameters parameters, @Nonnull ChangeCallback callback)
Command
which, when executed, will stream changes
describing modifications
made between two revisions, optionally filtered by path.
If no explicit "since"
revision is specified, it defaults to the
parent of the "until"
revision. If the "until" revision specifies
a merge commit (a commit with multiple parents), no changes will be returned.
Note: Some changes
, such as copies
and moves
,
affect more than one path. When filtering by path, if both paths are not available the change's type may not
be correctly detected by some SCMs.
parameters
- parameters describing the revisions to compare and paths to filter bycallback
- the callback to receive streamed commitsChangesCommandParameters
,
CommitService.streamChanges(ChangesRequest, ChangeCallback)
@Nonnull Command<Page<Change>> changes(@Nonnull ChangesCommandParameters parameters, @Nonnull PageRequest pageRequest)
page
of changes
describing the modifications made between two
revisions, optionally filtered by path.
If no explicit "since"
revision is specified, it defaults to the
parent of the "until"
revision. If the "until" revision specifies
a merge commit (a commit with multiple parents), no changes will be returned.
Note: Some changes
, such as copies
and moves
,
affect more than one path. When filtering by path, if both paths are not available the change's type may not
be correctly detected by some SCMs.
parameters
- parameters describing the revisions to compare and paths to filter bypageRequest
- describes the set of changes to returnChangesCommandParameters
,
CommitService.getChanges(ChangesRequest, PageRequest)
@Nonnull Command<Page<Changeset>> changesets(@Nonnull ChangesetsCommandParameters parameters, @Nonnull PageRequest pageRequest)
changesets
given a set of commit IDs
, where each changeset includes the first page of changes
between a requested commit and its first parent.parameters
- parameters describing the changesets to retrievepageRequest
- describes the page of changesets to retrieveCommitService.getChangesets(ChangesetsRequest, PageRequest)
@Nonnull Command<MinimalCommit> commonAncestor(@Nonnull CommonAncestorCommandParameters parameters)
parameters
- parameters describing which common ancestor to retrievenull
.@Nonnull Command<Commit> commit(@Nonnull CommitCommandParameters parameters)
details
for the specified commit.
If a path
is provided, the Commit
returned may not
be for the specified commit
. Instead, that commit is used as
a starting point and details for the first commit in its ancestry which affects that path are returned.
parameters
- parameters describing the commit to retrieve details forCommitCommandParameters
,
CommitService.getCommit(CommitRequest)
@Nonnull Command<Void> commits(@Nonnull CommitsCommandParameters parameters, @Nonnull CommitCallback callback)
parameters
to the provided callback.parameters
- parameters describing the commits to retrievecallback
- a callback to receive the streamed commitsUnsupportedOperationException
- if a secondary
repository
is provided an cross-
repository
operations are not supportedCommitsCommandParameters
,
CommitService.streamCommits(BulkCommitsRequest, BulkCommitCallback)
,
CommitService.streamCommits(CommitsRequest, CommitCallback)
,
CommitService.streamCommitsBetween(CommitsBetweenRequest, CommitCallback)
@Nonnull Command<Page<Commit>> commits(@Nonnull CommitsCommandParameters parameters, @Nonnull PageRequest pageRequest)
page
of commits matching the specified parameters
.
If the SCM supports
cross-repository
operations, a secondary repository
may be provided. Otherwise, it must be omitted or match the target repository.
parameters
- parameters describing which commits to retrievepageRequest
- describes the set of commits to returnUnsupportedOperationException
- if a secondary
repository
was provided and the underlying SCM does not support
cross-repository
operationsCommitsCommandParameters
,
CommitService.getCommits(CommitsRequest, PageRequest)
,
CommitService.getCommitsBetween(CommitsBetweenRequest, PageRequest)
@Nonnull Command<Branch> defaultBranch()
The returned command may throw NoDefaultBranchException
, when executed, if the specified repository
does not have a resolvable default branch. This might happen, for example, on a new repository with no commits,
or if the only commits to a repository have been to a branch other than the default branch.
NoDefaultBranchException
- if the repository does not have a resolvable default branchRefService.getDefaultBranch(Repository)
@Nonnull Command<Void> diff(@Nonnull DiffCommandParameters parameters, @Nonnull DiffContentCallback callback)
commits
.parameters
- parameters describing the diff to streamcallback
- the callback to receive the streamed diffDiffCommandParameters
,
CommitService.streamDiff(DiffRequest, DiffContentCallback)
@Nonnull Command<Void> diff(@Nonnull DiffCommandParameters parameters, @Nonnull TypeAwareOutputSupplier outputSupplier)
commits
.parameters
- parameters describing the diff to streamoutputSupplier
- a supplier which will provide an output streamDiffCommandParameters
,
CommitService.streamDiff(DiffRequest, TypeAwareOutputSupplier)
@Nonnull Command<Void> directory(@Nonnull DirectoryCommandParameters parameters, @Nonnull ContentTreeCallback callback, @Nonnull PageRequest pageRequest)
tree nodes
(files, subdirectories and submodules) in the specified
directory
.parameters
- parameters providing the directory to stream and the revision to stream it forcallback
- the callback to receive the streamed nodespageRequest
- describes the set of nodes to streamDirectoryCommandParameters
,
ContentService.streamDirectory(Repository, String, String, boolean, ContentTreeCallback, PageRequest)
@Nonnull Command<Void> file(@Nonnull FileCommandParameters parameters, @Nonnull FileContentCallback callback, @Nonnull PageRequest pageRequest)
specified file
.parameters
- parameters describing the file to stream and the revision to stream it forcallback
- the callback to receive the streamed contentpageRequest
- describes the set of lines in the file to streamFileCommandParameters
,
ContentService.streamFile(Repository, String, String, PageRequest, boolean, FileContentCallback)
@Deprecated @Nonnull Command<Void> heads(@Nonnull RefCallback callback)
refs(com.atlassian.bitbucket.scm.RefsCommandParameters, com.atlassian.bitbucket.repository.RefCallback)
instead.refs
for all of the heads in the repository. The exact definition of "heads" is an
SCM-specific detail, but it will generally include all branches and tags in the repository.
Note: This method is not exposed via the service API. It is only available directly on the SCM API.
callback
- the ref callback that will be called for each head@Nonnull Command<Void> rawFile(@Nonnull RawFileCommandParameters parameters, @Nonnull TypeAwareOutputSupplier outputSupplier)
OutputStream
from the provided supplier,
and the file's raw content will then be written to the returned stream.parameters
- parameters used to specify the path and version of the file to streamoutputSupplier
- the supplier which, when given a content type, will provide an output streamRawFileCommandParameters
,
ContentService.streamFile(Repository, String, String, TypeAwareOutputSupplier)
@Nonnull Command<Void> refs(@Nonnull RefsCommandParameters parameters, @Nonnull RefCallback callback)
refs
in the repository. The exact specification for what "refs" includes
is an SCM-specific detail, but it will generally include all branches and tags in the repository.
Note: This method is not exposed via the service API. It is only available directly on the SCM API.
parameters
- parameters to allow evolving the SPI over timecallback
- the ref callback that will be called for each ref@Nonnull Command<RepositorySize> repositorySize(@Nonnull Repository repository, @Nonnull RepositorySizeCommandParameters parameters)
size
for the specified repository.
Note: Calculating the size can be an expensive operation. The returned value may be a best effort estimation of the repository size.
repository
- the repository for which size needs to be calculated.parameters
- the additional parameters (if any) for the size calculation.size
of the given repository.RepositorySize
@Nonnull Command<Map<String,String>> resolveCommits(@Nonnull ResolveCommitsCommandParameters parameters)
parameters
to the referenced commit ID. Revisions specified on
parameters
can be anything that the SCM can resolve to commit IDs, including branch and tag names.
The command returns a map
from the provided revision to the resolved commit ID. If a revision could
not be resolved, no value is returned in the map.
parameters
- parameters describing the revisions to resolve@Nonnull Command<Ref> resolveRef(@Nonnull ResolveRefCommandParameters parameters)
refId
, which may be a:
If the refId
should be resolved to a specific type, that type
should be set to allow the SCM to restrict its search.
If a hash is provided, it will be resolved to the branch or tag it is the tip of. If it is not the tip of
any branch or tag, it will resolve to null
. If a type
was specified, the hash will only be resolved against that type.
When a hash is provided and resolves to multiple branches, tags or a combination of both, it is left to the SCM implementation to determine the result. SCM implementors are encouraged to choose a tag over a branch, and to return the "first" branch or tag, ordered alphabetically, but this is not enforced.
parameters
- parameters describing the ref to resolveResolveRefCommandParameters
,
RefService.resolveRef(ResolveRefRequest)
@Nonnull Command<Map<String,Ref>> resolveRefs(@Nonnull ResolveRefsCommandParameters parameters)
parameters
, which may be one of
Callers can specify on the parameters
whether a provided ID is expected to resolve to a
branch
, tag
,
or a ref of unknown type
.
If hashes are provided, they will be resolved to branches or tags they are the tip of. If they are not the tip of
any branch or tag, they will resolve to null
and will not be included in the returned map.
When a hash is provided and resolves to multiple branches, tags or a combination of both, it is left to the SCM implementation to determine the result. SCM implementors are encouraged to choose a tag over a branch, and to return the "first" branch or tag, ordered alphabetically, but this is not enforced.
parameters
- describes the ref IDs to resolveResolveRefsCommandParameters
,
RefService.resolveRefs(ResolveRefsRequest)
@Nonnull Command<Long> size(@Nonnull SizeCommandParameters parameters)
null
.parameters
- parameters describing the commit and path to retrieve the size forSizeCommandParameters
,
ContentService.getSize(Repository, String, String)
@Nonnull Command<Void> tags(@Nonnull TagsCommandParameters parameters, @Nonnull TagCallback callback)
tags
ordered either alphabetically or by modification and optionally filtered.
When no explicit order is requested, the default ordering depends on whether a filter was provided:
alphabetical
ordermodification
orderparameters
- parameters describing desired order and filter textcallback
- a callback to receive the streamed commitsTagsCommandParameters
,
RefService.streamTags(RepositoryTagsRequest, TagCallback)
@Nonnull Command<Page<Tag>> tags(@Nonnull TagsCommandParameters parameters, @Nonnull PageRequest pageRequest)
page
of tags
ordered either alphabetically or by modification and
optionally filtered.
When no explicit order is requested, the default ordering depends on whether a filter was provided:
alphabetical
ordermodification
orderparameters
- parameters describing desired order and filter textpageRequest
- describes the set of tags to returnTagsCommandParameters
,
RefService.getTags(RepositoryTagsRequest, PageRequest)
@Nonnull Command<Void> traverseCommits(@Nonnull TraversalCallback callback)
callback
- the callback to receive the streamed commitsCommitService.traverse(TraversalRequest, TraversalCallback)
@Nonnull Command<ContentTreeNode.Type> type(@Nonnull TypeCommandParameters parameters)
type
for the specified path
at the requested revision, if the path is present. Note that the same path might have different types between
revisions but the root entry ("", "\" or "/") will always be a directory
.parameters
- parameters describing the path to check, and the revision to check it forTypeCommandParameters
,
ContentService.getType(Repository, String, String)
Copyright © 2022 Atlassian. All rights reserved.