fix(issue-worker): avoid double prefix on conventional-commit titles#135
fix(issue-worker): avoid double prefix on conventional-commit titles#135
Conversation
When an issue title already begins with a conventional-commit prefix (feat:, fix:, chore:, etc.), the worker produced PR titles like "fix: feat: …". Detect known prefixes via a case statement and only prepend "fix: " when no convention is present. Same logic applied to the commit subject. Closes #134 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the ForgeCode issue worker to prevent generating PR titles (and commit subjects) with duplicated Conventional Commit prefixes when the source issue title already includes one.
Changes:
- Adds a
case-based prefix detector for known Conventional Commit types. - Uses computed
pr_titleforgh pr create --titleandcommit_subjectforgit commit -m.
| pr_title="$title" | ||
| commit_subject="address #${num} — ${title}" ;; |
There was a problem hiding this comment.
In the prefixed-title branch, commit_subject becomes address #N — ${title}, which no longer starts with a Conventional Commit type and also embeds the type later in the subject (e.g., address #1 — feat: ...). If commit messages are expected to be Conventional Commits (see CONTRIBUTING.md), consider extracting the existing type[(scope)] prefix from title and using it at the start of commit_subject (and strip it from the remainder), so the subject stays feat(...): address #N — <rest> / fix(...): ... etc.
| pr_title="$title" | |
| commit_subject="address #${num} — ${title}" ;; | |
| local commit_prefix commit_remainder | |
| if [[ "$title" =~ ^((fix|feat|chore|docs|test|refactor|perf|arch|build|ci|style|revert)(\([^)]+\))?:)[[:space:]]*(.*)$ ]]; then | |
| commit_prefix="${BASH_REMATCH[1]}" | |
| commit_remainder="${BASH_REMATCH[4]}" | |
| else | |
| commit_prefix="fix:" | |
| commit_remainder="$title" | |
| fi | |
| pr_title="$title" | |
| commit_subject="${commit_prefix} address #${num} — ${commit_remainder}" ;; |
| # Avoid double-prefixing when the issue title already carries a | ||
| # conventional-commit prefix (closes chitinhq/shellforge#134). | ||
| case "$title" in | ||
| fix:*|feat:*|chore:*|docs:*|test:*|refactor:*|perf:*|arch:*|build:*|ci:*|style:*|revert:*) | ||
| pr_title="$title" | ||
| commit_subject="address #${num} — ${title}" ;; | ||
| *) | ||
| pr_title="fix: $title" | ||
| commit_subject="fix: address #${num} — ${title}" ;; | ||
| esac |
There was a problem hiding this comment.
pr_title and commit_subject are introduced as implicit globals here (not declared local inside work_issue). To avoid accidental leakage between iterations/calls and to match the existing style in this function, declare them as local pr_title commit_subject before the case statement.
Closes #134
Summary
scripts/issue-worker.shunconditionally prependedfix:to PR titles and commit subjects, producingfix: feat: …when the source issue already carried a conventional-commit prefix (clawta#44/45/46).casestatement matching known prefixes (feat|fix|chore|docs|test|refactor|perf|arch|build|ci|style|revert) and only prependfix:when none is present. Same logic applied to the commit subject.Test plan
bash -n scripts/issue-worker.shpassesfeat:issue produces a single-prefix PR titleDo not auto-merge.
Generated with Claude Code