Skip to content

feat: add CGW_LOG_DIR and accept autosquash subjects - #114

Merged
forkni merged 2 commits into
developmentfrom
feat/log-dir-fixup-subjects
Dec 3, 2026
Merged

forkni merged 2 commits into
developmentfrom
feat/log-dir-fixup-subjects

Conversation

@forkni

@forkni forkni commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • CGW_LOG_DIR: a new setting (environment or .cgw.conf, registry row in _config.sh) for the folder the scripts write their logs to. It is created if missing. An absolute path is used as written; a relative path is taken from the project root. Empty (the default) keeps logs/ in the project root, as before. A leading ~/ means $HOME, and a root folder (/, C:/) keeps its slash. With the setting, the log file names get the PID added (<script>_<timestamp>_<pid>.log), so two worktrees that share the folder never write the same file. A folder that cannot be made falls back to logs/ with a [WARN]. The new cgw_log_dir in _common.sh gives the folder to init_logging.
  • Autosquash subjects: cgw_validate_commit_message now removes leading fixup! , squash! and amend! markers (also nested) before it checks the subject. commit_enhanced.sh "fixup! feat: x" passes; fixup! wip: x and fixup! add x are still refused. The subject-length caps already measure the text after the first colon, so the markers do not count. undo_last.sh amend-message and hooks/pre-push use the same check.
  • Pre-push guard: hooks/pre-push refuses an autosquash commit pushed to a guarded branch (source, target or protected), with the rebase_safe.sh --squash-last <N> --autosquash --non-interactive remedy. On a feature branch it is pushed. Before this change the hook refused these commits on every branch, so the guarded branches keep their old protection.
  • Docs: cgw.conf.example, the docs/configuration.md options table, skill/SKILL.md, skill/references/script-reference.md, error-recovery.md, wrapper-recipes.md, CONTEXT.md (commit-message format) and a CHANGELOG.md "Unreleased" entry.

Why

A retro of a HyprZero session on 2026-12-02 found two frictions with the vendored scripts/git/:

  1. Each linked worktree got a logs/ folder from the wrappers. Claude Code's auto mode refused to delete it until the user added a narrow allow rule. A linked worktree reads the main worktree's .cgw.conf, so one absolute CGW_LOG_DIR there keeps logs/ out of every worktree, and nothing must be deleted.
  2. Folding review fixes into two earlier commits needed fixup! commits. commit_enhanced.sh refused them as non-conventional, so they were made with raw git commit --fixup and then squashed with rebase_safe.sh --squash-last 4 --autosquash --non-interactive. Now the wrapper can make them.

Test plan

  • New unit tests (tests/unit/common.bats): absolute and relative CGW_LOG_DIR, the empty default, Windows drive paths, root folders and ~/, the PID in the file names, the fallback when the folder cannot be made, .cgw.conf and the environment winning over it; autosquash subjects accepted, nested, with CGW_EXTRA_PREFIXES; invalid rests and malformed markers refused; cgw_is_autosquash_subject; subject length without the markers.
  • New integration tests: a fixup! commit through commit_enhanced.sh, then rebase_safe.sh --autosquash folds it; fixup! wip: b is still refused; CGW_LOG_DIR in the main .cgw.conf keeps a linked worktree free of logs/; without it the logs still go to logs/ (commit_enhanced.bats). Pre-push: a fixup! commit on a feature branch is pushed, an invalid one is refused, a squash! commit to main is refused (pre_push_hook.bats).
  • Red before the fix: with the old _common.sh, _config.sh and hooks/pre-push, 14 of the 19 new tests fail. The 5 that pass check behaviour that must stay the same (invalid rests refused, length measure, default logs/).
  • Review fixes (b1d5a83): the 13 logging tests (init_logging, cgw_log_dir, CGW_LOG_DIR) in common.bats and commit_enhanced.bats, and config_registry.bats, pass on Windows. The full Windows run below is from bb78a63; all CI checks are green on b1d5a83.
  • Full suite on Windows (at bb78a63), tests/run.sh --all: 1,719 tests, 11 skipped, 1 failure: commit_enhanced_modes 16 (index.lock wait). It passes 3 of 3 alone on this branch; PR fix: a project-owned .cmd shim no longer keeps a stale AGY install #109 reported the same timing flake under parallel load.
  • ShellCheck (--severity=error on scripts, hooks and the changed .bats files), shfmt -d -i 2 -ci, markdownlint, tests/verify_skill_commands.sh and tests/lint_doc_snippets.sh are clean. typos is not installed locally; CI runs it.

The HyprZero copy of scripts/git/ gets this on its next sync_cgw_tooling.sh run.

🤖 Generated with Claude Code

forkni and others added 2 commits December 2, 2026 22:07
CGW_LOG_DIR (env or .cgw.conf) moves the log folder out of the project, so a linked worktree no longer gets a logs/ folder of its own. Empty keeps logs/ in the project root. A relative path is taken from the project root; cgw_log_dir in _common.sh resolves it.

cgw_validate_commit_message removes leading fixup!/squash!/amend! markers (also nested) before it checks the subject, so commit_enhanced.sh can make the fixup commits that rebase_safe.sh --autosquash folds. An invalid rest is still refused. hooks/pre-push refuses such a commit on a guarded branch (source, target, protected), as it did before for every branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of PR 114: with a shared CGW_LOG_DIR, two worktrees could write the same <script>_<timestamp>.log in the same second, so the file names get the PID added when the setting is used. A folder that cannot be made now falls back to logs/ with a [WARN] (mkdir was unchecked). A root (/, C:/) keeps its slash, and a leading ~/ is expanded to HOME, since .cgw.conf values are read literally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@forkni
forkni merged commit eb47d54 into development Dec 3, 2026
9 checks passed
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