From 0cddb3e24acef0b7ffdf64d43ddd2f4f5fcdc276 Mon Sep 17 00:00:00 2001 From: vinyas-bharadwaj Date: Tue, 7 Oct 2025 19:20:18 +0000 Subject: [PATCH 1/4] fixed the issue with the logo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ff00131..e00e395 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ Looking to contribute? Check out: 📋 **Auto-Copy to Clipboard** - Generated messages are automatically copied for instant use 🎛️ **Interactive Review Flow** - Accept, regenerate with new styles, or open the message in your editor before committing 📊 **File Statistics Display** - Visual preview of changed files and line counts -� **Smart Security Scrubbing** - Automatically removes API keys, passwords, and sensitive data from diffs -�🚀 **Easy to Use** - Simple CLI interface with beautiful terminal UI -⚡ **Fast** - Quick generation of commit messages +🔒 **Smart Security Scrubbing** - Automatically removes API keys, passwords, and sensitive data from diffs +🚀 **Easy to Use** - Simple CLI interface with beautiful terminal UI +⚡ **Fast** - Quick generation of commit messages//img.shields.io/badge/Hacktoberfest-2025-orange. ## Supported LLM Providers From afbe485349643a2debc3d6665fdd150e43410009 Mon Sep 17 00:00:00 2001 From: vinyas-bharadwaj Date: Wed, 8 Oct 2025 18:59:20 +0000 Subject: [PATCH 2/4] Removed svg from the binary file filtering and fixed the rename/copy status parsing --- internal/git/operations.go | 103 ++++++++++++++++++++++++++----------- internal/utils/utils.go | 14 +++-- 2 files changed, 84 insertions(+), 33 deletions(-) diff --git a/internal/git/operations.go b/internal/git/operations.go index ee9e956..1146776 100644 --- a/internal/git/operations.go +++ b/internal/git/operations.go @@ -22,44 +22,56 @@ func IsRepository(path string) bool { return strings.TrimSpace(string(output)) == "true" } -// filterBinaryFiles filters out binary files from git diff --name-status output -func filterBinaryFiles(nameStatusOutput string) string { - if nameStatusOutput == "" { - return "" +// parseGitStatusLine represents a parsed git status line +type parseGitStatusLine struct { + status string + filenames []string +} + +// parseGitNameStatus parses a single line from git diff --name-status output +// Handles various git status codes including rename (R) and copy (C) operations +func parseGitNameStatus(line string) parseGitStatusLine { + if line == "" { + return parseGitStatusLine{} } - lines := strings.Split(strings.TrimSpace(nameStatusOutput), "\n") - var filteredLines []string + parts := strings.Fields(line) + if len(parts) < 2 { + return parseGitStatusLine{} + } - for _, line := range lines { - if line == "" { - continue - } - - // Parse git diff --name-status format (e.g., "M filename" or "A filename") - parts := strings.Fields(line) - if len(parts) >= 2 { - filename := strings.Join(parts[1:], " ") // Handle filenames with spaces - if !utils.IsBinaryFile(filename) { - filteredLines = append(filteredLines, line) + status := parts[0] + + // Handle rename/copy status codes (e.g., "R100", "C75") + if len(status) > 1 && (status[0] == 'R' || status[0] == 'C') { + // For rename/copy, we expect: "R100 oldname newname" or "C75 oldname newname" + if len(parts) >= 3 { + // For renames/copies, both old and new filenames need to be checked + oldFile := parts[1] + newFile := strings.Join(parts[2:], " ") // Handle spaces in new filename + return parseGitStatusLine{ + status: status, + filenames: []string{oldFile, newFile}, } } } - if len(filteredLines) == 0 { - return "" + // Handle regular status codes (M, A, D, etc.) + filename := strings.Join(parts[1:], " ") // Handle filenames with spaces + return parseGitStatusLine{ + status: status, + filenames: []string{filename}, } - - return strings.Join(filteredLines, "\n") } -// extractNonBinaryFiles extracts non-binary filenames from git diff --name-status output -func extractNonBinaryFiles(nameStatusOutput string) []string { +// processGitStatusOutput processes git diff --name-status output and returns filtered results +func processGitStatusOutput(nameStatusOutput string, returnFilenames bool) ([]string, []string) { if nameStatusOutput == "" { - return nil + return nil, nil } lines := strings.Split(strings.TrimSpace(nameStatusOutput), "\n") + var filteredLines []string var nonBinaryFiles []string for _, line := range lines { @@ -67,18 +79,49 @@ func extractNonBinaryFiles(nameStatusOutput string) []string { continue } - // Parse git diff --name-status format (e.g., "M filename" or "A filename") - parts := strings.Fields(line) - if len(parts) >= 2 { - filename := strings.Join(parts[1:], " ") // Handle filenames with spaces - if !utils.IsBinaryFile(filename) { - nonBinaryFiles = append(nonBinaryFiles, filename) + parsed := parseGitNameStatus(line) + if len(parsed.filenames) == 0 { + continue + } + + // Check if any of the filenames are binary + hasBinaryFile := false + for _, filename := range parsed.filenames { + if utils.IsBinaryFile(filename) { + hasBinaryFile = true + break + } + } + + // If no binary files found, include this line/files + if !hasBinaryFile { + filteredLines = append(filteredLines, line) + if returnFilenames { + nonBinaryFiles = append(nonBinaryFiles, parsed.filenames...) } } } + return filteredLines, nonBinaryFiles +} + +// filterBinaryFiles filters out binary files from git diff --name-status output +func filterBinaryFiles(nameStatusOutput string) string { + filteredLines, _ := processGitStatusOutput(nameStatusOutput, false) + + if len(filteredLines) == 0 { + return "" + } + + return strings.Join(filteredLines, "\n") +} + +// extractNonBinaryFiles extracts non-binary filenames from git diff --name-status output +func extractNonBinaryFiles(nameStatusOutput string) []string { + _, nonBinaryFiles := processGitStatusOutput(nameStatusOutput, true) return nonBinaryFiles } +} // GetChanges retrieves all Git changes including staged, unstaged, and untracked files func GetChanges(config *types.RepoConfig) (string, error) { diff --git a/internal/utils/utils.go b/internal/utils/utils.go index a91baeb..616af21 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -24,7 +24,7 @@ func IsTextFile(filename string) bool { ".ts", ".tsx", ".jsx", ".php", ".rb", ".rs", ".dart", ".sql", ".r", ".scala", ".kt", ".swift", ".m", ".pl", ".lua", ".vim", ".csv", ".log", ".cfg", ".conf", ".ini", ".toml", ".lock", ".gitignore", - ".dockerfile", ".makefile", ".cmake", ".pro", ".pri", + ".dockerfile", ".makefile", ".cmake", ".pro", ".pri", ".svg", } ext := strings.ToLower(filepath.Ext(filename)) @@ -34,6 +34,12 @@ func IsTextFile(filename string) bool { } } + // Files without extensions (like README, Dockerfile, Makefile) are treated as text + // This ensures consistent behavior for common configuration and documentation files + if ext == "" { + return true + } + return false } @@ -41,8 +47,8 @@ func IsTextFile(filename string) bool { func IsBinaryFile(filename string) bool { // List of common binary file extensions binaryExtensions := []string{ - // Images - ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".svg", ".ico", ".webp", + // Images (excluding SVG which is XML text) + ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif", ".ico", ".webp", // Audio/Video ".mp3", ".mp4", ".avi", ".mkv", ".mov", ".wmv", ".flv", ".wav", ".ogg", ".m4a", // Archives/Compressed @@ -65,6 +71,8 @@ func IsBinaryFile(filename string) bool { } } + // Note: Files with unknown extensions are not considered binary by default + // This allows them to be processed as text files for diff analysis return false } From e0752f3f7c9ef38a7df3770fe6e6b2a03e0dc9d8 Mon Sep 17 00:00:00 2001 From: vinyas-bharadwaj Date: Wed, 8 Oct 2025 19:06:14 +0000 Subject: [PATCH 3/4] Improved text file detection by checking common exesnsionless files like Makefile and Dockerfile --- internal/git/operations.go | 1 - internal/utils/utils.go | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/git/operations.go b/internal/git/operations.go index 1146776..dc08587 100644 --- a/internal/git/operations.go +++ b/internal/git/operations.go @@ -121,7 +121,6 @@ func extractNonBinaryFiles(nameStatusOutput string) []string { _, nonBinaryFiles := processGitStatusOutput(nameStatusOutput, true) return nonBinaryFiles } -} // GetChanges retrieves all Git changes including staged, unstaged, and untracked files func GetChanges(config *types.RepoConfig) (string, error) { diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 616af21..12a7177 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -34,10 +34,20 @@ func IsTextFile(filename string) bool { } } - // Files without extensions (like README, Dockerfile, Makefile) are treated as text - // This ensures consistent behavior for common configuration and documentation files + // Common extensionless files that are typically text if ext == "" { - return true + baseName := strings.ToLower(filepath.Base(filename)) + commonTextFiles := []string{ + "readme", "dockerfile", "makefile", "rakefile", "gemfile", + "procfile", "jenkinsfile", "vagrantfile", "changelog", "authors", + "contributors", "copying", "install", "news", "todo", + } + + for _, textFile := range commonTextFiles { + if baseName == textFile { + return true + } + } } return false From 654dad471e23273619a975d2a606f1dc8214a129 Mon Sep 17 00:00:00 2001 From: vinyas-bharadwaj Date: Wed, 8 Oct 2025 19:13:53 +0000 Subject: [PATCH 4/4] Fixes parsing of git --name-status output by splitting lines on tabs instead of spaces --- internal/git/operations.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/git/operations.go b/internal/git/operations.go index dc08587..a8947ee 100644 --- a/internal/git/operations.go +++ b/internal/git/operations.go @@ -35,7 +35,8 @@ func parseGitNameStatus(line string) parseGitStatusLine { return parseGitStatusLine{} } - parts := strings.Fields(line) + // Git uses tabs to separate fields in --name-status output + parts := strings.Split(line, "\t") if len(parts) < 2 { return parseGitStatusLine{} } @@ -44,11 +45,11 @@ func parseGitNameStatus(line string) parseGitStatusLine { // Handle rename/copy status codes (e.g., "R100", "C75") if len(status) > 1 && (status[0] == 'R' || status[0] == 'C') { - // For rename/copy, we expect: "R100 oldname newname" or "C75 oldname newname" + // For rename/copy, we expect: "R100\toldname\tnewname" or "C75\toldname\tnewname" if len(parts) >= 3 { // For renames/copies, both old and new filenames need to be checked oldFile := parts[1] - newFile := strings.Join(parts[2:], " ") // Handle spaces in new filename + newFile := parts[2] return parseGitStatusLine{ status: status, filenames: []string{oldFile, newFile}, @@ -57,7 +58,7 @@ func parseGitNameStatus(line string) parseGitStatusLine { } // Handle regular status codes (M, A, D, etc.) - filename := strings.Join(parts[1:], " ") // Handle filenames with spaces + filename := parts[1] return parseGitStatusLine{ status: status, filenames: []string{filename},