RepoDiff is a tool designed to simplify code reviews by generating dynamic git diffs between two commits or branches. It optimizes diffs for analysis by large language models (LLMs) with features like context line adjustment.
- Generate diffs between two commits or branches with a single pass
- Configurable file pattern matching for different file types
- Adjustable context lines per file pattern
- Token counting for estimating LLM query costs
- Combines all changes into a single, well-formatted output
- High performance Rust implementation
- Go to the Releases page.
- Download the latest version of the
repodiff.exe
executable. - Move the
repodiff.exe
file to a directory included in your system'sPATH
.
Clone the repository and navigate to the directory:
git clone https://github.com/EntityProcess/RepoDiff.git
cd RepoDiff
Build the Rust executable:
# On Windows, run:
cd repodiff
cargo build --release
The compiled binary will be available at target/release/repodiff.exe
(Windows) or target/release/repodiff
(Linux/macOS).
To compare the latest commit in the current branch with the latest common commit in another branch:
repodiff -b main -o output.txt
repodiff -c abc1234 -d 5678def -o output.txt
Parameters:
-b
,--branch
: Branch to compare with (e.g.,main
ormaster
)-c
,--commit1
: First commit hash-d
,--commit2
: Second commit hash-o
,--output_file
: (Optional) Path to the output file. If not provided, the diff will be written to a default file in the system's temporary directory.-v
,--version
: Display the current version of RepoDiff-h
,--help
: Print help information
RepoDiff uses a config.json
file in the project root directory. Example configuration:
{
"tiktoken_model": "gpt-4o",
"filters": [
{
"file_pattern": "*.cs",
"context_lines": 999
},
{
"file_pattern": "*Test*.cs",
"context_lines": 200
},
{
"file_pattern": "*.xml",
"context_lines": 10
},
{
"file_pattern": "*",
"context_lines": 3
}
]
}
Configuration options:
tiktoken_model
: Specifies the language model for token counting (e.g., "gpt-4o").filters
: An array of filter rules that determine how different files are processed.file_pattern
: Glob pattern to match files (e.g., "*.cs", "Test.cs").context_lines
: Number of context lines to show around changes (default: 3).
Filter rules are applied in order, with the first matching pattern being used.
The tool generates a unified diff format with some enhancements:
- Standard git diff headers for each file.
- Modified hunks based on the applied filters:
- Adjusted context lines based on file patterns
- Original line numbers preserved
Example output:
diff --git a/src/MyClass.cs b/src/MyClass.cs
--- a/src/MyClass.cs
+++ b/src/MyClass.cs
@@ -10,7 +10,7 @@ public class MyClass
public void ProcessData(int value)
{
- var result = value * 2;
+ var result = value * 3;
return result;
}
- Rust: If building from source, you need Rust installed on your system.
- Git: Required for generating diffs.
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.