public interface

ScmExtendedCommandFactory

com.atlassian.bitbucket.scm.ScmExtendedCommandFactory

Class Overview

Creates commands which provide optional SCM functionality such as merging two branches or updating the default branch. Each method accepts a set of CommandParameters which are used to control the command's behaviour and output.

Each command on this factory has an associated SCM feature. Prior to using any of these commands, callers should check if the feature is supported. Failure to do so will result in FeatureUnsupportedScmExceptions when requesting unsupported commands.

Summary

Public Methods
@Nonnull Command<Commit> editFile(EditFileCommandParameters parameters)
Adds a new file or updates the content of an existing file as described in the parameters.
@Nonnull Command<Void> lastModified(LastModifiedCommandParameters parameters, LastModifiedCallback callback)
Streams the latest commit to modify each file in the specified path, using the provided commit as the starting point for the traversal.
@Nonnull Command<Branch> merge(MergeCommandParameters parameters)
Merges the specified fromCommitId into the specified toBranch.
@Nonnull Command<Void> updateDefaultBranch(UpdateDefaultBranchCommandParameters parameters)
Sets the default branch for the repository to the specified branch.

Public Methods

@Nonnull public Command<Commit> editFile (EditFileCommandParameters parameters)

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

This operation is optional and may not be supported by all SCM implementations. Such implementations will throw an FeatureUnsupportedScmException.

Parameters
parameters parameters describing the file to be edited
Returns
  • a command which, when executed, will edit the content of a file
Throws
FeatureUnsupportedScmException if the underlying SCM does not support editing a file.

@Nonnull public Command<Void> lastModified (LastModifiedCommandParameters parameters, LastModifiedCallback callback)

Streams the latest commit to modify each file in the specified path, using the provided commit as the starting point for the traversal.

This operation is optional and may not be supported by all SCM implementations. Calling this method on an SCM which does not support it will result in a FeatureUnsupportedScmException.

Parameters
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 which, when executed, will stream the latest commit to modify each file in the specified path
Throws
FeatureUnsupportedScmException if the underlying SCM does not support streaming modifications

@Nonnull public Command<Branch> merge (MergeCommandParameters parameters)

Merges the specified fromCommitId into the specified toBranch.

The provided fromCommitId may be:

  • A 40-byte hash (Note: Short hashes are not supported)
  • A fully-qualified branch name
  • A short branch name
The provided 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.

If the SCM supports cross-repository merges, a different from repository may be provided. Otherwise, it must be omitted or match the target repository.

This operation is optional and may not be supported by all SCM implementations. Calling this method on an SCM which does not support it will result in a FeatureUnsupportedScmException.

Note: This method is not exposed via the service API. It is only available directly on the SCM API.

Parameters
parameters parameters describing the branches to merge
Returns
  • a command which, when executed, will merge the specified commit into the target branch
Throws
FeatureUnsupportedScmException if the underlying SCM does not support merging branches, or if a cross-repository merge was requested and the SCM doesn't support cross-repository merges
See Also

@Nonnull public Command<Void> updateDefaultBranch (UpdateDefaultBranchCommandParameters parameters)

Sets the default branch for the repository to the specified branch.

This operation is optional and may not be supported by all SCM implementations. Such implementations will throw an FeatureUnsupportedScmException.

Parameters
parameters parameters describing the branch to make the default
Returns
  • a command which, when executed, will update the repository's default branch
Throws
FeatureUnsupportedScmException if the underlying SCM does not support setting the default branch