Skip to content

Commit 3e1c2bb

Browse files
committed
fix: Adjust regex for diff stats output
The regex for parsing the output of `git diff --cached --stat` was too strict. It did not account for the pluralization of "insertion" and "deletion". This change makes the regex more flexible to handle both singular and plural forms, ensuring accurate parsing of the diff statistics. --- {"auto-commit-msg":{"language":"rust","version":"0.4.0-dev","model":"gemini-2.5-flash-lite","response_time":1.62,"execution_time":1.65}}
1 parent 1b54799 commit 3e1c2bb

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ var rootCmd = &cobra.Command{
7272
if preCommitDetected {
7373
commitSource = os.Getenv("PRE_COMMIT_COMMIT_MSG_SOURCE")
7474
}
75+
7576
if commitSource != "" {
7677
log.Printf("Commit source '%s' is not empty, skipping commit message generation\n", commitSource)
7778
return nil

internal/git/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func DiffCachedStats() (*Stats, error) {
2828
return nil, err
2929
}
3030

31-
re := regexp.MustCompile(`\s+(\d+)\s+files? changed,\s+(\d+)\s+insertions\(\+\),\s+(\d+)\s+deletions\(\-\)`)
31+
re := regexp.MustCompile(`\s+(\d+)\s+files? changed,\s+(\d+)\s+insertions?\(\+\),\s+(\d+)\s+deletions?\(\-\)`)
3232
matches := re.FindStringSubmatch(string(output))
3333
if len(matches) < 4 {
3434
return nil, errors.New("TODO")

0 commit comments

Comments
 (0)