Package sonia.scm.repository.api
Class ModifyCommandBuilder
java.lang.Object
sonia.scm.repository.api.ModifyCommandBuilder
Use this
ModifyCommandBuilder
to make file changes to the head of a branch. You can
- create new files (
createFile(String)
(with the option to overwrite a file, if it already exists; by default aAlreadyExistsException
will be thrown) - modify existing files (
modifyFile(String)
- delete existing files (
deleteFile(String)
execute()
.
Example:
commandBuilder .setBranch("feature/branch") .setCommitMessage("make some changes") .setAuthor(new Person()) .createFile("file/to/create").withData(inputStream) .deleteFile("old/file/to/delete") .execute();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
class
class
class
-
Method Summary
Modifier and TypeMethodDescriptioncreateFile
(String path) Create a new file.deleteFile
(String path) Delete an existing file.deleteFile
(String path, boolean recursive) Disables adding a verifiable signature to the modification commit.execute()
Apply the changes and create a new commit with the given message and author.boolean
isEmpty()
modifyFile
(String path) Modify an existing file.Move existing directories or files.Set the author for the new commit.Set the branch the changes should be made upon.setCommitMessage
(String message) Set the commit message for the new commit.setExpectedRevision
(String expectedRevision) Set the expected revision of the branch, before the changes are applied.useDefaultPath
(boolean useDefaultPath)
-
Method Details
-
createFile
Create a new file. The content of the file will be specified in a subsequent call toModifyCommandBuilder.ContentLoader.withData(ByteSource)
orModifyCommandBuilder.ContentLoader.withData(InputStream)
. By default, anAlreadyExistsException
will be thrown, when there already exists a file with the given path. You can disable this settingModifyCommandBuilder.WithOverwriteFlagContentLoader.setOverwrite(boolean)
totrue
.- Parameters:
path
- The path and the name of the file that should be created.- Returns:
- The loader to specify the content of the new file.
-
modifyFile
Modify an existing file. The new content of the file will be specified in a subsequent call toModifyCommandBuilder.ContentLoader.withData(ByteSource)
orModifyCommandBuilder.ContentLoader.withData(InputStream)
.- Parameters:
path
- The path and the name of the file that should be modified.- Returns:
- The loader to specify the new content of the file.
-
move
Move existing directories or files.- Parameters:
fromPath
- The source file or directory.- Returns:
- A sub builder to specify the target and further options for the move.
- Since:
- 2.28.0
-
deleteFile
Delete an existing file.- Parameters:
path
- The path and the name of the file that should be deleted.- Returns:
- This builder instance.
-
deleteFile
-
execute
Apply the changes and create a new commit with the given message and author.- Returns:
- The revision of the new commit.
-
isEmpty
public boolean isEmpty() -
setCommitMessage
Set the commit message for the new commit.- Returns:
- This builder instance.
-
setAuthor
Set the author for the new commit.- Returns:
- This builder instance.
-
setBranch
Set the branch the changes should be made upon.- Returns:
- This builder instance.
-
disableSigning
Disables adding a verifiable signature to the modification commit.- Returns:
- This builder instance.
- Since:
- 2.4.0
-
setExpectedRevision
Set the expected revision of the branch, before the changes are applied. If the branch does not have the expected revision, a concurrent modification exception will be thrown when the command is executed and no changes will be applied.- Returns:
- This builder instance.
-
useDefaultPath
-