Skip to content

Conversation

@philn-delphia
Copy link

Make the approvers field optional, and allow anyone to approve if it's empty.

I had to rework approvalFromComments to make this work, since it worked by removing names from the required approvers list until the list was small enough.

closes #108

Anyone can approve except the workflow initiator if they're not allowed.
fix length of issue approvers
@trstringer
Copy link
Owner

What kind of testing did you do for this PR? And also thanks for contributing!

@zchenyu
Copy link

zchenyu commented Jul 18, 2024

bump, this would be a nice feature :)

@philn-delphia
Copy link
Author

What kind of testing did you do for this PR? And also thanks for contributing!

I've been using this internally with no issues, but honestly we always have it set to allow all reviewers since it's private repos.

@MichalLeszczynski
Copy link

Hello, bumping as it'd be really helpful for me. Is there anything blocking us from merging it?

icon: pause
color: yellow
inputs:
approvers:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add your input here

approverIdx := approversIndex(remainingApprovers, commentUser)
if approverIdx < 0 {

if approversIndex(disallowedUsers, commentUser) >= 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think nonApprovers is a little more concise and clear

for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
actual, err := approvalFromComments(testCase.comments, testCase.approvers, testCase.minimumApprovals)
actual, err := approvalFromComments(testCase.comments, testCase.approvers, testCase.minimumApprovals, testCase.disallowedUsers)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would like to see a test for this specifically - as well as a test for if the same user is in the disallowed and allowed lists

approvers:
description: Required approvers
required: true
required: false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest keeping this field as required and adding a keyword for your use case.
If we have a keyword instead of an empty field it could save potential security catastrophies caused by a mere oversight.

}

issueApproversText := "Anyone can approve."
if len(a.issueApprovers) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of overwriting a variable, it would be better to use if...else.

approvers := []string{}
requiredApproversRaw := os.Getenv(envVarApprovers)
requiredApprovers := strings.Split(requiredApproversRaw, ",")
requiredApprovers := []string{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of overwriting a variable, it would be better to use if...else.

@snskArora
Copy link
Collaborator

Also, please rebase on the main branch to account the new changes.

@snskArora
Copy link
Collaborator

Hi @philn-delphia

Thank you for your contribution!
There are a few open comments, can you please address them.

@snskArora snskArora added the Changes Requested Awaiting for a response on the open commnets label Jun 13, 2025
@adrian-chang
Copy link

@philn-delphia any update on this? would be useful ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes Requested Awaiting for a response on the open commnets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let anyone approve an issue

7 participants