-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add configurable stats mode with Git integration #17
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
krfantasy
wants to merge
4
commits into
master
Choose a base branch
from
stats-mode
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.
+527
−80
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bac585e
feat(output): add stats mode for summary change statistics
krfantasy 1b0da41
refactor(output): move `render_views` from `alsdiff.ml` to `text_rend…
krfantasy 1e02b4d
feat(scripts): add prepare-commit-msg hook option for stats-based com…
krfantasy 65c0cf5
feat(output): add configurable stats mode with config-driven type fil…
krfantasy 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
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
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
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
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,84 @@ | ||
| open View_model | ||
| open Config | ||
|
|
||
| let display_name (dt : domain_type) : string = | ||
| match dt with | ||
| | DTTrack -> "Tracks" | ||
| | DTDevice -> "Devices" | ||
| | DTClip -> "Clips" | ||
| | DTNote -> "Notes" | ||
| | DTAutomation -> "Automations" | ||
| | DTSend -> "Sends" | ||
| | DTParam -> "Parameters" | ||
| | DTLocator -> "Locators" | ||
| | _ -> domain_type_to_string dt | ||
|
|
||
| (* Build the initial stats list from config - include types not set to Ignore *) | ||
| let stats_from_config (cfg : detail_config) : (domain_type * change_breakdown) list = | ||
| (* All domain types we might track - check if they're not Ignored *) | ||
| let all_types = [ | ||
| DTLiveset; DTTrack; DTDevice; DTClip; DTNote; | ||
| DTAutomation; DTMixer; DTRouting; DTLocator; | ||
| DTParam; DTEvent; DTSend; DTPreset; DTMacro; | ||
| DTSnapshot; DTLoop; DTSignature; DTSampleRef; | ||
| DTVersion; DTOther; | ||
| ] in | ||
| (* Filter to types that should be tracked (not Ignore for their change type) *) | ||
| List.filter_map (fun dt -> | ||
| (* Check if any change type for this domain type is not Ignore *) | ||
| let trackable = | ||
| (get_effective_detail cfg Added dt <> Ignore) || | ||
| (get_effective_detail cfg Removed dt <> Ignore) || | ||
| (get_effective_detail cfg Modified dt <> Ignore) || | ||
| (get_effective_detail cfg Unchanged dt <> Ignore) | ||
| in | ||
| if trackable then Some (dt, { added = 0; removed = 0; modified = 0 }) | ||
| else None | ||
| ) all_types | ||
|
|
||
| let increment_stats stats dt ct = | ||
| List.map | ||
| (fun (d, b) -> if d = dt then (d, increment_breakdown b ct) else (d, b)) | ||
| stats | ||
|
|
||
| let rec collect_view (cfg : detail_config) (stats : (domain_type * change_breakdown) list) (view : view) = | ||
| match view with | ||
| | Field _ -> stats | ||
| | Item item -> | ||
| let stats = | ||
| (* Use get_effective_detail to check if type should be tracked *) | ||
| let level = get_effective_detail cfg item.change item.domain_type in | ||
| if should_render_level level && item.change <> Unchanged then | ||
| increment_stats stats item.domain_type item.change | ||
| else stats | ||
| in | ||
| List.fold_left (collect_view cfg) stats item.children | ||
| | Collection col -> List.fold_left (collect_view cfg) stats col.items | ||
|
|
||
| let collect (cfg : detail_config) (views : view list) : (domain_type * change_breakdown) list = | ||
| List.fold_left (collect_view cfg) (stats_from_config cfg) views | ||
|
|
||
| let render_line (dt : domain_type) (b : change_breakdown) : string option = | ||
| if total_breakdown b = 0 then None | ||
| else | ||
| let parts = | ||
| List.filter_map Fun.id | ||
| [ | ||
| (if b.added > 0 then Some (Printf.sprintf "%d Added" b.added) | ||
| else None); | ||
| (if b.removed > 0 then Some (Printf.sprintf "%d Removed" b.removed) | ||
| else None); | ||
| (if b.modified > 0 then Some (Printf.sprintf "%d Modified" b.modified) | ||
| else None); | ||
| ] | ||
| in | ||
| Some (Printf.sprintf "%s: %s" (display_name dt) (String.concat ", " parts)) | ||
|
|
||
| let render (cfg : detail_config) (views : view list) : string = | ||
| let stats = collect cfg views in | ||
| let lines = | ||
| List.filter_map (fun (dt, b) -> render_line dt b) stats | ||
| in | ||
| match lines with | ||
| | [] -> "No changes." | ||
| | _ -> String.concat "\n" lines |
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.
This branch returns
1for a stats-mode argument error even when--gitis active, which makes Git (trustExitCode) interpret the failure as "differences found" instead of an invalid invocation. In practice,alsdiff --git --mode stats --prefix-added ...will look like a real diff result rather than a configuration error, despite the command documentation in this file defining exit code2for invalid arguments. Return2in git mode for this path so misconfiguration is surfaced correctly.Useful? React with 👍 / 👎.