Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ test-adr:
@bash tests/adr-archive-test.sh
@bash tests/adr-golden-test.sh
@bash tests/adr-macro-test.sh
@docs/scripts/adr lint --check >/dev/null || { docs/scripts/adr lint; exit 1; }
@echo "adr tool tests passed."

test-unit:
Expand Down
5 changes: 4 additions & 1 deletion hooks/ways/documentation/adr/adr-tool
Original file line number Diff line number Diff line change
Expand Up @@ -1397,10 +1397,13 @@ def _frozen_snapshot(adr) -> Optional[tuple]:
# A record freezes where it lands: history is read from the default
# branch when there is one, so a decision still in review on a feature
# branch can be revised. Without a remote default, HEAD's history counts.
# --first-parent keeps to the branch's own line, so a pull request merged
# with a merge commit lands at the merge, not at the first commit on its
# branch; -m lists the merge's files against that parent on older git.
ref = (_git(['rev-parse', '--abbrev-ref', 'origin/HEAD'], root) or '').strip() or 'HEAD'
# --reverse drops pre-rename history under --follow, so read newest first
# and reverse here. -z keeps names with spaces or non-ASCII intact.
log = _git(['log', ref, '--follow', '-z', '--format=commit:%H', '--name-only', '--', str(rel)], root)
log = _git(['log', ref, '--first-parent', '-m', '--follow', '-z', '--format=commit:%H', '--name-only', '--', str(rel)], root)
if not log:
return None
entries, commit = [], None
Expand Down
5 changes: 4 additions & 1 deletion hooks/ways/documentation/adr/src/rules_v1_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,13 @@ def _frozen_snapshot(adr) -> Optional[tuple]:
# A record freezes where it lands: history is read from the default
# branch when there is one, so a decision still in review on a feature
# branch can be revised. Without a remote default, HEAD's history counts.
# --first-parent keeps to the branch's own line, so a pull request merged
# with a merge commit lands at the merge, not at the first commit on its
# branch; -m lists the merge's files against that parent on older git.
ref = (_git(['rev-parse', '--abbrev-ref', 'origin/HEAD'], root) or '').strip() or 'HEAD'
# --reverse drops pre-rename history under --follow, so read newest first
# and reverse here. -z keeps names with spaces or non-ASCII intact.
log = _git(['log', ref, '--follow', '-z', '--format=commit:%H', '--name-only', '--', str(rel)], root)
log = _git(['log', ref, '--first-parent', '-m', '--follow', '-z', '--format=commit:%H', '--name-only', '--', str(rel)], root)
if not log:
return None
entries, commit = [], None
Expand Down
14 changes: 14 additions & 0 deletions tests/adr-golden-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ fresh v1
edit docs/architecture/system/ADR-110-old-v0-record.md "s.replace('status: Accepted\n', 'contract: adr/v1\nkind: decision\nverb: add\ncapability: ingest\nstatus: accepted\nagent: {name: Claude, model: fixture-model}\nbasis:\n - evidence: migrated from v0\n').replace('# ADR-110: An unmigrated v0 record\n', '# ADR-110: An unmigrated v0 record\n\n## Summary\n\n- **Probes:** *Confident:* a. *Not confident:* b.\n- **Inversion:** c.\n')"
capture v1-frozen-migrated lint docs/architecture/system/ADR-110-old-v0-record.md

# A record accepted on a review branch and revised there freezes where it
# merges, not at the branch's first accepted commit; editing it after the
# merge still fails.
fresh v1
(cd "$WORK/repo" && git switch -q -c review)
edit docs/architecture/system/ADR-113-operator-proposed.md "s.replace('status: proposed\n', 'status: accepted\nconsidered: [{operator: developer, said: \"yes\", via: PR 13}]\n')"
commit_all accept
edit docs/architecture/system/ADR-113-operator-proposed.md "s.replace('basis:\n', 'basis:\n - evidence: a review fix\n', 1)"
commit_all "review fix"
(cd "$WORK/repo" && git switch -q - && git merge -q --no-ff -m "merge review" review)
capture v1-frozen-merged-branch lint docs/architecture/system/ADR-113-operator-proposed.md
edit docs/architecture/system/ADR-113-operator-proposed.md "s.replace(' - evidence: a review fix\n', '')"
capture v1-frozen-merged-branch-edited lint docs/architecture/system/ADR-113-operator-proposed.md

# A non-UTF-8 blob in a record's history does not stop lint.
fresh v1
printf 'binary \377\376 junk\n' > "$WORK/repo/docs/architecture/system/ADR-102-ingest-spec.md"
Expand Down
20 changes: 20 additions & 0 deletions tests/fixtures/adr/golden/v1-frozen-merged-branch-edited.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Scanned: 1 ADRs

Status distribution:
accepted: 1

Contract: adr/v1 (1 v0 records remain)

────────────────────────────────────────────────────────────
Issues found in 1 files:
────────────────────────────────────────────────────────────

docs/architecture/system/ADR-113-operator-proposed.md
❌ 'basis' changed after the decision left proposed; only concern, considered, enacted, status, superseded_by may change

════════════════════════════════════════════════════════════
Summary: 1 errors, 0 warnings
════════════════════════════════════════════════════════════

[exit 0]
13 changes: 13 additions & 0 deletions tests/fixtures/adr/golden/v1-frozen-merged-branch.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Scanned: 1 ADRs

Status distribution:
accepted: 1

Contract: adr/v1 (1 v0 records remain)

════════════════════════════════════════════════════════════
Summary: 0 errors, 0 warnings
════════════════════════════════════════════════════════════

[exit 0]
Loading