public interface ScmService
Modifier and Type | Method and Description |
---|---|
ScmCommandBuilder<?> |
createBuilder(Repository repository)
Creates a
ScmCommandBuilder which can be used to construct free-form commands to interact directly with
the underlying SCM implementation and perform custom functions on repositories. |
Set<AvailableScm> |
getAvailable()
Retrieves the set of
available SCMs . |
ScmBulkContentCommandFactory |
getBulkContentCommandFactory(Repository repository)
Retrieves an
ScmBulkContentCommandFactory , used to create commands for retrieving
bulk data from the SCM. |
ScmCommandFactory |
getCommandFactory(Repository repository)
Retrieves an
ScmCommandFactory , used to create commands for performing standard SCM
operations such as retrieving commits and viewing diffs. |
ScmCompareCommandFactory |
getCompareCommandFactory(CompareRequest compareRequest)
Retrieves an
ScmCompareCommandFactory , used to create commands tailored for
comparing refs. |
ScmExtendedCommandFactory |
getExtendedCommandFactory(Repository repository)
Retrieves an
ScmExtendedCommandFactory , used to create commands for extended SCM functionality. |
ScmHookHandlerFactory |
getHookHandlerFactory(Repository repository)
Retrieves a
ScmHookHandlerFactory , used to create hook
handlers that manage scm hook callbacks. |
ScmMirrorCommandFactory |
getMirrorCommandFactory(Repository repository)
Retrieves an
ScmMirrorCommandFactory , used to create commands tailored for mirroring
repositories. |
ScmPullRequestCommandFactory |
getPullRequestCommandFactory(PullRequest pullRequest)
Retrieves an
ScmPullRequestCommandFactory , used to create commands tailored for use
operating on pull requests. |
ScmRefCommandFactory |
getRefCommandFactory(Repository repository)
|
String |
getScmName(Repository repository)
Retrieves the name for the
SCM which powers the specified repository. |
long |
getSize(Repository repository)
Calculates the size (in bytes) for the specified repository.
|
boolean |
isEmpty(Repository repository)
Tests whether the specified
Repository is empty. |
boolean |
isSupported(Repository repository,
ScmFeature feature)
Tests whether the SCM for the specified
Repository supports the requested feature . |
boolean |
isSupported(String scmId,
ScmFeature feature)
Tests whether the specified SCM supports the requested
feature . |
@Nonnull ScmCommandBuilder<?> createBuilder(@Nonnull Repository repository)
ScmCommandBuilder
which can be used to construct free-form commands to interact directly with
the underlying SCM implementation and perform custom functions on repositories.
Command builders are provided as a very powerful extension point for plugin developers, allowing them to create new functionality that uses commands the application does not, or uses them in different ways. However, plugin developers should be aware that:
The created ScmCommandBuilder
will use the provided repository's
directory as its
initial working directory. After the builder has been created, it is possible to change the working directory
on the instance, before commands are constructed.
Note: Per the contract of the ScmCommandBuilder
API, the returned builder is not thread-safe. If
multiple threads require use of a builder, each thread should always create its own builder.
repository
- the repository to create a builder for, used to determine the correct SCM implementation to
use and to provide the initial working directory for built commandsFeatureUnsupportedScmException
- if the target SCM does not support command buildersUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmCommandBuilder
@Nonnull Set<AvailableScm> getAvailable()
available SCMs
. SCMs that are installed but not in a good state will
not be included in the returned set. The returned set will never be empty; the system requires at least one
available SCM or it will be locked out on startup.
Each SCM implementation is different, but examples of reasons why an installed SCM might not be available include:
git
or hg
, may not be installed@Nonnull ScmBulkContentCommandFactory getBulkContentCommandFactory(@Nonnull Repository repository)
ScmBulkContentCommandFactory
, used to create commands
for retrieving
bulk data from the SCM.
SCMs are not required to implement support for bulk commands. However, an SCM which does support them may be capable of significantly increased efficiency when performing large operations.
Note: Since 5.8, this method will no longer throw FeatureUnsupportedScmException
. Instead, an
exception will be thrown when trying to create a specific command
, if the SCM doesn't support
it. Prior to 5.8, since ScmBulkContentCommandFactory
only supported a single command, the associated
feature could be eagerly checked when retrieving the factory. Now that it offers multiple commands, features
must be checked when commands are requested instead.
repository
- the repository to retrieve a command factory for, used to determine the correct SCM
implementation to useUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmBulkContentCommandFactory
@Nonnull ScmCommandFactory getCommandFactory(@Nonnull Repository repository)
ScmCommandFactory
, used to create commands
for performing standard SCM
operations such as retrieving commits and viewing diffs.repository
- the repository to retrieve a command factory for, used to determine the correct SCM
implementation to use and to specify the repository created commands operate onUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmCommandFactory
@Nonnull ScmCompareCommandFactory getCompareCommandFactory(@Nonnull CompareRequest compareRequest)
ScmCompareCommandFactory
, used to create commands
tailored for
comparing refs.
This differs from the normal getCommandFactory(Repository)
in that any comparison will be rooted
into the closest common ancestor between the refs. In other words, any comparison will be one sided
and only includes the changes the source ref
would bring to the
target ref
if they were merged.
compareRequest
- the request describing the refs to compareFeatureUnsupportedScmException
- if the target SCM does not support comapring refs using their closest common ancestorUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmCommandFactory
,
ScmPullRequestCommandFactory
@Nonnull ScmExtendedCommandFactory getExtendedCommandFactory(@Nonnull Repository repository)
ScmExtendedCommandFactory
, used to create commands for extended SCM functionality.
SCMs are not required to implement support for any of the commands on this factory, and implementing
support for any one command does not require supporting any other command. Attempting to use a command which
has not been implemented by the SCM will trigger a FeatureUnsupportedScmException
. Callers should
check support
prior to using any command on this factory. Each
command is associated with its own feature
. The mapping between features and commands is
documented on the ScmExtendedCommandFactory
interface.
Note: Unlike other command factories, like the pull request
command factory
, calling this method will never throw a FeatureUnsupportedScmException
.
Feature support is checked against each method on the returned factory, not against retrieving the factory
itself.
repository
- the repository to retrieve a command factory for, used to determine the correct SCM
implementation to useUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmExtendedCommandFactory
@Nonnull ScmHookHandlerFactory getHookHandlerFactory(@Nonnull Repository repository)
ScmHookHandlerFactory
, used to create hook
handlers
that manage scm hook callbacks.
SCMs are not required to implement support for SCM hooks.
repository
- the repository for which to retrieve the ScmScmHookHandlerFactory
used to create hook handlers@Nonnull ScmMirrorCommandFactory getMirrorCommandFactory(@Nonnull Repository repository)
ScmMirrorCommandFactory
, used to create commands
tailored for mirroring
repositories.
SCMs are not required to implement support for mirroring.
repository
- the repository to retrieve a command factory for, used to determine the correct SCM
implementation to useFeatureUnsupportedScmException
- if the target SCM does not support mirroringUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmMirrorCommandFactory
@Nonnull ScmPullRequestCommandFactory getPullRequestCommandFactory(@Nonnull PullRequest pullRequest)
ScmPullRequestCommandFactory
, used to create commands
tailored for use
operating on pull requests.
SCMs are not required to implement support for pull requests.
pullRequest
- the pull request to retrieve a command factory for, used to determine the correct SCM
implementation to use and to specify the pull request created commands operate onFeatureUnsupportedScmException
- if the target SCM does not support pull requestsUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmPullRequestCommandFactory
@Nonnull ScmRefCommandFactory getRefCommandFactory(@Nonnull Repository repository)
ScmRefCommandFactory
, used to create commands
tailored for creating
branches
and tags
.
SCMs are not required to implement support for creating branches or tags.
repository
- repository to get refs forFeatureUnsupportedScmException
- if the target SCM does not support mutable refsUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledScmFeature.REFS
@Nonnull String getScmName(@Nonnull Repository repository)
SCM
which powers the specified repository.repository
- the repository to retrieve the SCM name forUnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledlong getSize(@Nonnull Repository repository)
Repository
does not exist,
its size is always 0
.
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 whose size should be calculatedboolean isEmpty(@Nonnull Repository repository)
Repository
is empty.repository
- the repository to checktrue
if the repository is empty; otherwise, false
UnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledboolean isSupported(@Nonnull Repository repository, @Nonnull ScmFeature feature)
Repository
supports the requested feature
.repository
- the repository to checkfeature
- the feature to testtrue
if the SCM for the specified repository supports the requested feature
;
otherwise, false
UnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledboolean isSupported(@Nonnull String scmId, @Nonnull ScmFeature feature)
feature
.scmId
- identifier of the SCM to checkfeature
- the feature to testtrue
if the SCM for the specified repository supports the requested feature
;
otherwise, false
UnavailableScmException
- if the target SCM is installed and enabled but unavailable for some reasonUnsupportedScmException
- if the target SCM has been uninstalled or disabledCopyright © 2020 Atlassian. All rights reserved.