public interface

CommitService

implements CommonHistoryService
com.atlassian.stash.commit.CommitService

Summary

Public Methods
@Nonnull Comment addComment(Repository repository, String commitId, String commentText)
Adds a general comment on the specified commit in the specified repository.
@Nonnull Comment addDiffComment(Repository repository, String commitId, AddDiffCommentRequest request)
Adds a line comment to a commit diff in the specified repository.
@Nonnull Comment addFileComment(Repository repository, String commitId, AddFileCommentRequest request)
Adds a file-level comment to a commit diff in the specified repository.
@Nonnull Comment addReply(Repository repository, String commitId, long commentId, String commentText)
Adds a reply to a comment.
boolean deleteComment(Repository repository, String commitId, long commentId, int commentVersion)
Deletes a comment.
@Nonnull Iterable<DiffCommentAnchor> findCommentAnchors(Repository repository, String commitId, String parentId, String path)
Finds anchors for file and line comments on the specified path in the commit.
@Nonnull Comment getComment(Repository repository, String commitId, long commentId)
Retrieves a the specified comment by its ID.
void streamDiff(DiffRequest request, DiffContentCallback callback)
Streams diff output for the specified paths at the specified changeset.
void traverse(TraversalRequest request, TraversalCallback callback)
Traverse the graph of commits in topological order, optionally supplying included commits to start from and excluded commits to ignore.
boolean unwatch(Repository repository, String commitId)
Removes the current user as a watcher for the specified commit, which will prevent further notifications from being dispatched to that user.
@Nonnull Comment updateComment(Repository repository, String commitId, long commentId, int commentVersion, String commentText)
Updates the text for the specified comment.
@Nonnull Watcher watch(Repository repository, String commitId)
Adds the current user as a watcher for the specified commit.
[Expand]
Inherited Methods
From interface com.atlassian.stash.history.CommonHistoryService

Public Methods

@Nonnull public Comment addComment (Repository repository, String commitId, String commentText)

Adds a general comment on the specified commit in the specified repository.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
commentText the comment text
Returns
  • the created comment

@Nonnull public Comment addDiffComment (Repository repository, String commitId, AddDiffCommentRequest request)

Adds a line comment to a commit diff in the specified repository.

The request's toHash should generally be omitted. If it is provided, it must match the commitId. For merge commits, which have a diff for each parent, the desired diff can be selected by providing the parent's ID in the fromHash. If the fromHash is null, the first parent will be assumed.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
request a request describing the comment to create
Returns
  • the created line comment
Throws
ArgumentValidationException if the request contains invalid data

@Nonnull public Comment addFileComment (Repository repository, String commitId, AddFileCommentRequest request)

Adds a file-level comment to a commit diff in the specified repository.

The request's toHash should generally be omitted. If it is provided, it must match the commitId. For merge commits, which have a diff for each parent, the desired diff can be selected by providing the parent's ID in the fromHash. If the fromHash is null, the first parent will be assumed.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
request a request describing the comment to create
Returns
  • the created file comment
Throws
ArgumentValidationException if the request contains invalid data

@Nonnull public Comment addReply (Repository repository, String commitId, long commentId, String commentText)

Adds a reply to a comment.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
commentId the ID of the comment to reply to
commentText the comment text
Returns
  • the created comment
Throws
NoSuchCommentException if no comment exists with the specified ID

public boolean deleteComment (Repository repository, String commitId, long commentId, int commentVersion)

Deletes a comment.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
commentId the ID of the comment to delete
commentVersion the expected version of the comment
Returns
  • true if the comment existed (and thus was deleted); otherwise false
Throws
CommentDeletionException if the comment has replies
CommentOutOfDateException if the version of the specified comment does not match the expected version

@Nonnull public Iterable<DiffCommentAnchor> findCommentAnchors (Repository repository, String commitId, String parentId, String path)

Finds anchors for file and line comments on the specified path in the commit. For merge commits, which have a diff for each parent, the parent ID can also be provided to select the diff to retrieve comments from.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
parentId the ID of the parent, used to select the desired diff for merge commits. If the parent ID is not provided the commit's first parent is automatically used if it has one
path the path of the file for which the anchors should be retrieved
Returns
  • all anchors (representing comments) for the specified modified path in the commit

@Nonnull public Comment getComment (Repository repository, String commitId, long commentId)

Retrieves a the specified comment by its ID.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
commentId the ID of the comment to retrieve
Returns
  • the retrieved comment
Throws
NoSuchCommentException if no comment exists with the specified ID

public void streamDiff (DiffRequest request, DiffContentCallback callback)

Streams diff output for the specified paths at the specified changeset.

Note: This interface is currently not paged. The implementation will apply a hard cap and it is not possible to request subsequent content when that cap is exceeded.

Parameters
request the repository, starting and terminating changsets, paths to filter
callback the callback for receiving the diff details

public void traverse (TraversalRequest request, TraversalCallback callback)

Traverse the graph of commits in topological order, optionally supplying included commits to start from and excluded commits to ignore.

Parameters
request the traversal request describing the repository and the commits to include and exclude
callback the callback to receive the traversed commits

public boolean unwatch (Repository repository, String commitId)

Removes the current user as a watcher for the specified commit, which will prevent further notifications from being dispatched to that user.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
Returns
  • true if the watcher existed (and thus was removed); otherwise false

@Nonnull public Comment updateComment (Repository repository, String commitId, long commentId, int commentVersion, String commentText)

Updates the text for the specified comment.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
commentId the ID of the comment to update
commentVersion the expected version of the comment
commentText the new text for the comment
Returns
  • the updated comment
Throws
CommentOutOfDateException if the version of the specified comment does not match the expected version
NoSuchCommentException if no comment exists with the specified ID

@Nonnull public Watcher watch (Repository repository, String commitId)

Adds the current user as a watcher for the specified commit. Watchers receive notifications when new comments are added to the commit.

Parameters
repository the ID of the repository containing the commit
commitId the ID of the commit within the repository
Returns
  • the created watcher