forked from srvaroa/labeler
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New rule to match on whether author can merge
Allow matching on whether the author of a PR can merge it. For now, implementing it using the author_association field in the PR. Which gives a value among these [1](https://docs.github.com/en/graphql/reference/enums#commentauthorassociation). Not sure if it's the best way of achieving it, but let's see. Signed-off-by: Galo Navarro <[email protected]>
- Loading branch information
Showing
7 changed files
with
553 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package labeler | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func AuthorCanMergeCondition() Condition { | ||
return Condition{ | ||
GetName: func() string { | ||
return "Author can merge" | ||
}, | ||
CanEvaluate: func(target *Target) bool { | ||
return true | ||
}, | ||
Evaluate: func(target *Target, matcher LabelMatcher) (bool, error) { | ||
if len(matcher.AuthorCanMerge) <= 0 { | ||
return false, fmt.Errorf("AuthorCanMerge not set in repository") | ||
} | ||
ghRepo := target.ghPR.GetAuthorAssociation() | ||
canMerge := ghRepo == "OWNER" | ||
fmt.Printf("User: %s can merge? %t\n", target.Author, canMerge) | ||
return canMerge, nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.