Make name comparison case-insensitive (#172)

Signed-off-by: Simeon Widdis <sawiddis@amazon.com>
This commit is contained in:
Simeon Widdis 2025-04-20 08:36:57 -07:00 committed by GitHub
parent ef4dddd64b
commit c1ebf589e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 5 deletions

View file

@ -136,12 +136,12 @@ func (a *approvalEnvironment) SetActionOutputs(outputs map[string]string) (bool,
// two outputs from being written on the same line.
fileInfo, err := f.Stat()
if err != nil {
return false, err
return false, err
}
if fileInfo.Size() > 0 {
if _, err := f.WriteString("\n"); err != nil {
return false, err
}
if _, err := f.WriteString("\n"); err != nil {
return false, err
}
}
if _, err := f.WriteString(strings.Join(pairs, "\n")); err != nil {
@ -194,7 +194,7 @@ func approvalFromComments(comments []*github.IssueComment, approvers []string, m
func approversIndex(approvers []string, name string) int {
for idx, approver := range approvers {
if approver == name {
if strings.EqualFold(approver, name) {
return idx
}
}

View file

@ -3,6 +3,7 @@ package main
import (
"errors"
"os"
"strings"
"testing"
"github.com/google/go-github/v43/github"
@ -16,6 +17,8 @@ func TestApprovalFromComments(t *testing.T) {
bodyDenied := "Denied"
bodyPending := "not approval or denial"
login1u := strings.ToUpper(login1)
testCases := []struct {
name string
comments []*github.IssueComment
@ -160,6 +163,17 @@ func TestApprovalFromComments(t *testing.T) {
expectedStatus: approvalStatusPending,
minimumApprovals: 2,
},
{
name: "single_approver_single_comment_approved_case_insensitive",
comments: []*github.IssueComment{
{
User: &github.User{Login: &login1u},
Body: &bodyApproved,
},
},
approvers: []string{login1},
expectedStatus: approvalStatusApproved,
},
}
for _, testCase := range testCases {