Use Tree Navigation
public interface

PluginExtendedCommandFactory

com.atlassian.bitbucket.scm.PluginExtendedCommandFactory

Class Overview

Provides backing functionality for the ScmExtendedCommandFactory.

This interface is intended to be implemented by plugin developers. Functionality provided by this interface is intended to be consumed using the ScmExtendedCommandFactory exposed by the ScmService. Only the system should ever deal with this interface directly.

This interface describes optional commands which an SCM implementor may provide to extend the functionality of their SCM. Some features, like auto-merging between release branches and creating forks, rely on these optional commands. If the SCM does not implement them, the features which depend on them will be disabled.

Summary

Public Methods
@Nullable Command<Void> archive(Repository repository, ArchiveCommandParameters parameters, TypeAwareOutputSupplier outputSupplier)
Streams an archive of the repository at the specified commit, in the requested format.
@Nullable Command<Commit> editFile(Repository repository, EditFileCommandParameters parameters)
Adds a new file or updates the content of an existing file as described in the parameters.
@Nullable Command<Void> fork(Repository repository, ForkCommandParameters parameters)
Creates a fork of repository, stored in the specified fork.
@Nullable Command<Void> lastModified(Repository repository, LastModifiedCommandParameters parameters, LastModifiedCallback callback)
Streams the latest commit to modify each file in the specified LastModifiedCommandParameters#getPath() path, using the provided LastModifiedCommandParameters#getCommitId() commit as the starting point for the traversal.
@Nullable Command<Branch> merge(Repository repository, MergeCommandParameters parameters)
Merges the specified {@link MergeCommandParameters#getFromCommitId() fromCommitId into the specified {@link MergeCommandParameters#getToBranch() toBranch.
@Nullable Command<Void> signedObjects(Repository repository, SignedObjectsParameters parameters, SignedObjectCallback callback)
Retrieves requested objects and if the object is signed, provides the signature and signed content to the callback.
@Nullable Command<Void> updateDefaultBranch(Repository repository, UpdateDefaultBranchCommandParameters parameters)
Sets the default branch for the repository to the UpdateDefaultBranchCommandParameters#getBranchId() named branch.

Public Methods

@Nullable public Command<Void> archive (Repository repository, ArchiveCommandParameters parameters, TypeAwareOutputSupplier outputSupplier)

Streams an archive of the repository at the specified commit, in the requested format. If paths are supplied, the streamed archive should be filtered to only include files from the specified paths.

Implementors: This operation is optional. Implementations which do not support streaming archives should return null and omit the ScmFeature#ARCHIVE ARCHIVE feature. For simplicity, this factory provides a default implementation which returns null. SCMs which implement this command are required to support streaming archives in all of the ArchiveFormat standard formats. If the underlying SCM does not innately support one or more of the standard formats, the implementation is required to augment the SCM and support them manually. If such augmentation is not possible, the SCM must not implement this command.

Parameters
repository the repository to stream the archive from
parameters parameters describing the commit to archive and the format to produce the archive in
outputSupplier a supplier which, when given the archive content type, will provide an output stream
Returns
  • a command to stream an archive of the repository, or null if archiving is not supported
See Also
  • ScmFeature#ARCHIVE

@Nullable public Command<Commit> editFile (Repository repository, EditFileCommandParameters parameters)

Adds a new file or updates the content of an existing file as described in the parameters.

Implementors: This feature is optional. Implementations which do not support updating the content of a file should return null and omit the ScmFeature#EDIT_FILE EDIT_FILE feature. For simplicity, this factory provides a default implementation which returns null.

Parameters
repository the repository in
parameters parameters describing the file path, file content, branch and the previous contentId of the file.
Returns
  • a command to edit a file, or null if editing file is not supported
See Also
  • ScmFeature#EDIT_FILE

@Nullable public Command<Void> fork (Repository repository, ForkCommandParameters parameters)

Creates a fork of repository, stored in the specified fork. Similar to creating a repository, the specified fork must not exist on disk when this command is called. It is expected that the SCM will create it with contents based on repository, which becomes the fork's origin.

Implementors: This operation is optional. Implementations which do not support forking should return null and omit the ScmFeature#FORK FORK feature. For simplicity, this factory provides a default implementation which returns null.

Parameters
repository the fork repository
parameters parameters describing the origin repository to be forked
Returns
  • a command to create a fork of a repository, or null if forking is not supported
See Also
  • ScmFeature#FORK

@Nullable public Command<Void> lastModified (Repository repository, LastModifiedCommandParameters parameters, LastModifiedCallback callback)

Streams the latest commit to modify each file in the specified LastModifiedCommandParameters#getPath() path, using the provided LastModifiedCommandParameters#getCommitId() commit as the starting point for the traversal.

Implementors: This feature is optional. Implementations which do not support updating the default branch should return null and omit the ScmFeature#LAST_MODIFIED LAST_MODIFIED feature. For simplicity, this factory provides a default implementation which returns null.

Parameters
repository the repository containing the starting commit
parameters parameters describing the path to stream modifications for, and the starting commit for the traversal
callback a callback to receive the latest commit for files in the specified path
Returns
  • a command to stream the latest commit to modify each files in the specified path, or null if streaming last modifications is not supported
See Also
  • ScmFeature#LAST_MODIFIED

@Nullable public Command<Branch> merge (Repository repository, MergeCommandParameters parameters)

Merges the specified {@link MergeCommandParameters#getFromCommitId() fromCommitId into the specified {@link MergeCommandParameters#getToBranch() toBranch.

SCMs are required to support the following values for fromCommitId:

  • A 40-byte hash (Note: Short hashes are not supported)
  • A fully-qualified branch name
  • A short branch name
toBranch, as the parameter name suggests, must be a branch name, either fully qualified or short, and the SCM should validate that that is the case; using a hash (full or short) is not supported.

Implementors: This feature is optional. Implementations which do not support merging should return null and omit the ScmFeature#MERGE MERGE feature. For simplicity, this factory provides a default implementation which returns null. Additionally, SCMs which support merging are not required to support MergeCommandParameters#getFromRepository() different source repositories unless they offer ScmFeature#CROSS_REPOSITORY cross-repository support. If a different from source repository is provided and cross-repository operations are not supported, implementations should throw an UnsupportedOperationException.

Parameters
repository the repository containing both the source commit and the target branch
parameters parameters describing the branches to merge
Returns
  • a command which, when executed, will merge the specified branch into the target branch, or null if merging is not supported
Throws
UnsupportedOperationException if a MergeCommandParameters#getFromRepository() source repository is specified and ScmFeature#CROSS_REPOSITORY cross-repository operations are not supported
See Also
  • ScmFeature#CROSS_REPOSITORY
  • ScmFeature#MERGE

@Nullable public Command<Void> signedObjects (Repository repository, SignedObjectsParameters parameters, SignedObjectCallback callback)

Retrieves requested objects and if the object is signed, provides the signature and signed content to the callback.

Parameters
repository the repository containing the requested objects
parameters describes which objects to retrieve
callback callback to receive the requested objects
Returns
  • a command which, when executed, will retrieve the requested objects and provide them to the provided callback
Throws
if the underlying SCM does not support retrieving signing objects
See Also
  • ScmFeature#SIGNED_OBJECTS

@Nullable public Command<Void> updateDefaultBranch (Repository repository, UpdateDefaultBranchCommandParameters parameters)

Sets the default branch for the repository to the UpdateDefaultBranchCommandParameters#getBranchId() named branch.

Implementors: This feature is optional. Implementations which do not support updating the default branch should return null and omit the ScmFeature#UPDATE_DEFAULT_BRANCH UPDATE_DEFAULT_BRANCH feature. For simplicity, this factory provides a default implementation which returns null.

Parameters
repository the repository whose default branch should be updated
parameters parameters describing the new branch to set as the default
Returns
  • a command to update the default branch, or null if updating the default branch is not supported
See Also
  • ScmFeature#UPDATE_DEFAULT_BRANCH
Feedback?
View cookie preferences