Create REST endpoint to change commit message

Modifying the commit message using change edits needs two separate API
calls:

  PUT /changes/{change-id}/edit:message
  POST /changes/{change-id}/edit:publish

Since it requires two API calls, the operation is not atomic and can
leave a user with an unpublished edit.

PolyGerrit wants to support editing a commit message as an atomic
operation even before support for change edits is built.

This commit adds a new API endpoint on the change resource that
allows to edit the commit message of a change atomically.

It does not reuse the code from a previous implementation since the
underlying infrastructure changed and we now use BatchUpdate.

Bug: Issue 6502
Change-Id: I60595df074b00a503165c41485b69a5fe0c5de39
This commit is contained in:
Patrick Hiesel
2017-06-14 16:44:54 +02:00
parent 21e983bf26
commit fda9645d2f
8 changed files with 416 additions and 12 deletions

View File

@@ -3130,6 +3130,28 @@ request:
HTTP/1.1 204 No Content
----
[[set-message]]
=== Set Commit Message
--
'PUT /changes/link:#change-id[\{change-id\}]/message'
--
Creates a new patch set with a new commit message.
The new commit message must be provided in the request body inside a
link:#commit-message-input[CommitMessageInput] entity and contain the change ID footer if
link:project-configuration.html#require-change-id[Require Change-Id] was specified.
.Request
----
PUT /changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/message HTTP/1.0
Content-Type: application/json; charset=UTF-8
{
"message": "New Commit message \n\nChange-Id: I10394472cbd17dd12454f229e4f6de00b143a444\n"
}
----
[[revision-endpoints]]
== Revision Endpoints
@@ -5921,6 +5943,25 @@ Links to the commit in external sites as a list of
link:#web-link-info[WebLinkInfo] entities.
|===========================
[[commit-message-input]]
=== CommitMessageInput
The `CommitMessageInput` entity contains information for changing
the commit message of a change.
[options="header",cols="1,^1,5"]
|=============================
|Field Name ||Description
|`message` ||New commit message.
|`notify` |optional|
Notify handling that defines to whom email notifications should be sent
after the commit message was updated. +
Allowed values are `NONE`, `OWNER`, `OWNER_REVIEWERS` and `ALL`. +
If not set, the default is `ALL`.
|`notify_details`|optional|
Additional information about whom to notify about the update as a map
of recipient type to link:#notify-info[NotifyInfo] entity.
|=============================
[[delete-comment-input]]
=== DeleteCommentInput
The `DeleteCommentInput` entity contains the option for deleting a comment.