feat: add issue:fork/assign/label commands for GitLab work item bot#342
Merged
Conversation
Wraps the new Drupal.org bot slash commands (/do:fork, /do:access, /do:assign, /do:unassign, /do:reassign, /do:label, /do:unlabel, /do:relabel) as drupalorg-cli commands. Each posts a comment on the target GitLab work item via the GitLab issue notes endpoint, which the upstream bot then acts on. Token resolution falls back to `glab config get token` when DRUPALORG_GITLAB_TOKEN is unset. drupalorg-work-on-issue and drupalorg-mr-review skills updated to use the new commands at the natural workflow points (fork creation, self assign, verdict label). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class CLI support for posting Drupal.org bot “/do:*” slash commands as comments on GitLab work items (git.drupalcode.org), along with output formatting and skill/documentation updates so higher-level workflows can create forks, assign/unassign, and manage state labels programmatically.
Changes:
- Introduces
SlashCommandbuilders, aPostWorkItemSlashCommandAction, andClient::postIssueNote()for posting bot commands to GitLab work items. - Adds eight new
drupalorg issue:*CLI commands (fork/access/assign/unassign/reassign/label/unlabel/relabel) plus formatter support (md,llm) for the new result type. - Updates skills/docs and adds unit tests for the slash-command builder + posting action.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/src/GitLab/SlashCommandTest.php | Unit tests for building /do:* command strings. |
| tests/src/Action/GitLab/PostWorkItemSlashCommandActionTest.php | Tests for parsing refs/NIDs and posting a note via the GitLab client. |
| src/Cli/Formatter/MarkdownFormatter.php | Adds Markdown formatting for SlashCommandResult. |
| src/Cli/Formatter/LlmFormatter.php | Adds LLM/XML formatting for SlashCommandResult. |
| src/Cli/Formatter/AbstractFormatter.php | Routes SlashCommandResult to formatter implementations. |
| src/Cli/Command/Issue/Fork.php | New issue:fork command posting /do:fork. |
| src/Cli/Command/Issue/GetAccess.php | New issue:get-access command posting /do:access. |
| src/Cli/Command/Issue/Assign.php | New issue:assign command posting /do:assign …. |
| src/Cli/Command/Issue/Unassign.php | New issue:unassign command posting /do:unassign …. |
| src/Cli/Command/Issue/Reassign.php | New issue:reassign command posting /do:reassign …. |
| src/Cli/Command/Issue/Label.php | New issue:label command posting /do:label …. |
| src/Cli/Command/Issue/Unlabel.php | New issue:unlabel command posting /do:unlabel …. |
| src/Cli/Command/Issue/Relabel.php | New issue:relabel command posting /do:relabel …. |
| src/Cli/Application.php | Registers the new CLI commands. |
| src/Api/GitLab/SlashCommand.php | Adds the /do:* command string builder/validator. |
| src/Api/Action/GitLab/PostWorkItemSlashCommandAction.php | New action to resolve refs/NIDs and post the slash command as a note. |
| src/Api/Result/Issue/SlashCommandResult.php | New result DTO for posted command metadata + URL. |
| src/Api/GitLab/Client.php | Adds token fallback via glab and implements postIssueNote(). |
| skill-data/drupalorg-work-on-issue/SKILL.md | Updates workflow guidance to use the new commands for forks/assign/hand-off. |
| skill-data/drupalorg-cli/SKILL.md | Documents the new slash-command CLI surface and auth behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+61
to
+65
| $ref = WorkItemRef::tryParse($refOrNid); | ||
| if ($ref !== null) { | ||
| return $ref; | ||
| } | ||
| if (!ctype_digit($refOrNid)) { |
Comment on lines
+49
to
+50
| $noteId = isset($response->id) ? (int) $response->id : 0; | ||
|
|
Comment on lines
+21
to
+25
| return sprintf( | ||
| 'https://git.drupalcode.org/%s/-/work_items/%d', | ||
| $this->projectPath, | ||
| $this->issueIid, | ||
| ); |
- Trim whitespace in PostWorkItemSlashCommandAction::resolveRef so a bare NID copied with surrounding whitespace is still accepted. - Throw a descriptive RuntimeException when the GitLab notes response is missing an id, instead of silently returning noteId=0. - Document why SlashCommandResult::workItemUrl() always emits the canonical /-/work_items/ path even when a caller supplies an /-/issues/ URL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
drupalorgcommands that post Drupal.org bot slash commands as comments on a GitLab work item:issue:fork,issue:get-access,issue:assign,issue:unassign,issue:reassign,issue:label,issue:unlabel,issue:relabel. Closes the gap where the CLI/skills had no programmatic way to create a fork, self-assign, or move an issue betweenstate::*labels for projects whose queue lives at git.drupalcode.org.Client::postIssueNote()to the GitLab HTTP client and falls back toglab config get token --host git.drupalcode.orgwhenDRUPALORG_GITLAB_TOKENis unset.drupalorg-work-on-issue(fork creation when missing, self-assign, hand-off label + unassign) and into the personaldrupalorg-mr-reviewskill (verdict label).Only applies to projects migrated to GitLab work items; classic Drupal.org issue queues are unaffected (bot is not present there).
Refs upstream docs: https://new.drupal.org/drupalorg/gitlab-custom-commands
Test plan
vendor/bin/phpcs srccleanvendor/bin/phpstan analyse srccleanvendor/bin/phpunit— 149 tests, 505 assertions, all green (includes newPostWorkItemSlashCommandActionTest+SlashCommandTest)drupalorg issue:assign ai_context#<nid>, confirm bot picks it updrupalorg issue:fork <new-issue-ref>on an issue without a fork, thendrupalorg issue:get-fork --no-cacheto confirm🤖 Generated with Claude Code