fix: propagate conventional commit type from child repo to sync PR - #69
Conversation
Instead of hardcoding feat: or fix:, fetch the child commit message via gh api and extract the conventional commit type. This means: - Child fix: commits → fix(repo): sync → patch bump - Child feat: commits → feat(repo): sync → minor bump (post-1.0) - Non-release types (chore, docs, etc.) → promoted to fix: so syncs always trigger a release Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe workflow now dynamically generates sync PR titles by querying the child repository's commit message and parsing conventional commit prefixes. Non-release-triggering commit types ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Greptile SummaryThis PR improves the Key changes:
Issues found:
Confidence Score: 3/5Merging carries a real risk of incorrect minor-version bumps if any child commit message starts with a conventional-commit keyword without the required colon delimiter. The regex on line 41 lacks the colon/scope guard that distinguishes an actual conventional commit type from an ordinary word at the start of a commit message. In the worst case a message beginning with 'feat' (without a colon) silently bypasses all promotion guards and forces a minor-bump PR title — a present, reproducible defect on the changed path. This warrants a P1 and a score of 3. .github/workflows/on-child-update.yml — specifically the COMMIT_TYPE extraction on line 41
|
| Filename | Overview |
|---|---|
| .github/workflows/on-child-update.yml | Adds conventional-commit-type extraction from the child repo's commit message to drive the sync PR title; the regex is missing a colon/scope delimiter that could produce incorrect semver bumps on non-conventional commit messages. |
Sequence Diagram
sequenceDiagram
participant CR as Child Repo
participant GHA as on-child-update workflow
participant GHAPI as GitHub API
participant Meta as harmony-labs/meta
CR->>GHA: repository_dispatch (child-repo-updated)<br/>payload: {repo_name, sha}
GHA->>GHAPI: GET /repos/harmony-labs/{repo}/commits/{sha}<br/>--jq '.commit.message'
GHAPI-->>GHA: commit message (first line)
note over GHA: grep -oE '^(feat|fix|perf|...)' ⚠️ no colon guard
note over GHA: case: feat/fix/perf → pass through<br/>anything else → promote to "fix"
GHA->>Meta: git push origin sync/{repo}/{sha}
GHA->>Meta: gh pr create --title "{type}({repo}): sync {sha}"
Meta-->>GHA: PR URL
GHA->>Meta: gh pr merge --auto --squash
Prompt To Fix All With AI
This is a comment left during a code review.
Path: .github/workflows/on-child-update.yml
Line: 41
Comment:
**Regex matches keyword prefixes, not full conventional commit types**
The pattern `'^(feat|fix|perf|refactor|docs|test|chore|ci|build|style)'` anchors at the start of the line but does **not** require a `:` or `(` after the type token. This means it will false-positive on ordinary prose commit messages:
| Commit message | Matched `COMMIT_TYPE` | Effect |
|---|---|---|
| `"feature: add login"` (wrong keyword) | `feat` | minor bump |
| `"performance improvements in rendering"` | `perf` | patch bump |
| `"testing out the new pipeline"` | `test` → `fix` | patch bump |
| `"chores: update deps"` (plural) | `chore` → `fix` | patch bump |
The first case is the most dangerous — a commit that starts with the string `feat` but lacks the colon will be promoted straight through to a minor-bump PR title without any promotion guard.
Add a word-boundary by requiring `[:(]` immediately after the keyword:
```suggestion
COMMIT_TYPE=$(echo "$COMMIT_MSG" | grep -oE '^(feat|fix|perf|refactor|docs|test|chore|ci|build|style)(\([^)]+\))?:' | grep -oE '^[a-z]+' | head -1)
```
This two-step match first validates that a colon (with optional scope) follows the type, then extracts just the bare keyword from that validated match.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: .github/workflows/on-child-update.yml
Line: 39-40
Comment:
**Silent API failure is hard to debug**
`2>/dev/null` suppresses all stderr from the `gh api` call, including actionable failures like an expired PAT, rate-limiting, or a typo in `REPO_NAME`. When the API fails silently the workflow just defaults to `fix:` with no indication of why, making it tricky to diagnose misconfigured secrets or incorrect payloads.
Consider logging the failure reason while still falling back gracefully:
```suggestion
COMMIT_MSG=$(gh api "repos/harmony-labs/${REPO_NAME}/commits/${FULL_SHA}" \
--jq '.commit.message' 2>&1 | head -1) || { echo "Warning: gh api failed, defaulting COMMIT_TYPE to fix"; COMMIT_MSG=""; }
```
Or keep `2>/dev/null` but add a note when the variable is empty:
```bash
if [[ -z "$COMMIT_MSG" ]]; then
echo "Warning: could not fetch commit message for ${REPO_NAME}@${FULL_SHA}, defaulting to fix:"
fi
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix: propagate conventional commit type ..." | Re-trigger Greptile
Summary
feat:(or previouslychore:), fetch the child commit message and extract the conventional commit typefix:→fix(repo): sync→ patch bumpfeat:→feat(repo): sync→ minor bump (post-1.0)chore,docs,test, etc.) → promoted tofix:so syncs always trigger a releaseAddresses review feedback from #67 —
feat:would bump minor after 1.0, but most child syncs should be patches.This PR is also a
fix:commit, so merging it will trigger release-please to create the release PR that includes the meta_git_cli#25 fix.Test plan
gh api repos/harmony-labs/REPO/commits/SHA --jq '.commit.message'returns the commit messagefix:push → sync PR title starts withfix(feat:push → sync PR title starts withfeat(chore:push → sync PR title starts withfix((promoted)🤖 Generated with Claude Code
Summary by CodeRabbit