diff options
author | John Cai <jcai@gitlab.com> | 2022-11-01 23:04:46 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2022-11-04 22:07:41 +0300 |
commit | 9c29f5ff0b5b7526645b08612bd9cfee7d5a74c2 (patch) | |
tree | 625231e699de9edc8633a9a9ee32adb866c45711 | |
parent | f8e4d798c86e54d8207398e9b0accdf4b4c023b9 (diff) |
operations: Add newline after commit message with git2go Merge
A future commit will add an implementation to use git-merge-tree(1) to
create a merge. In order to do so, we will need to also use
git-commit-tree(1) to create the commit.
There is a difference however, between how git-commit-tree(1) processes
the -m message that is passed in versus how git2go's Merge function
creates the commit. git2go's Merge function does not add a '\n' when
creating the commit message.
In order to have parity between git2go and using git-merge-tree(1),
which we are about to do, add a '\n' after the commit message when
merging with git2go.
-rw-r--r-- | internal/gitaly/service/operations/merge.go | 2 | ||||
-rw-r--r-- | internal/gitaly/service/operations/merge_test.go | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/internal/gitaly/service/operations/merge.go b/internal/gitaly/service/operations/merge.go index 876a6bcf4..6eef9c304 100644 --- a/internal/gitaly/service/operations/merge.go +++ b/internal/gitaly/service/operations/merge.go @@ -77,7 +77,7 @@ func (s *Server) mergeWithGit2Go( AuthorName: authorName, AuthorMail: authorMail, AuthorDate: authorDate, - Message: message, + Message: message + "\n", Ours: ours, Theirs: theirs, }) diff --git a/internal/gitaly/service/operations/merge_test.go b/internal/gitaly/service/operations/merge_test.go index af041e720..0e835f555 100644 --- a/internal/gitaly/service/operations/merge_test.go +++ b/internal/gitaly/service/operations/merge_test.go @@ -321,7 +321,7 @@ func testUserMergeBranchStableMergeIDs(t *testing.T, ctx context.Context) { } // Because the timestamp is - expectedMergeID := "f0165798887392f9148b55d54a832b005f93a38c" + expectedMergeID := "4da30bc9e1ed20b1cdeabafc3f68889df72582f1" require.NoError(t, mergeBidi.Send(firstRequest), "send first request") response, err := mergeBidi.Recv() @@ -340,8 +340,8 @@ func testUserMergeBranchStableMergeIDs(t *testing.T, ctx context.Context) { require.NoError(t, err, "look up git commit after call has finished") require.Equal(t, commit, &gitalypb.GitCommit{ Subject: []byte("Merged by Gitaly"), - Body: []byte("Merged by Gitaly"), - BodySize: 16, + Body: []byte("Merged by Gitaly\n"), + BodySize: 17, Id: expectedMergeID, ParentIds: []string{ "281d3a76f31c812dbf48abce82ccf6860adedd81", @@ -485,7 +485,7 @@ func testUserMergeBranchConcurrentUpdate(t *testing.T, ctx context.Context) { ReferenceUpdate: &gitalypb.ReferenceUpdateError{ ReferenceName: []byte("refs/heads/" + mergeBranchName), OldOid: "281d3a76f31c812dbf48abce82ccf6860adedd81", - NewOid: "f0165798887392f9148b55d54a832b005f93a38c", + NewOid: "4da30bc9e1ed20b1cdeabafc3f68889df72582f1", }, }, }, @@ -559,7 +559,7 @@ func testUserMergeBranchAmbiguousReference(t *testing.T, ctx context.Context) { require.NoError(t, err, "look up git commit after call has finished") testhelper.ProtoEqual(t, &gitalypb.OperationBranchUpdate{CommitId: commit.Id}, response.BranchUpdate) - require.Equal(t, mergeCommitMessage, string(commit.Body)) + require.Equal(t, mergeCommitMessage+"\n", string(commit.Body)) require.Equal(t, gittest.TestUser.Name, commit.Author.Name) require.Equal(t, gittest.TestUser.Email, commit.Author.Email) require.Equal(t, []string{mergeBranchHeadBefore, commitToMerge}, commit.ParentIds) @@ -733,7 +733,7 @@ func TestUserMergeBranch_allowed(t *testing.T) { } func testUserMergeBranchAllowed(t *testing.T, ctx context.Context) { - mergeBranchHeadAfter := "ff0ac4dfa30d6b26fd14aa83a75650355270bf76" + mergeBranchHeadAfter := "c5b32bc830ea7f6f14796118ff236608295bcf46" for _, tc := range []struct { desc string |