mirror of
https://github.com/go-gitea/gitea
synced 2025-07-13 22:17:20 +00:00
Properly migrate target branch change GitLab comment (#29340)
GitLab generates "system notes" whenever an event happens within the
platform. Unlike Gitea, those events are stored and retrieved as text
comments with no semantic details. The only way to tell whether a
comment was generated in this manner is the `system` flag on the note
type.
This PR adds detection for a new specific kind of event: Changing the
target branch of a PR. When detected, it is downloaded using Gitea's
type for this event, and eventually uploaded into Gitea in the expected
format, i.e. with no text content in the comment.
This PR also updates the template used to render comments to add support
for migrated comments of this type.
ref:
11bd6dc826/app/services/system_notes/merge_requests_service.rb (L102)
This commit is contained in:
committed by
GitHub
parent
b79c30435f
commit
6e5966597c
@ -545,7 +545,8 @@ func TestNoteToComment(t *testing.T) {
|
||||
notes := []gitlab.Note{
|
||||
makeTestNote(1, "This is a regular comment", false),
|
||||
makeTestNote(2, "enabled an automatic merge for abcd1234", true),
|
||||
makeTestNote(3, "canceled the automatic merge", true),
|
||||
makeTestNote(3, "changed target branch from `master` to `main`", true),
|
||||
makeTestNote(4, "canceled the automatic merge", true),
|
||||
}
|
||||
comments := []base.Comment{{
|
||||
IssueIndex: 17,
|
||||
@ -556,6 +557,7 @@ func TestNoteToComment(t *testing.T) {
|
||||
CommentType: "",
|
||||
Content: "This is a regular comment",
|
||||
Created: now,
|
||||
Meta: map[string]any{},
|
||||
}, {
|
||||
IssueIndex: 17,
|
||||
Index: 2,
|
||||
@ -565,15 +567,30 @@ func TestNoteToComment(t *testing.T) {
|
||||
CommentType: "pull_scheduled_merge",
|
||||
Content: "enabled an automatic merge for abcd1234",
|
||||
Created: now,
|
||||
Meta: map[string]any{},
|
||||
}, {
|
||||
IssueIndex: 17,
|
||||
Index: 3,
|
||||
PosterID: 72,
|
||||
PosterName: "test",
|
||||
PosterEmail: "test@example.com",
|
||||
CommentType: "change_target_branch",
|
||||
Content: "changed target branch from `master` to `main`",
|
||||
Created: now,
|
||||
Meta: map[string]any{
|
||||
"OldRef": "master",
|
||||
"NewRef": "main",
|
||||
},
|
||||
}, {
|
||||
IssueIndex: 17,
|
||||
Index: 4,
|
||||
PosterID: 72,
|
||||
PosterName: "test",
|
||||
PosterEmail: "test@example.com",
|
||||
CommentType: "pull_cancel_scheduled_merge",
|
||||
Content: "canceled the automatic merge",
|
||||
Created: now,
|
||||
Meta: map[string]any{},
|
||||
}}
|
||||
|
||||
for i, note := range notes {
|
||||
|
Reference in New Issue
Block a user