Skip to content

Commit aabaf3b

Browse files
Merge pull request #4935 from linuxfoundation/unicron-add-remove-co-authored-by-option
Unicron add remove co authored by option
2 parents 28716a2 + 2da8f25 commit aabaf3b

6 files changed

Lines changed: 82 additions & 7 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-go/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"serverless-layers": "^2.6.1",
2727
"serverless-plugin-tracing": "^2.0.0",
2828
"serverless-prune-plugin": "^2.0.2",
29+
"simple-git": "^3.33.0",
2930
"xml2js": "^0.6.0",
3031
"yarn-audit-fix": "^9.3.10"
3132
},
@@ -45,7 +46,7 @@
4546
"normalize-url": "^4.5.1",
4647
"qs": "^6.14.2",
4748
"set-value": "^4.0.1",
48-
"simple-git": "^3.16.0",
49+
"simple-git": "^3.33.0",
4950
"ws": ">=7.5.10",
5051
"xmlhttprequest-ssl": "^1.6.2",
5152
"form-data": "^4.0.4",

cla-backend-go/yarn.lock

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,13 +2385,20 @@ dayjs@^1.11.8:
23852385
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c"
23862386
integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==
23872387

2388-
debug@4, debug@^4.1.1, debug@^4.3.4, debug@^4.3.5:
2388+
debug@4, debug@^4.1.1, debug@^4.3.4:
23892389
version "4.4.0"
23902390
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a"
23912391
integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==
23922392
dependencies:
23932393
ms "^2.1.3"
23942394

2395+
debug@^4.4.0:
2396+
version "4.4.3"
2397+
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.3.tgz#c6ae432d9bd9662582fce08709b038c58e9e3d6a"
2398+
integrity sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==
2399+
dependencies:
2400+
ms "^2.1.3"
2401+
23952402
decompress-response@^6.0.0:
23962403
version "6.0.0"
23972404
resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc"
@@ -4783,14 +4790,14 @@ signal-exit@^3.0.2, signal-exit@^3.0.7:
47834790
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
47844791
integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==
47854792

4786-
simple-git@^3.16.0:
4787-
version "3.27.0"
4788-
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.27.0.tgz#f4b09e807bda56a4a3968f635c0e4888d3decbd5"
4789-
integrity sha512-ivHoFS9Yi9GY49ogc6/YAi3Fl9ROnF4VyubNylgCkA+RVqLaKWnDSzXOVzya8csELIaWaYNutsEuAhZrtOjozA==
4793+
simple-git@^3.16.0, simple-git@^3.33.0:
4794+
version "3.33.0"
4795+
resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.33.0.tgz#b903dc70f5b93535a4f64ff39172da43058cfb88"
4796+
integrity sha512-D4V/tGC2sjsoNhoMybKyGoE+v8A60hRawKQ1iFRA1zwuDgGZCBJ4ByOzZ5J8joBbi4Oam0qiPH+GhzmSBwbJng==
47904797
dependencies:
47914798
"@kwsites/file-exists" "^1.1.1"
47924799
"@kwsites/promise-deferred" "^1.1.1"
4793-
debug "^4.3.5"
4800+
debug "^4.4.0"
47944801

47954802
slash@^3.0.0:
47964803
version "3.0.0"

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)