Skip to content

Commit 4f25212

Browse files
feat: add comparison mode and improve CLI options
- Add explicit mode flag (-m) to control comparison behavior - Remove auto-detection of commit mode - Update CLI help text with mode-specific examples
1 parent 1aef82b commit 4f25212

File tree

4 files changed

+58
-58
lines changed

4 files changed

+58
-58
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ Thumbs.db
4040
# Optional
4141
*.log
4242
*.pid
43-
*.seed
43+
*.seed
44+
45+
# GitLoom Diff
46+
/git-diffs

README.md

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,45 +33,33 @@ gitloom-diff -s feature/awesome -e main
3333

3434
## Why You'll Love This
3535

36-
GitHub, GitLab, or any other git provider diffs can be hard to parse - especially for large changes. This tool gives you a better diff experience with:
37-
38-
- 🚀 **Beautiful Local Diffs**
39-
- Works with any git provider
40-
- Syntax highlighting
41-
- Clean, consistent formatting
42-
43-
- 📝 **Markdown Export Ready For**:
44-
- 📄 Documentation & issue tracking
45-
- 🤖 AI code review (ChatGPT, Claude)
46-
- 📊 PR summaries & release notes
47-
- 🔍 Security audits
48-
49-
- 🔧 **Full IDE Power**:
50-
- 🔍 Fast full-text search
51-
- 🎯 Regex & pattern matching
52-
- 🌳 File tree navigation
53-
- 🖼️ Rich markdown preview
54-
- 🔖 Bookmarking changes
55-
56-
## Features In Detail
57-
58-
- 📊 **Smart Analysis**
59-
- Per-file change statistics
60-
- Commit message history
61-
- File diff summaries
62-
- Progress tracking for large diffs
63-
64-
- 🧹 **Intelligent Filtering**
65-
- Excludes build artifacts
66-
- Skips dependency files
67-
- Removes sensitive data
68-
- Customizable patterns
69-
70-
- 💡 **Flexible Comparison**
71-
- Between any commits
72-
- Across branches
73-
- Between tags
74-
- With remote branches
36+
GitHub, GitLab, or any other git provider diffs are often overwhelming - endless scrolling, no search, and hard to navigate between files. This tool generates clean markdown diffs that you can:
37+
38+
- 🚀 **Open in Your Favorite IDE/Editor**
39+
- Use your IDE's search & navigation
40+
- Navigate diffs with familiar codebase structure (follows original file paths)
41+
- Get proper syntax highlighting
42+
- Review diffs comfortably
43+
44+
- 🤖 **Feed Directly to AI**
45+
- Compatible with any LLM (e.g. ChatGPT, Claude, etc)
46+
- Review changes with integrated AI in your preferred editor (No more copy-paste hell)
47+
- Let AI help you:
48+
- Generate PR summaries instantly
49+
- Generate commit messages from changes
50+
- Get code review suggestions and explanations
51+
- Analyze changes for potential bugs and improvements
52+
53+
- 🧹 **Focus on What Matters**
54+
- Auto-skips node_modules, build files, and junk
55+
- Shows only relevant changes
56+
- Customize exclusion patterns
57+
58+
## Core Features
59+
60+
- 💡 **Compare Anything**: branches (local or remote), commits, tags
61+
- 📊 **Rich Statistics**: changes per file, summaries, commit history
62+
- 📝 **Markdown Output**: readable, searchable, navigable, shareable
7563

7664
## Output Structure
7765

@@ -106,14 +94,14 @@ GitHub, GitLab, or any other git provider diffs can be hard to parse - especiall
10694
### Basic Commands
10795

10896
```bash
109-
# Compare commits
110-
gitloom-diff -s abc123 -e def456
111-
112-
# Compare branches
97+
# Compare branches (PR mode - default)
11398
gitloom-diff -s feature/branch -e main
11499

115-
# Compare tags
116-
gitloom-diff -s v1.1.0 -e v1.0.0
100+
# Compare tags (use tag mode)
101+
gitloom-diff -s v1.1.0 -e v1.0.0 -m tag
102+
103+
# Compare commits (use commit mode)
104+
gitloom-diff -s abc123 -e def456 -m commit
117105

118106
# Compare with remote
119107
gitloom-diff -s origin/main -e main
@@ -131,23 +119,25 @@ Options:
131119
-o, --output <dir> Output directory (default: "git-diffs")
132120
--exclude <patterns...> Additional file patterns to exclude
133121
-f, --format <format> Diff format: diff|unified|side-by-side
122+
-m, --mode <mode> Comparison mode: pr|commit|tag (default: "pr")
134123
--light-mode Use light mode theme
135124
-h, --help Display help
136125
```
137126

