diff --git a/approval.go b/approval.go index 9516b64..8487e26 100644 --- a/approval.go +++ b/approval.go @@ -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 } } diff --git a/approval_test.go b/approval_test.go index cefe1b0..efddf7f 100644 --- a/approval_test.go +++ b/approval_test.go @@ -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 {