Repository navigation
Conversation
Add internal/commits with pure Normalize/validate functions enforcing the project's Conventional Commits rules (known type set, lowercase type, lowercase subject, 72-char subject limit, whitespace trimming, and 72-column body wrapping). Wire it into the CLI as 'nightshift commit normalize' (positional, --file, and stdin sources; --check to validate only), ship a commit-msg git hook under scripts/, and document the format and installation in docs/commit-messages.md. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
- errcheck: handle fmt.Fprintln error in commit-normalize RunE - govet: replace deprecated reflect.Ptr alias with reflect.Pointer Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift
The commit-msg hook docs and hook header instruct users to run 'make install-hooks', but the target only installed the pre-commit hook. Also symlink scripts/commit-msg.sh so the documented command actually installs it. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
…and hook - commit-msg hook: disable errexit around the normalizer invocation so a failing command substitution no longer aborts the script before the error guidance runs; bad messages now print the expected format and exit 1 instead of failing silently. Also fix the quoted multi-word 'go run' fallback and use a mktemp error file. - commit normalize --check: actually validate instead of duplicating the rewrite path; exits non-zero (silently on success) when the message is invalid or not already in canonical form. - normalizer: accept and preserve the Conventional Commits '!' breaking change marker (feat! / feat(scope)!), lowercase the scope, and keep bullet-list body items on their own lines instead of merging them into prose; wrapped bullet continuation lines keep normalization idempotent. - CLI: drop the manual stderr print so errors are reported once by cobra, and silence the usage dump for runtime validation errors. - docs/tests updated to match; new table cases for '!', bullet lists, idempotency, and CLI-level tests for input resolution and canonicality. Nightshift-Task: commit-normalize Nightshift-Ref: https://github.com/marcus/nightshift
This was referenced Sep 23, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR brings the Conventional Commits message normalizer to the CLI, plus related lint and hook-install fixes.
Conventional Commits normalizer (commit-normalize)
internal/commits— pureNormalize/validate functions enforcing Conventional Commits rules:feat,fix,docs,style,refactor,test,chore,perf,build,ciFEAT(UI): …→feat(ui): …); unknown/missing types are hard errors!breaking-change marker is accepted and preserved (feat!:/feat(api)!:) per Conventional Commits 1.0.0-/*) stay on their own lines; git comment lines (#) are strippednormalizer_test.go)nightshift commit normalize— CLI command with positional arg,--file(for commit-msg hooks), stdin fallback, and--checkvalidation-only mode (prints nothing on success; non-zero exit when the message is invalid or not already in canonical form)scripts/commit-msg.sh— git commit-msg hook that normalizes the message file in place and rejects unfixable messages; install viamake install-hooksdocs/commit-messages.md— documents the format, the command, and the hookMakefile—install-hooksnow installs the commit-msg hook too (previously it only installed pre-commit, so the documented command didn't work)Lint fixes (lint-fix)
Fixes the 4 issues reported by
golangci-lint run(default config):errcheck (2) —
cmd/nightshift/commands/commit.gofmt.Fprintln(os.Stdout, normalized)in thecommit-normalizeRunE (lines 55 and 58). Now captured and returned as an error, consistent with the surrounding error handling.govet inline (2) —
cmd/nightshift/commands/config.goreflect.Ptrwithreflect.Pointerin theprintStructswitch (line 373) and theisZeroswitch (line 411).Review fixes (iteration 2)
Addresses the code-review findings on the initial implementation:
set -euo pipefail, theNORMALIZED=$(...)assignment aborted the script beforeSTATUS=$?, making the documented error-guidance block dead code and rejecting bad messages silently. Errexit is now disabled around the invocation, so bad messages print the expected format and exit 1. Also fixed the quoted multi-wordgo runfallback (it previously tried to exec a binary literally namedgo run …) and replaced the shared/tmperror file withmktemp+ cleanup trap.--checkwas a no-op — both branches printed the normalized message.--checknow validates only: silent on success, non-zero exit when the message is invalid or not already in canonical form (commit.goisCanonical).!breaking-change markers were rejected while the docs claimed Conventional Commits 1.0.0 compliance — now parsed and preserved with or without a scope; scope is lower-cased like the type.- item one - item two) — list items now stay on their own lines (with wrapped continuation lines kept in the list block so normalization remains idempotent).fmt.Fprintf(os.Stderr, …)(cobra already printsError: …) and setSilenceUsageso validation failures don't dump the usage text.commit_test.go).Verification
go build ./...→ succeedsgo vet ./...→ cleango test ./...→ all packages pass (incl.internal/commits)golangci-lint run→ 0 issues (baseline was 4)nightshift commit normalizevia positional/stdin/--file/--checkwith valid, bad-type, capitalized, overlong-subject, and multi-paragraph messages — output and exit codes as documented--checksilent-zero on canonical, non-zero otherwise;golangci-lint run→ 0 issuesNightshift-Task: commit-normalize
Nightshift-Ref: https://github.com/marcus/nightshift
Automated by nightshift