138127
### Advanced Examples
139128

140129
```bash
141-
# Side-by-side diff with custom output
142-
gitloom-diff -s main -e develop -o pr-123-diffs -f side-by-side
130+
# Side-by-side tag comparison
131+
gitloom-diff -s v2.0.0 -e v1.0.0 -m tag -f side-by-side
143132

144-
# Exclude patterns
145-
gitloom-diff --exclude "*.test.js" "docs/**"
133+
# Exclude patterns with commit comparison
134+
gitloom-diff -s abc123 -e def456 -m commit --exclude "*.test.js" "docs/**"
146135

147136
# Multiple options
148137
gitloom-diff \
149138
-s feature/new-ui \
150139
-e develop \
140+
-m pr \
151141
-o ui-changes \
152142
-f side-by-side \
153143
--exclude "*.test.js" "*.snap" \

src/cli/index.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const pkg = require("../../package.json");
1717
* - 'unified': Unified diff format
1818
* - 'side-by-side': Two column comparison view
1919
* @param {boolean} [options.lightMode=false] - Use light mode theme instead of dark
20+
* @param {string} [options.mode] - Comparison mode (pr, commit, tag)
2021
*
2122
* Default behavior:
2223
* - Compares current branch against 'main' if no refs provided
@@ -56,22 +57,29 @@ program
5657
.option("--exclude <patterns...>", "Additional file patterns to exclude")
5758
.option("-f, --format <format>", "Diff format (diff, unified, side-by-side)", "diff")
5859
.option("--light-mode", "Use light mode theme instead of dark mode")
60+
.option("-m, --mode <mode>", "Comparison mode (pr, commit, tag)", "pr")
5961
.addHelpText('after', `
6062
Examples:
6163
# Basic usage (current branch vs main)
6264
$ gitloom-diff
6365
64-
# Compare branches
66+
# Compare branches (PR mode)
6567
$ gitloom-diff -s feature/awesome -e main
6668
67-
# Compare tags
68-
$ gitloom-diff -s v1.1.0 -e v1.0.0
69+
# Compare tags (use -m tag for proper tag comparison)
70+
$ gitloom-diff -s v1.1.0 -e v1.0.0 -m tag
71+
72+
# Compare commits (use -m commit for commit comparison)
73+
$ gitloom-diff -s abc123 -e def456 -m commit
6974
7075
# Side-by-side diff with custom output
7176
$ gitloom-diff -s main -e develop -o pr-diffs -f side-by-side
7277
73-
# Compare commit hashes
74-
$ gitloom-diff -s 1234567890abcdef1234567890abcdef12345678 -e 0987654321fedcba0987654321fedcba09876543`)
78+
Note:
79+
Mode (-m) affects how git compares the references:
80+
- pr: Uses double-dot (..) for PR/branch comparison
81+
- commit: Uses triple-dot (...) for commit comparison
82+
- tag: Uses triple-dot (...) for tag comparison`)
7583
.action(async (options) => {
7684
showBranding();
7785

@@ -80,8 +88,7 @@ Examples:
8088
exclusions: options.exclude || [],
8189
diffFormat: options.format,
8290
darkMode: !options.lightMode,
83-
// Auto-detect mode based on ref format
84-
mode: (isCommitHash(options.startRef) && isCommitHash(options.endRef)) ? 'commit' : 'pr'
91+
mode: options.mode
8592
};
8693

8794
const differ = new GitLoomDiff(config);

src/sdk/GitLoomDiff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class GitLoomDiff {
1414
* @param {string[]} [options.exclude=[]] - File patterns to exclude from the diff
1515
* @param {string} [options.format='diff'] - Diff format (diff, unified, side-by-side)
1616
* @param {boolean} [options.darkMode=true] - Whether to use dark mode theme
17-
* @param {string} [options.mode='pr'] - Diff mode ('pr' or 'commit')
17+
* @param {string} [options.mode='pr'] - Diff mode ('pr', 'commit', or 'tag')
1818
*/
1919
constructor(options = {}) {
2020
this.config = new Config(options);

0 commit comments

Comments
 (0)