-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
By setting the type attribute in the label configuration, the user can specify whether a rule applies exclusively to Pull Requests (PRs) or Issues. This functionality increases the adaptability of this GitHub Action, allowing users to create more tailored labeling strategies that differentiate between PRs and Issues or apply universally to both.
- Loading branch information
1 parent
daa45e5
commit ff8cb30
Showing
6 changed files
with
146 additions
and
0 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,36 @@ | ||
package labeler | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
) | ||
|
||
func TypeCondition() Condition { | ||
return Condition{ | ||
GetName: func() string { | ||
return "Target type matches defined type" | ||
}, | ||
CanEvaluate: func(target *Target) bool { | ||
return true | ||
}, | ||
Evaluate: func(target *Target, matcher LabelMatcher) (bool, error) { | ||
if len(matcher.Type) <= 0 { | ||
return false, fmt.Errorf("type is not set in config") | ||
} else if matcher.Type != "pull_request" && matcher.Type != "issue" { | ||
return false, fmt.Errorf("type musst be of value 'pull_request' or 'issue'") | ||
} | ||
|
||
var targetType string | ||
if target.ghPR != nil { | ||
targetType = "pull_request" | ||
} else if target.ghIssue != nil { | ||
targetType = "issue" | ||
} else { | ||
return false, fmt.Errorf("target is neither pull_request nor issue") | ||
} | ||
|
||
log.Printf("Matching `%s` against: `%s`", matcher.Type, targetType) | ||
return matcher.Type == targetType || matcher.Type == "all", 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