Skip to content

Commit cb81fcc

Browse files
Update comment message and add test case
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io> Assisted by [OpenAI](https://platform.openai.com/) Assisted by [GitHub Copilot](https://github.com/features/copilot)
1 parent 28716a2 commit cb81fcc

4 files changed

Lines changed: 67 additions & 0 deletions

File tree

cla-backend-go/github/github_repository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Supported |Co-authored-by:| formats include:
5353
4) |Anything <other-email>| - it will locate your GitHub user by |other-email| part but only if that email was used before for any other CLA as a main commit author.
5454
5) |login <any-valid-email>| - it will locate your GitHub user by |login| part, note that |login| part must be at least 3 characters long.
5555
56+
Alternatively, if the co-author should not be included, remove the |Co-authored-by:| line from the commit message.
57+
5658
Please update your commit message(s) by doing |git commit --amend| and then |git push [--force]| and then request re-running CLA check via commenting on this pull request:
5759
5860
|||
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright The Linux Foundation and each contributor to CommunityBridge.
2+
// SPDX-License-Identifier: MIT
3+
4+
package github
5+
6+
import (
7+
"testing"
8+
9+
gh "github.com/google/go-github/v37/github"
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestGetCommentBodyIncludesCoAuthorRemovalGuidance(t *testing.T) {
14+
signed := []*UserCommitSummary{{
15+
SHA: "abc1234xyz-123",
16+
CommitAuthor: &gh.User{
17+
ID: gh.Int64(1234),
18+
Login: gh.String("login_value"),
19+
Name: gh.String("author name"),
20+
Email: gh.String("foo@bar.com"),
21+
},
22+
Affiliated: true,
23+
Authorized: true,
24+
}}
25+
26+
missing := []*UserCommitSummary{{
27+
SHA: "some_other_sha",
28+
CommitAuthor: &gh.User{
29+
ID: gh.Int64(123456),
30+
Login: gh.String("login_value2"),
31+
Name: gh.String("author name2"),
32+
Email: gh.String("foo2@bar.com"),
33+
},
34+
Affiliated: false,
35+
Authorized: false,
36+
}}
37+
38+
body := getCommentBody("github", "https://foo.com", signed, missing, true)
39+
40+
assert.Contains(t, body, "One or more co-authors of this pull request were not found")
41+
assert.Contains(t, body, "Alternatively, if the co-author should not be included, remove the `Co-authored-by:` line from the commit message.")
42+
assert.NotContains(t, body, "|Co-authored-by:|")
43+
}
44+
45+
func TestGetCommentBodyOmitsCoAuthorRemovalGuidanceWhenNoCoAuthorIsMissing(t *testing.T) {
46+
missing := []*UserCommitSummary{{
47+
SHA: "some_other_sha",
48+
CommitAuthor: &gh.User{
49+
ID: gh.Int64(123456),
50+
Login: gh.String("login_value2"),
51+
Name: gh.String("author name2"),
52+
Email: gh.String("foo2@bar.com"),
53+
},
54+
Affiliated: false,
55+
Authorized: false,
56+
}}
57+
58+
body := getCommentBody("github", "https://foo.com", nil, missing, false)
59+
60+
assert.NotContains(t, body, "One or more co-authors of this pull request were not found")
61+
assert.NotContains(t, body, "Alternatively, if the co-author should not be included, remove the `Co-authored-by:` line from the commit message.")
62+
}

cla-backend/cla/tests/unit/test_user_commit_summary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ def test_user_commit_summary_get_comment_body_missing_co_authors(self) -> None:
7474
self.assertTrue(':white_check_mark:' in body)
7575
self.assertTrue(':x:' in body)
7676
self.assertTrue('One or more co-authors of this pull request were not found' in body)
77+
self.assertTrue('Alternatively, if the co-author should not be included, remove the `Co-authored-by:` line from the commit message.' in body)

cla-backend/cla/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
4) `Anything <other-email>` - it will locate your GitHub user by `other-email` part but only if that email was used before for any other CLA as a main commit author.
5454
5) `login <any-valid-email>` - it will locate your GitHub user by `login` part, note that `login` part must be at least 3 characters long.
5555
56+
Alternatively, if the co-author should not be included, remove the `Co-authored-by:` line from the commit message.
57+
5658
Please update your commit message(s) by doing `git commit --amend` and then `git push [--force]` and then request re-running CLA check via commenting on this pull request:
5759
5860
```

0 commit comments

Comments
 (0)