Skip to content

Commit

Permalink
Merge pull request #4051 from nickmango/bug/approval-regex
Browse files Browse the repository at this point in the history
[#4006] Bug/Approval List handles
  • Loading branch information
nickmango authored Jul 18, 2023
2 parents 7822ba7 + 4e06eba commit 5cbc48f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 16 additions & 5 deletions cla-backend-go/github/github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,32 @@ func (u UserCommitSummary) GetDisplayText(tagUser bool) string {
}

func (u UserCommitSummary) getUserInfo(tagUser bool) string {

f := logrus.Fields{
"functionName": "github.github_repository.getUserInfo",
"tagUser": tagUser,
}

userInfo := ""
tagValue := ""
var sb strings.Builder
sb.WriteString(userInfo)

log.WithFields(f).Debugf("author: %+v", u.CommitAuthor)

if tagUser {
tagValue = "@"
}
if *u.CommitAuthor.Login != "" {
sb.WriteString(fmt.Sprintf("login: %s%s / ", tagValue, *u.CommitAuthor.Login))
}
if u.CommitAuthor != nil {
if *u.CommitAuthor.Login != "" {
sb.WriteString(fmt.Sprintf("login: %s%s / ", tagValue, *u.CommitAuthor.Login))
}

if u.CommitAuthor.Name != nil {
sb.WriteString(fmt.Sprintf("%sname: %s / ", userInfo, utils.StringValue(u.CommitAuthor.Name)))
if u.CommitAuthor.Name != nil {
sb.WriteString(fmt.Sprintf("%sname: %s / ", userInfo, utils.StringValue(u.CommitAuthor.Name)))
}
}

return strings.Replace(sb.String(), "/ $", "", -1)
}

Expand Down
4 changes: 2 additions & 2 deletions cla-backend-go/utils/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func ValidGitHubUsername(githubUsername string) (string, bool) {
}

// For now, we only allow alphanumeric values
re := regexp.MustCompile("^[a-zA-Z0-9_-]*$")
re := regexp.MustCompile("^[a-zA-Z0-9._-]*$")
valid := re.MatchString(strings.TrimSpace(githubUsername))
if !valid {
return fmt.Sprintf("invalid GitHub username: %s", githubUsername), false
Expand All @@ -113,7 +113,7 @@ func ValidGitlabUsername(gitlabUsername string) (string, bool) {
}

// For now, we only allow alphanumeric values
re := regexp.MustCompile("^[a-zA-Z0-9_-]*$")
re := regexp.MustCompile("^[a-zA-Z0-9._-]*$")
valid := re.MatchString(strings.TrimSpace(gitlabUsername))
if !valid {
return fmt.Sprintf("invalid Gitlab username: %s", gitlabUsername), false
Expand Down

0 comments on commit 5cbc48f

Please sign in to comment.