Skip to content

Commit

Permalink
Fix can merge with additional roles (#126)
Browse files Browse the repository at this point in the history
author-can-merge was not considering all the roles that allow for
committing into the base branch

Fixes: #123

Signed-off-by: Galo Navarro <anglorvaroa@gmail.com>
  • Loading branch information
srvaroa authored Dec 10, 2023
1 parent 69c414f commit 7d6ef90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 5 additions & 6 deletions pkg/condition_author_can_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ func AuthorCanMergeCondition() Condition {
return false, fmt.Errorf("author-can-merge doesn't have a valid value in config")
}

ghRepo := target.ghPR.GetAuthorAssociation()
canMerge := ghRepo == "OWNER"
authorAssoc := target.ghPR.GetAuthorAssociation()
canMerge := authorAssoc == "MEMBER" || authorAssoc == "OWNER" || authorAssoc == "COLLABORATOR"

if expected && canMerge {
fmt.Printf("User: %s can merge %t, condition matched\n",
target.Author, canMerge)
fmt.Printf("User: %s can merge, condition matched\n", target.Author)
return true, nil
}

if !expected && !canMerge {
fmt.Printf("User: %s can not merge %t, condition matched\n",
target.Author, canMerge)
fmt.Printf("User: %s can not merge, condition matched\n",
target.Author)
return true, nil
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/labeler.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,6 @@ func (l *Labeler) findMatches(target *Target, config *LabelerConfigV1) (LabelUpd
} else { // First condition evaluated for this label
labelUpdates.set[label] = isMatched
}

if isMatched {
continue
}
}

if matcher.Negate {
Expand Down

0 comments on commit 7d6ef90

Please sign in to comment.