|
1 | 1 |
|
2 | 2 | # GitDiff4LLM |
3 | 3 |
|
4 | | -**GitDiff4LLM** is a tool designed to simplify code reviews by generating comprehensive git diffs between two commits, branches, or pull requests. It combines diffs into a single output file optimized for consumption by large language models (LLMs). |
| 4 | +**GitDiff4LLM** is a tool designed to simplify code reviews by generating comprehensive git diffs between two commits or branches. It allows you to configure diff options based on file paths, optimizing the output for consumption by large language models (LLMs). |
5 | 5 |
|
6 | 6 | ## Features |
7 | 7 |
|
@@ -38,13 +38,51 @@ gitdiff4llm -c1 <commit1> -c2 <commit2> [-o /path/to/output_file.txt] |
38 | 38 | * `-c2`, `--commit2`: Second commit hash. |
39 | 39 | * `-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. |
40 | 40 |
|
| 41 | +### Configuring Diff Options |
| 42 | + |
| 43 | +You can customize the diff options using a `config.json` file. This allows you to apply different diff strategies depending on the file path. |
| 44 | + |
| 45 | +For example: |
| 46 | + |
| 47 | +```bash |
| 48 | +{ |
| 49 | + "tiktoken_model": "gpt-4o", |
| 50 | + "diffs": [ |
| 51 | + ["-U50", "--ignore-all-space", "--", ":!*Test*"], |
| 52 | + ["-U20", "--ignore-all-space", "--", "*Test*"] |
| 53 | + ] |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +Explanation of the options: |
| 58 | + |
| 59 | +* `tiktoken_model`: This specifies the language model you're using (for example, gpt-4o), which helps estimate how many tokens the output will contain. |
| 60 | +* `diffs`: This is a list of different comparison rules. Each rule has settings that control how Git compares the files: |
| 61 | + * `-U50`: Show 50 lines of context around changes (default is 3 lines). |
| 62 | + * `--ignore-all-space`: Ignore spaces when comparing files (useful when whitespace changes don't matter). |
| 63 | + * `--`: Signals the end of options and the start of file patterns. |
| 64 | + * `:!*Test*`: Exclude files with Test in their path. |
| 65 | + * `*Test*`: Include only files with Test in their path. |
| 66 | + |
| 67 | +This setup means: |
| 68 | +* For most files, it shows a larger context (50 lines around each change) and ignores spaces. |
| 69 | +* For test files (*Test*), it shows fewer lines of context (20 lines) and also ignores spaces. |
| 70 | + |
41 | 71 | ## Prerequisites |
42 | 72 |
|
43 | 73 | - **PowerShell (Windows Only)**: If you're using Windows, you need to run the script in PowerShell. The pattern matching functionality in the script will not work properly in Command Prompt (`cmd`). |
44 | 74 | - **Python 3.x**: Ensure Python is installed on your system. |
45 | 75 |
|
46 | 76 | ## Installation |
47 | 77 |
|
| 78 | +### Option 1: Download the Executable |
| 79 | + |
| 80 | +1. Go to the [Releases](https://github.com/EntityProcess/GitDiff4LLM/releases) page. |
| 81 | +2. Download the latest version of the `gitdiff4llm.exe` executable. |
| 82 | +3. Move the `gitdiff4llm.exe` file to a directory included in your system's `PATH`. |
| 83 | + |
| 84 | +### Option 2: Build the Executable Yourself |
| 85 | + |
48 | 86 | Clone the repository and navigate to the directory: |
49 | 87 |
|
50 | 88 | ```bash |
|
0 commit comments