Skip to content

meta: Add hook to auto-add Linear issue links#1131

Open
szokeasaurusrex wants to merge 1 commit into
masterfrom
szokeasaurusrex/pre-commit-hook
Open

meta: Add hook to auto-add Linear issue links#1131
szokeasaurusrex wants to merge 1 commit into
masterfrom
szokeasaurusrex/pre-commit-hook

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

Add a commit-msg pre-commit hook that expands GitHub issue footers into markdown links and appends a matching Linear footer when GitHub comments include a linked Linear issue. Running this as a hook ensures footer expansion happens for both agent-written and manually-written commit messages.

Add a commit agent skill that fetches Sentry commit guidelines before creating or amending commits and documents the footer format expected by the hook. I have been using a similar commit skill locally; this checks it into this repo with modifications for the new pre-commit hook.

Examples

A footer for getsentry/sentry-rust#1:

References #1

becomes:

References [#1](https://github.com/getsentry/sentry-rust/issues/1)

A footer for getsentry/sentry-rust#1130, which has a Linear linkback to RUST-216:

References #1130

becomes:

References [#1130](https://github.com/getsentry/sentry-rust/issues/1130)
References [RUST-216](https://linear.app/getsentry/issue/RUST-216)

Add a `commit-msg` `pre-commit` hook that expands GitHub issue footers into markdown links and appends a matching Linear footer when GitHub comments include a linked Linear issue. Running this as a hook ensures footer expansion happens for both agent-written and manually-written commit messages.

Add a commit agent skill that fetches Sentry commit guidelines before creating or amending commits and documents the footer format expected by the hook. I have been using a similar [commit skill](https://github.com/szokeasaurusrex/pi-agent/blob/85d169d0022f31c46cf7821e2f176bd739b1b2a2/skills/commit/SKILL.md) locally; this checks it into this repo with modifications for the new `pre-commit` hook.

### Examples

A footer for [#1](#1):

```
References #1
```

becomes:

```
References [#1](#1)
```

A footer for [#1130](#1130), which has a Linear linkback to [RUST-216](https://linear.app/getsentry/issue/RUST-216):

```
References #1130
```

becomes:

```
References [#1130](#1130)
References [RUST-216](https://linear.app/getsentry/issue/RUST-216)
```
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner May 22, 2026 14:04
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 22, 2026

RUST-216

@szokeasaurusrex szokeasaurusrex changed the title meta(commit): Add commit message helpers meta: Add hook to auto-add Linear issue links May 22, 2026
Copy link
Copy Markdown
Member Author

@szokeasaurusrex szokeasaurusrex May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is admittedly 100% vibe-coded 🤖

I have skimmed the script, and it looks reasonable, but did not fully read it. In my limited testing, it appears to work. Given that this is only used as a pre-commit script, I think that should be okay; we can fix bugs as they are discovered.

@szokeasaurusrex szokeasaurusrex requested a review from giortzisg May 22, 2026 14:12
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 80c71ac. Configure here.

from typing import Any

FOOTER_RE = re.compile(
r"^(?P<prefix>\s*)(?P<keyword>\w+)\s+"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex fails to match multi-word keywords documented in SKILL.md

Medium Severity

FOOTER_RE uses (?P<keyword>\w+) which only matches single-word keywords. The SKILL.md documents "Related to" and "Contributes to" as valid multi-word keywords, but lines like Related to #1130 will never match the regex — \w+ captures only "Related", then \s+ consumes the space, and "to #1130" fails the display group since # doesn't immediately follow "to". These footers are silently skipped with no warning, so agents following the documented format will produce unexpanded footers with no Linear links added.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 80c71ac. Configure here.

Run:

```bash
scripts/fetch-commit-guidelines.sh
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skill references nonexistent script path from repo root

Medium Severity

The SKILL.md instructs agents to run scripts/fetch-commit-guidelines.sh, but that path doesn't exist in the repo-root scripts/ directory (which only contains bump-version.sh, commit-msg-expand-issues.py, generate-readme.sh, and update-readme.sh). The actual script lives at .agents/skills/commit/scripts/fetch-commit-guidelines.sh. An agent executing this from the repository root will get a "file not found" error, causing the skill's first step (fetching commit guidelines) to fail entirely.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 80c71ac. Configure here.

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.

1 participant