šŸ› fix(kavach): checkout-discards-uncommitted passes conflict resolution, and commit-body-ref-line-length matches commitlint, 0.8.14

Merged
AT
2d ago
+235-19

Slice: #642
Refs athya-hq/athya_mono#3606

Under work item #43. Alok asked for it in chat on 2026-11-27. The slice waits on his šŸ‘ on https://github.com/veda-hq/veda/issues/642#issuecomment-7201824063, and this pull request merges only after that.

Two kavach command rules fired where the command was right, so athya_mono kept both at warn (#3606):

  • checkout-discards-uncommitted: 27 of its 66 live fires were git checkout --ours|--theirs|-m resolving merge conflicts.
  • commit-body-ref-line-length: it fires on lines that commitlint lets through.

What changes:

  • uncommitted() leaves out the paths git status shows unmerged (DD AU UD UA DU AA UU). Overwriting one, with a side or a ref, is how a conflict is resolved, and git refuses the plain forms over it ("path is unmerged"). The exemption depends on the path's state, not on the flag. On a path outside the conflict, git's --ours, --theirs, -m, restore --ours and restore --merge all silently overwrite a local edit with the index, so those still fire. In a command that names both kinds, the fire names only the changed path. The message no longer says "resolve hunk by hunk".
  • commit_body_ref_line_length ports commitlint's own exemptions rather than approximating them:
    • the URL regex of @commitlint/ensure's max-line-length;
    • the default ignores of @commitlint/is-ignored (lib/defaults.js), each with its JavaScript flags. The two Merge patterns are /m, so they match at any line. The others anchor at the start.
    • isSemver, with semver's FULL regex, its 256-character limit and its safe-integer check.
  • git commit --fixup and --squash pass, because git writes their fixup!/squash! subject itself. commit_messages returns None for them.
  • uncommitted()'s filter reads the path once, (path := entry[3:]). The old len(entry) > 3 left mutants that no git output can tell apart.
  • The README rule rows and the held-by lines in docs/lessons/git-github.md.
  • kavach and sarathi move to 0.8.14, the next legal version after v0.8.13. sarathi's VERSION follows.

Tests (test_rules.py):

  • CheckoutDuringAMerge is a stopped merge with c.txt UU, d.txt AA and a.txt edited.
    • Nine resolution forms pass, --theirs -- c.txt d.txt among them: --ours, --theirs, -m, HEAD --, other --, restore --ours, restore --source=HEAD -SW, and plain --.
    • --ours -- a.txt, --theirs -- c.txt a.txt, --theirs -- . and -m -- a.txt fire, naming only a.txt.
    • Once c.txt and d.txt are added, they count as changed again.
  • CommitBodyRefLineLength.COMMITLINT: each message is pinned to the outcome @commitlint/lint 20.2 gives it with footer-max-line-length at 100. The outcomes were run on 2026-11-27, near misses included: revert:, xhttps://, a bare https://, HTTPS://, 1.2, 01.2.3, 1.2.3-alpha.01, a skip tag twice, merge branch, Merged PR in the body, 2^53 against 2^53 āˆ’ 1, and the re.ASCII cases (a URL after Ć© passes, 1Ł”.2.3 fires).
  • --fixup and --squash, each with a body -m that would fire otherwise; -m "--fixup" is still judged.
  • An ignored commit followed by a judged one in the same command; a body line right under the subject.
  • I hand-applied 31 mutants of the changed lines to a copy, as #594 did, and each made the rule tests fail. The CI gate has the last word.

athya_mono pins @commitlint/lint 20.2.0, the release these outcomes come from. Its config-conventional makes body-max-line-length (100) an error as well as the footer rule. A long line holding #3606., #3606: or `#3606` is therefore not a reference to the parser, which wants a space, ,, ;, ), ] or the end after it, and it still fails as body. So kavach's remaining fires all fail commitlint there too (probed both ways). Under the footer rule alone those three shapes would pass, and kavach would still fire. kavach matches commitlint's default ignores only, not athya_mono's own Mergify Merge of #N entry: the queue writes those commits, not a session's git commit.

Open #645 sets dvara to 0.8.14 too. One v0.8.14 tag releases all three if it comes after both merge. If v0.8.14 is tagged before this merges, this moves to 0.8.15.

Next under this slice: tag v0.8.14 (or the version it ends on) after this merges, then veda's pin bump to sarathi and kavach 0.8.14. athya_mono's pin bump and the two flips are athya_mono pull requests under #3606.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes two kavach command rules that fired on commands that were right, which kept both at warn in athya_mono (#3606): checkout-discards-uncommitted flagged git checkout --ours/--theirs/-m resolving merge conflicts (27 of its 66 live fires), and commit-body-ref-line-length fired on lines commitlint accepts.

  • Paths git status shows as unmerged (DD AU UD UA DU AA UU) no longer count as uncommitted: overwriting one is how a conflict is resolved. Other changed paths the command names still fire, naming only that path.
  • commit_body_ref_line_length now ports commitlint's own exemptions — the @commitlint/ensure URL regex, the @commitlint/is-ignored default ignores, and semver's FULL regex — so it fires only where commitlint fails.
  • git commit --fixup/--squash pass, because git writes its own subject for them.
  • Tests pin each case to @commitlint/lint 20.2 outcomes at footer-max-line-length 100, near misses included; each of 31 hand-applied mutants made the rule tests fail.
  • kavach and sarathi move to 0.8.14; README rule rows and the held-by lines in docs/lessons/git-github.md updated. Tag v0.8.14 after this merges, or the version becomes 0.8.15.