com.atlassian.stash.scm.PluginCommandFactory |
Provides backing functionality for the ScmCommandFactory.
This interface is intended to be implemented by plugin developers. Functionality provided by this interface is intended to be consumed using the ScmCommandFactory exposed by the ScmService. Only the system should ever deal with this interface directly. All command types on this interface are required to have a working implementation, as this factory describes the basic SCM commands used by the system to provide day-to-day functionality.SCM
implementations may
also provide additional functionality to allow the system to offer enhanced features, such as pull requests. Such
functionality is exposed by other interfaces.
For SCMs which support additional functionality, or have custom Command types, it is encouraged for them to
provide a sub-interface extending from this one exposing that functionality. For example:
//Extends Command to allow canceling it after it has been called and checking whether it's been canceled.
public interface CancelableCommand<T> extends Command<T> {
void cancel();
boolean isCanceled();
}
//Overrides methods on the PluginCommandFactory
interface using covariant return types to return the
//enhanced CancelableCommand
instead of simple Command
public interface MyScmCommandFactory extends PluginCommandFactory {
@Nonnull
@Override
CancelableCommand<List<Blame>> blame(@Nonnull Repository repository,
@Nonnull BlameCommandParameters parameters,
@Nonnull PageRequest pageRequest);
//Overrides for other methods as appropriate
}
The SCM plugin would then expose the class implementing their custom MyScmCommandFactory
using a
component
directive:
<!-- Note: This should be in the SCM provider's atlassian-plugin.xml -->
<component key="myScmCommandFactory"
class="com.example.DefaultMyScmCommandFactory"
public="true">
<interface>com.example.MyScmCommandFactory</interface>
</component>
The public="true"
allows other plugins to import the component. This approach allows other plugin developers
to import the SCM plugin's command factory and leverage its enhanced functionality with a component-import
directive:
<!-- Note: This should be in the SCM consumer's atlassian-plugin.xml -->
<component-import key="myScmCommandFactory"
interface="com.example.MyScmCommandFactory"/>
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Retrieves all descendant commits of any of the refs (commitHash, tagname, branchname) in
refs . | |||||||||||
Creates and initializes the repository on disk
| |||||||||||
Retrieves a Command which will resolve the default branch for the specified repository when executed.
| |||||||||||
Deletes the repository, allowing the underlying SCM to carry out any special processing necessary to clean up
repository storage.
| |||||||||||
This method is deprecated.
in 2.1 for removal in 3.0. Deleting branches is SCM-specific.
| |||||||||||
Creates a fork of repository
parent | |||||||||||
Creates a command that, when executed, will merge the specified
fromChangesetId into the specified
toBranch . | |||||||||||
Returns a com.atlassian.stash.scm.Command that will, when executed, retrieve the content of the given file, try to detect its
mime-type, obtain an java.io.OutputStream from the given com.atlassian.stash.io.TypeAwareOutputSupplier and copy all the content
into it.
| |||||||||||
This method is deprecated.
in 2.4 for removal in 3.0, with no replacement. If reparenting is necessary, it should be handled
automatically during
repository deletion .
| |||||||||||
Traverse the commit graph in topological order
| |||||||||||
Returns a com.atlassian.stash.scm.Command which, when executed, will set the default branch for the specified repository to the
named branch.
|
Retrieves all descendant commits of any of the refs (commitHash, tagname, branchname) in refs
.
repository | the repository to query |
---|---|
parameters | previous heads |
callback | the changeset callback that will be called for each of the matching commits. |
Creates and initializes the repository on disk
repository | the repository to create |
---|
Retrieves a Command which will resolve the default branch for the specified repository when executed.
The returned command may throw com.atlassian.stash.exception.NoDefaultBranchException 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.repository | the repository to retrieve the default branch for |
---|
NoDefaultBranchException | if the repository does not have a resolvable default branch. |
---|
Deletes the repository, allowing the underlying SCM to carry out any special processing necessary to clean up repository storage.
Note: By the time this method is called, the repository has already been deleted from the database, and the associated database transaction has been committed. Warning: This method is irreversible. It should never be called by a plugin. It is intended solely for use by the system.repository | the repository to delete |
---|---|
parameters | additional parameters, such as IDs for forks of the deleted repository |
This method is deprecated.
in 2.1 for removal in 3.0. Deleting branches is SCM-specific.
Returns a Command which, when executed, will delete the specified branch
.
branch | to be deleted |
---|
Creates a fork of repository parent
parent | the repository to be forked |
---|---|
fork | the fork |
Creates a command that, when executed, will merge the specified fromChangesetId
into the specified
toBranch
.
fromChangesetId
may be:
toBranch
, as the parameter name suggests, must be a branch name, either fully
qualified or short; using a hash (full or short) is not supported.repository | the repository containing both the source changeset and the target branch |
---|
Returns a com.atlassian.stash.scm.Command that will, when executed, retrieve the content of the given file, try to detect its mime-type, obtain an java.io.OutputStream from the given com.atlassian.stash.io.TypeAwareOutputSupplier and copy all the content into it.
repository | the repository that contains the file |
---|---|
parameters | parameters used to specify the path and version of the file to stream |
outputSupplier | the supplier which, when given a content type, will provide an output stream |
This method is deprecated.
in 2.4 for removal in 3.0, with no replacement. If reparenting is necessary, it should be handled
automatically during repository deletion
.
Returns a Command that will, when executed, update the origin
for the
specified repository
to reference the newParent
.
newParent | the new parent which should be used as the repository's origin |
---|
Traverse the commit graph in topological order
repository | the repository to traverse |
---|---|
callback | the callback for traversing the commit graph |
Returns a com.atlassian.stash.scm.Command which, when executed, will set the default branch for the specified repository to the
named branch. This operation may not be supported by all SCM implementations. Such implementations should throw
an UnsupportedOperationException
.
repository | the repository whose default branch should be updated |
---|---|
branchName | the branch to make the default |
IllegalArgumentException | Thrown if the provided branchName is null or blank. |
---|---|
UnsupportedOperationException | Thrown if the underlying SCM does not support setting the default branch. |