Repository navigation
fix(auto-commit): skip detached HEAD commits - #1754
akramcodez merged 2 commits into
Conversation
nc-review: comments — 1 important, 2 nits@ducanhnguyen223 — a few things worth a look, none blocking. The PR resolves both halves of #1747: it skips auto-commit when HEAD is detached (via 🟠 important · The PR is a user-facing bug fix (a new warning, a skipped-commit path, and a mandatory commit-trailer) but no ⚪ nit · The test covers detached HEAD and the one-time warning, but does not cover the diff branch added to ⚪ nit ·
🔴 blocking · 🟠 a reviewer would ask for a change · ⚪ optional Automated code review — correctness, security, design, tests, plus duplicates and scope. A human still decides; this is not a substitute for review and is not exhaustive. The required status checks separately cover lint, formatting, types, unused dependencies, the test suite and the build. This bot never merges. Maintainers can rerun with |
akramcodez
left a comment
There was a problem hiding this comment.
Thanks @ducanhnguyen223, I reviewed and ran it against real git: detached HEAD is now skipped with one warning, and commits on a branch carry a Nanocoder-Auto-Commit trailer that git log --grep finds. I also tidied the PR body to the template. One follow-up: docs/configuration/index.md should mention the new skip case and trailer. LGTM!
Description
Closes #1747.
With
nanocoder.autoCommiton, a commit made while HEAD is detached belongs to no branch and is easy to lose at the next checkout, and the user was not told. Auto-commits also carried no marker, so they could not be found later for squashing or review.git symbolic-ref --quiet HEAD), before the index is touched, and show one warning per repository.Nanocoder-Auto-Commit: truetrailer to agent-generated commits, sogit log --grep Nanocoder-Auto-Commitfinds them.git log --grep.Description reformatted to the PR template by a maintainer; the original verification notes are kept below.
Type of Change
Changeset
pnpm changeset) describing this change for the changelogTesting
Automated Tests
.spec.ts/tsxfilespnpm test:allcompletes successfully)All 17 hosted checks pass on the current head.
pnpm test:allis not ticked because the contributor's local run (macOS) stopped in AVA on failures unrelated to this change (see below); CI is the source of truth for the full suite.Contributor's verification at head d09e729
@nanocollective/nanocoder.git diff --check: passed.pnpm run test:all: format, lint and TypeScript stages passed (Biome printed a schema-version notice and an internal UTF-8 I/O diagnostic). AVA ended with 51 failed and 15 skipped tests, including CLI integration failures because the test harness mock forinkhas noTextexport, and macOS/varversus/private/varpath assertions. The script stopped at AVA, so Knip and the security stages did not run.Maintainer re-test (this branch merged into current
main, Linux)auto-commit.spec.ts: 24 passed;tsc --noEmitand Biome clean.mainand pass with this change.mainvs this PR: on a detached HEAD,mainmakes the commit (HEAD moves, no branch contains it) and this PR skips it with one warning. On a branch, the commit carries the trailer andgit log --grep/git interpret-trailers --parsefind it. A multi-paragraph model message keeps the trailer as its own final paragraph. Re-attaching to a branch resumes committing. A new repo with no commits is unaffected. A linked worktree on a branch commits; one created with--detachis skipped. Acommit-msghook that checks the subject line still passes.Manual Testing
Not applicable: the change only touches the git steps of auto-commit and does not depend on the provider or MCP.
Checklist
Open item:
docs/configuration/index.md("Auto-commit") still lists the skipped cases without detached HEAD and does not mention the new trailer. The warning reuses the existinglogWarningmessage-queue path, the same one as the "merge/rebase in progress" warning.