Repository navigation
Conversation
Add two new action kinds, `assign` and `unassign`, usable from `match` rules so a comment like `/assign @alice bob` adds assignees and `/unassign @alice` removes them. With no arguments the comment author is the target, so a bare `/assign` self-assigns (Prow semantics). - Extend GitHubClient with AddAssignees, RemoveAssignees and IsAssignee. - Add optional CommentAuthor to LabelRequest, an optional trailing `comment_author` CLI argument, and a matching optional `comment_author` input on .github/actions/labeler-action (backwards compatible). - Logins are normalized (leading `@` stripped, case-insensitive dedupe). Already-assigned users are skipped; users who cannot be assigned in the repository are skipped with a log line rather than failing the run. - Match-rule commands must now be the first whitespace-delimited token of a line, so `/assign` no longer also matches `/assignee`. - Document the new actions in the labeler README. Fixes cncf#109 Signed-off-by: Aman Bansal <amanbn@icloud.com>
amanbn8
force-pushed
the
labeler-assign
branch
from
October 18, 2026 18:28
b5b3c51 to
65a8b29
Compare
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Needs approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Malformed targets can unexpectedly select the comment author or prevent valid assignments in the same command.
2 open issues
What changed in this PR
Adds configurable /assign and /unassign commands to the labeler, addressing #109.
Changes:
- Adds assignee actions with login normalization and eligibility checks.
- Passes an optional comment author through the CLI and Docker action.
- Tightens command matching and adds documentation and tests.
| File | Description |
|---|---|
| utilities/labeler/README.md | Documents assignment commands and author input. |
| utilities/labeler/main.go | Accepts the optional comment-author argument. |
| utilities/labeler/labeler.go | Implements assignee actions and exact-token matching. |
| utilities/labeler/labeler_test.go | Extends mocks with assignee state and operations. |
| utilities/labeler/assign_test.go | Tests assignment behavior and command matching. |
| .github/actions/labeler-action/action.yml | Forwards the optional comment-author input. |
Review effort: Balanced
| // `/assign` semantics. | ||
| func (l *Labeler) resolveAssignees(req *LabelRequest, argv []string) []string { | ||
| logins := normalizeLogins(argv) | ||
| if len(logins) == 0 && req.CommentAuthor != "" { |
Comment on lines
+375
to
+377
| ok, _, err := l.client.IsAssignee(ctx, req.Owner, req.Repo, login) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to check whether %s can be assigned: %v", login, err) |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #109
What
Adds
/assignand/unassignslash-command support toutilities/labelervia two new action kinds,assignandunassign, usable frommatchrules:/assign/assign @alice bobaliceandbob/unassign @alicealiceHow
GitHubClientgainsAddAssignees,RemoveAssigneesandIsAssignee(all exist in go-github v55; no new dependencies).LabelRequestgains an optionalCommentAuthor. It is wired through as an optional trailingcomment_authorCLI argument and an optionalcomment_authorinput on.github/actions/labeler-action(pass${{ github.event.comment.user.login }}). Existing callers that omit it keep working; only bare/assign//unassignneed it.@stripped, case-insensitive de-dupe. Already-assigned users are skipped on assign, not-assigned users on unassign. Users who are not assignable in the repo (perIsAssignee) are skipped with a log line rather than failing the whole run, so one bad login does not block the rest./assignno longer also fires on/assignee. Leading whitespace is still tolerated (strings.Fields). This matches the direction of Update labeler #640.Testing
New tests cover explicit users, bare self-assign, no-author no-op, skipping already-assigned/duplicate/unassignable users,
IsAssigneeAPI error, unassign explicit/self/not-assigned, and that/assigneedoes not trigger/assign.Not tested against a live repository; the GitHub calls are the straightforward go-github wrappers.
Notes
The mock
GetIssuenow reflects the mock's assignee state. Kept the change additive to limit conflicts with #640; theprocessMatchRuletoken check is the one overlapping hunk.