Skip to content

Commit 8cc692e

Browse files
Address copilot review feedback
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent 6ca6b2e commit 8cc692e

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

cla-backend-go/github/bots.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ package github
55

66
import (
77
"fmt"
8+
"regexp"
9+
"strings"
10+
811
"github.com/linuxfoundation/easycla/cla-backend-go/events"
912
"github.com/linuxfoundation/easycla/cla-backend-go/gen/v1/models"
1013
log "github.com/linuxfoundation/easycla/cla-backend-go/logging"
1114
"github.com/sirupsen/logrus"
12-
"regexp"
13-
"strings"
1415
)
1516

1617
// propertyMatches returns true if value matches the pattern.
@@ -74,10 +75,10 @@ func isActorSkipped(actor *UserCommitSummary, config string) bool {
7475
username string
7576
email string
7677
)
77-
if actor.CommitAuthor != nil && actor.CommitAuthor.Login != nil {
78+
if actor != nil && actor.CommitAuthor != nil && actor.CommitAuthor.Login != nil {
7879
username = *actor.CommitAuthor.Login
7980
}
80-
if actor.CommitAuthor != nil && actor.CommitAuthor.Email != nil {
81+
if actor != nil && actor.CommitAuthor != nil && actor.CommitAuthor.Email != nil {
8182
email = *actor.CommitAuthor.Email
8283
}
8384

@@ -167,10 +168,14 @@ func SkipWhitelistedBots(ev events.Service, orgModel *models.GithubOrganization,
167168
log.WithFields(f).Debug("No skip_cla config found for repo, skipping whitelisted bots check")
168169
return actorsMissingCLA, []*UserCommitSummary{}
169170
}
171+
const nullStr = "(null)"
170172

171173
for _, actor := range actorsMissingCLA {
172174
if isActorSkipped(actor, config) {
173-
id, login, username, email := "(null)", "(null)", "(null)", "(null)"
175+
if actor == nil {
176+
continue
177+
}
178+
id, login, username, email := nullStr, nullStr, nullStr, nullStr
174179
if actor.CommitAuthor != nil && actor.CommitAuthor.ID != nil {
175180
id = fmt.Sprintf("%v", *actor.CommitAuthor.ID)
176181
}

cla-backend/cla/models/github_models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,8 @@ def skip_whitelisted_bots(self, org_model, org_repo, actors_missing_cla) -> Tupl
10401040
out_actors_missing_cla = []
10411041
whitelisted_actors = []
10421042
for actor in actors_missing_cla:
1043+
if actor is None:
1044+
continue
10431045
try:
10441046
if self.is_actor_skipped(actor, config):
10451047
actor_data = "id='{}',login='{}',username='{}',email='{}'".format(

utils/skip_cla_entry.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# put-item Overwrites/adds the entire `skip_cla` entry.
44
# add-key Adds or updates a key/value inside the skip_cla map (preserves other keys)
55
# delete-key Removes a key from the skip_cla map
6-
# delete-item Deletes the entire `skip_cla`entry.
6+
# delete-item Deletes the entire `skip_cla` entry.
77
#
88
# MODE=add-key ./utils/skip_cla_entry.sh sun-test-org 'repo1' 're:vee?rendra' '*'
99
# ./utils/scan.sh github-orgs organization_name sun-test-org

0 commit comments

Comments
 (0)