Skip to content

fix: match PR comment commands on a word boundary - #2763

Open
echomohit wants to merge 1 commit into
diggerhq:developfrom
echomohit:fix/comment-command-word-boundary
Open

echomohit wants to merge 1 commit into
diggerhq:developfrom
echomohit:fix/comment-command-word-boundary

Conversation

@echomohit

@echomohit echomohit commented Nov 3, 2026 •

Copy link
Copy Markdown

🧠 Ai UsageDetails (if applicable):

The bug was found by a human: a digger applyt typo applied a production project on our Digger Cloud setup, and digger unlockt also unlocked. The investigation, the code change, the tests, the linked issue (#2762) and this description were generated by Claude Code. The tests listed under Testing were run locally.

Fixes #2762

PR comment commands were matched with strings.HasPrefix (GitHub path, GetCommandFromComment) or strings.Contains (GitLab, Bitbucket, Azure), so digger applyt ran an apply, and on the Contains paths any comment mentioning digger apply did.

This adds scheduler.IsCommentCommand, which matches a command only at the start of the trimmed, lower-cased comment and only when followed by whitespace or the end of the comment, and uses it at all five sites.

Comment Before After
digger apply -p prod apply apply
digger applyt apply rejected
digger planet plan rejected
digger unlockt unlock rejected
lgtm, digger apply (GitLab/Bitbucket/Azure) apply ignored

Behaviour change: on GitLab, Bitbucket and Azure the command must now start the comment, which is what GitHub already required and what the docs show.

GetCommandFromJob is left alone since job.Commands are produced internally.

Testing

  • go test ./scheduler/ ./ci/generic/ ./ci/gitlab/ ./ci/bitbucket/ ./ci/azure/ in libs/
  • New libs/scheduler/utils_test.go covers exact match, flags, mixed case, tab/newline separators, typos, and mid-comment mentions.

🤖 Generated with Claude Code

"digger applyt" was dispatched as "digger apply": the GitHub path matched
with HasPrefix and GitLab, Bitbucket and Azure with Contains. Match only
when the command is followed by whitespace or the end of the comment.

Fixes diggerhq#2762

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PR comment commands match by prefix: "digger applyt" runs an apply

1 participant