-
Notifications
You must be signed in to change notification settings - Fork 17
docs(skill): report bug attribution via @holdex bot #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| Post a `@holdex bug commit` or `@holdex bug dispute` comment on a pull | ||
| request to attribute the commit and author that introduced a bug. | ||
|
|
||
| **Required for every PR whose title starts with `fix` (Conventional | ||
| Commits type).** A `fix` PR is not ready for review until this comment is | ||
| posted — it's how the original bug source gets attributed. | ||
|
|
||
| ## Input | ||
|
|
||
| `$ARGUMENTS` holds the commit URL and the GitHub handle of the commit's | ||
| author, optionally prefixed with `dispute` to correct a previous report | ||
| instead of filing a new one: | ||
|
|
||
| - `<commit-url> @<github-handle>` — report the commit/author that introduced | ||
| the bug (e.g. | ||
| `https://github.com/holdex/my-repo/commit/1234567890 @usershandle`). | ||
| - `dispute <commit-url> @<github-handle>` — dispute a previous bug report | ||
| after the PR it was filed on has already been merged, to correct an | ||
| incorrect attribution. | ||
|
|
||
| If `$ARGUMENTS` is empty, ask the user for the commit URL and the author's | ||
| GitHub handle before proceeding. | ||
|
|
||
| Determine which mode applies: | ||
|
|
||
| - No `dispute` prefix: **report** — attribute the commit/author that | ||
| introduced the bug this PR fixes. | ||
| - `dispute` prefix: **dispute** — strip the `dispute` prefix to get the | ||
| commit URL and handle; use this to correct a wrong attribution after | ||
| merge. | ||
|
|
||
| Validate the input against strict patterns — reject anything that doesn't | ||
| fully match, don't just check a prefix: | ||
|
|
||
| - Commit URL must match | ||
| `^https://github\.com/[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+/(commit|pull/[0-9]+/(commits|changes))/[0-9a-f]{7,40}$`. | ||
| - Handle must match `^@[A-Za-z0-9](-?[A-Za-z0-9])*$` (a bare GitHub | ||
| username, `@` + up to 39 alphanumeric/hyphen characters, no spaces or | ||
| shell metacharacters). | ||
|
|
||
| If either fails to match, tell the user and stop — don't attempt to sanitize | ||
| or partially accept it. | ||
|
|
||
| ## Resolve the PR | ||
|
|
||
| Detect the current PR from the git worktree. **Report** mode targets the | ||
| PR still in progress, so open PRs are enough. **Dispute** mode corrects a | ||
| PR that "has already been merged" (per its own description above), so the | ||
| lookup must include closed/merged PRs too: | ||
|
|
||
| ```bash | ||
| # report | ||
| gh pr list --head "$(git branch --show-current)" --json number,url,title --limit 1 | ||
|
|
||
| # dispute | ||
| gh pr list --head "$(git branch --show-current)" --state all --json number,url,title,comments --limit 1 | ||
| ``` | ||
|
|
||
| If no PR is found for the current branch, ask the user for the PR number or | ||
| URL. | ||
|
|
||
| If the PR title does not start with `fix`, confirm with the user that they | ||
| still want to post a bug report comment before continuing — this command is | ||
| only required for `fix` PRs, but can be used on any PR. | ||
|
|
||
| For **dispute** mode specifically, before posting: check the resolved PR's | ||
| comments for a prior `@holdex bug commit <COMMIT_URL> && bug author | ||
| <HANDLE>` comment whose commit URL matches the one given in `$ARGUMENTS` | ||
| (the handle is expected to differ — that's the attribution being | ||
| corrected). Require exactly one such PR/comment match. If none match, or | ||
| more than one PR matches the branch/commit, stop without posting and tell | ||
| the user why instead of guessing. | ||
|
|
||
| ## Post the comment | ||
|
|
||
| Assign the validated URL, handle, and PR URL to shell variables first, quote | ||
| every expansion, and pass the body through `--body-file -` rather than | ||
| interpolating them into an inline `--body` string: | ||
|
|
||
| Report the commit/author that introduced the bug: | ||
|
|
||
| ```bash | ||
| COMMIT_URL="<commit-url>" | ||
| HANDLE="<handle>" | ||
| PR_URL="<pr-url>" | ||
| gh pr comment "$PR_URL" --body-file - <<EOF | ||
| @holdex bug commit $COMMIT_URL && bug author $HANDLE | ||
| EOF | ||
| ``` | ||
|
|
||
| Dispute a previous bug report: | ||
|
|
||
| ```bash | ||
| COMMIT_URL="<commit-url>" | ||
| HANDLE="<handle>" | ||
| PR_URL="<pr-url>" | ||
| gh pr comment "$PR_URL" --body-file - <<EOF | ||
| @holdex bug dispute $COMMIT_URL && bug author $HANDLE | ||
| EOF | ||
| ``` | ||
|
|
||
| Confirm the comment was posted and show the PR URL. | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.