Repository navigation
Draw commit records as semantic diffs of the compiler's objects #8882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cristianoc
wants to merge
1
commit into
master
Choose a base branch
from
cristianoc/record-object-kinds
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,671
−1,030
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Draw commit records as semantic diffs of the compiler's objects, each kind of object in its own drawing, and extract the exact forms a record abstracts from the compiler with `scripts/recordFacts.js`. https://github.com/rescript-lang/rescript/pull/8882 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #!/bin/bash | ||
|
|
||
| # commit-msg hook: the commit message is a commit record | ||
| # (.claude/skills/records/SKILL.md). Every commit carries the required | ||
| # trailers Area, Output, Tests and Signed-off-by, with Signed-off-by last; a | ||
| # commit that changes the compiler, the runtime, the build system or the | ||
| # editor tooling also has a Why: section and at least one change block naming | ||
| # the object it changes. Enable it in a checkout with | ||
| # ln -sf "$PWD/scripts/commitRecordHook.sh" "$(git rev-parse --git-path hooks)/commit-msg" | ||
|
|
||
| exec 1>&2 | ||
|
|
||
| message_file=$1 | ||
| git_dir=$(git rev-parse --git-dir) | ||
|
|
||
| # a merge commit has no record of its own | ||
| if [[ -f "$git_dir/MERGE_HEAD" ]]; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| body=$(grep -v '^#' "$message_file") | ||
| # fixup! and squash! commits are folded into a recorded commit | ||
| case "$body" in | ||
| fixup!*|squash!*|amend!*) exit 0 ;; | ||
| esac | ||
|
|
||
| trailers=$(printf '%s\n' "$body" | git interpret-trailers --parse) | ||
| value() { | ||
| printf '%s\n' "$trailers" | sed -n "s/^$1: //p" | head -n 1 | ||
| } | ||
|
|
||
| problems=() | ||
| for key in Area Output Tests Signed-off-by; do | ||
| if ! printf '%s\n' "$trailers" | grep -q "^$key: "; then | ||
| problems+=("no '$key:' trailer") | ||
| fi | ||
| done | ||
| last=$(printf '%s\n' "$trailers" | tail -n 1) | ||
| if [[ -n "$last" && "$last" != Signed-off-by:* ]]; then | ||
| problems+=("the last trailer is '${last%%:*}'; Signed-off-by is the last trailer") | ||
| fi | ||
|
|
||
| output=$(value Output) | ||
| case "$output" in | ||
| unchanged*|changed*|"") ;; | ||
| *) problems+=("Output '$output' starts with neither 'unchanged' nor 'changed'") ;; | ||
| esac | ||
| tests=$(value Tests) | ||
| case "$tests" in | ||
| "none, because "?*|[+~-]?*|"") ;; | ||
| none*) problems+=("Tests: none gives its reason as 'none, because <reason>'") ;; | ||
| *) problems+=("Tests lists tests as +added ~changed -removed paths, or is 'none, because <reason>'") ;; | ||
| esac | ||
|
|
||
| if git diff --cached --name-only | | ||
| grep -Eq '^(compiler|rewatch/src|analysis|tools/src|packages/@rescript/(runtime|belt))/'; then | ||
| kinds='Syntax|Format|AST|Transform|Typing|Typedtree|Diagnostic|Matching|Lambda|IR|Representation|JS|API|TypeScript|Editor|Build|Semantics|Code' | ||
| if ! printf '%s\n' "$body" | grep -q '^Why:'; then | ||
| problems+=("no 'Why:' section (the problem this commit addresses)") | ||
| fi | ||
| if ! printf '%s\n' "$body" | grep -Eq "^($kinds) (added|modified|removed)( \(.*\))?:"; then | ||
| problems+=("no change block such as 'Typing modified (rule name):' or 'Code added (module):'") | ||
| fi | ||
| fi | ||
|
|
||
| if (( ${#problems[@]} )); then | ||
| echo "The commit message is not a commit record:" | ||
| for p in "${problems[@]}"; do | ||
| echo " - $p" | ||
| done | ||
| echo "Format: .claude/skills/records/SKILL.md. The trailers are the last block of" | ||
| echo "the message, one 'Key: value' per line; git interpret-trailers --parse reads them." | ||
| exit 1 | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include
rewatch-ocaml/in this source-path predicate. When a commit stages a file such asrewatch-ocaml/build_state.ml, the condition is false, so the new hook accepts the commit without the requiredWhy:section or change block even though this directory contains the OCaml build-system implementation.AGENTS.md reference: AGENTS.md:L35-L38
Useful? React with 👍 / 👎.