From 2efbd6ff648a69c911d9aa21e6c1a9a43155e85e Mon Sep 17 00:00:00 2001 From: Alex Kantor Date: Sun, 25 Oct 2026 19:48:15 +0000 Subject: [PATCH] fix(gitlab): record a commit with no author as empty, not " <>" The merge request's author and its reviewers are already "" when GitLab names no one. A commit with no author name or email was still recorded as " <>". It's now "" too. Part of #1283 Co-Authored-By: Claude Opus 5.5 --- internal/gitlab/commit_mapping_test.go | 11 +++++++++++ internal/gitlab/gitlab.go | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/gitlab/commit_mapping_test.go b/internal/gitlab/commit_mapping_test.go index a5fdf9417..26299681e 100644 --- a/internal/gitlab/commit_mapping_test.go +++ b/internal/gitlab/commit_mapping_test.go @@ -135,3 +135,14 @@ func TestGitlabMRRefs(t *testing.T) { require.Equal(t, "feature-branch", head) require.Equal(t, "main", base) } + +// A commit with no author is recorded with an empty author, not " <>". One +// part is enough to keep the format. +func TestCommitFromGitlabCommit_MissingAuthorIsEmpty(t *testing.T) { + c := commitFromGitlabCommit(&gitlab.Commit{ID: "abc1230000000000000000000000000000000000"}, "my-branch") + require.Equal(t, "", c.Author) + c = commitFromGitlabCommit(&gitlab.Commit{ID: "abc1230000000000000000000000000000000000", AuthorName: "Steve Tooke"}, "my-branch") + require.Equal(t, "Steve Tooke <>", c.Author) + c = commitFromGitlabCommit(&gitlab.Commit{ID: "abc1230000000000000000000000000000000000", AuthorEmail: "tooky@kosli.com"}, "my-branch") + require.Equal(t, " ", c.Author) +} diff --git a/internal/gitlab/gitlab.go b/internal/gitlab/gitlab.go index 48af5c52f..7a725158b 100644 --- a/internal/gitlab/gitlab.go +++ b/internal/gitlab/gitlab.go @@ -344,10 +344,15 @@ func commitFromGitlabCommit(commit *gitlab.Commit, branch string) types.Commit { if commit.AuthoredDate != nil { timestamp = commit.AuthoredDate.Unix() } + // A commit with no author is recorded as "", not " <>". + author := "" + if commit.AuthorName != "" || commit.AuthorEmail != "" { + author = fmt.Sprintf("%s <%s>", commit.AuthorName, commit.AuthorEmail) + } return types.Commit{ SHA: commit.ID, Message: commit.Message, - Author: fmt.Sprintf("%s <%s>", commit.AuthorName, commit.AuthorEmail), + Author: author, Timestamp: timestamp, Branch: branch, URL: commit.WebURL,