Skip to content

Commit a9981fc

Browse files
refactor: remove unused diff format options
- Remove format option from CLI and SDK interfaces - Delete format-related code and flags - Simplify getFileDiff() to use standard git diff - Update examples in CLI help text
1 parent 66e2172 commit a9981fc

File tree

9 files changed

+7
-41
lines changed

9 files changed

+7
-41
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ Options:
118118
-e, --end-ref <ref> Ending reference (older state)
119119
-o, --output <dir> Output directory (default: "git-diffs")
120120
--exclude <patterns...> Additional file patterns to exclude
121-
-f, --format <format> Diff format: diff|unified|side-by-side
122121
-m, --mode <mode> Comparison mode: pr|commit|tag (default: "pr")
123122
--light-mode Use light mode theme
124123
-h, --help Display help
@@ -127,8 +126,8 @@ Options:
127126
### Advanced Examples
128127

129128
```bash
130-
# Side-by-side tag comparison
131-
gitloom-diff -s v2.0.0 -e v1.0.0 -m tag -f side-by-side
129+
# Tag comparison
130+
gitloom-diff -s v2.0.0 -e v1.0.0 -m tag
132131

133132
# Exclude patterns with commit comparison
134133
gitloom-diff -s abc123 -e def456 -m commit --exclude "*.test.js" "docs/**"
@@ -139,7 +138,6 @@ gitloom-diff \
139138
-e develop \
140139
-m pr \
141140
-o ui-changes \
142-
-f side-by-side \
143141
--exclude "*.test.js" "*.snap" \
144142
--light-mode
145143
```
@@ -152,7 +150,6 @@ const GitLoomDiff = require('gitloom-diff');
152150
const differ = new GitLoomDiff({
153151
outputDir: 'custom-dir',
154152
exclusions: ['*.log'],
155-
diffFormat: 'side-by-side',
156153
darkMode: false,
157154
mode: 'pr'
158155
});

example/src/cli/index.js.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ index 34daa02..2fa36fa 100644
4242
+ * @param {string} [options.endRef] - Ending git reference to compare to
4343
+ * @param {string} [options.output=git-diffs] - Directory to output the diff files
4444
+ * @param {string[]} [options.exclude] - File patterns to exclude from the diff
45-
+ * @param {string} [options.format=diff] - Diff format:
46-
+ * - 'diff': Traditional git diff format
47-
+ * - 'unified': Unified diff format
48-
+ * - 'side-by-side': Two column comparison view
4945
+ * @param {boolean} [options.lightMode=false] - Use light mode theme instead of dark
5046
+ *
5147
+ * Default behavior:

example/src/sdk/GitLoomDiff.js.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ index 309c756..cbbe85d 100644
4444
+ * @param {Object} options - Configuration options
4545
+ * @param {string} [options.outputDir='git-diffs'] - Directory to output the diff files
4646
+ * @param {string[]} [options.exclude=[]] - File patterns to exclude from the diff
47-
+ * @param {string} [options.format='diff'] - Diff format (diff, unified, side-by-side)
4847
+ * @param {boolean} [options.darkMode=true] - Whether to use dark mode theme
4948
+ */
5049
constructor(options = {}) {

example/src/sdk/config/Config.js.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ index 6634d45..1035615 100644
4141
+ * @param {Object} options - Configuration options
4242
+ * @param {string} [options.outputDir='git-diffs'] - Directory to output the diff files
4343
+ * @param {string[]} [options.exclusions=[]] - Additional file patterns to exclude from diff
44-
+ * @param {('diff'|'unified'|'side-by-side')} [options.diffFormat='diff'] - Format for git diff output
4544
+ * @param {boolean} [options.darkMode=true] - Whether to use dark mode styling
4645
+ */
4746
constructor(options = {}) {

example/src/sdk/utils/gitUtils.js.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ index 541dbcf..94ec414 100644
9494
+ * Gets the diff output for a specific file
9595
+ * @param {string} file - Path to the file
9696
+ * @param {string} range - Git range to compare
97-
+ * @param {('diff'|'unified'|'side-by-side')} [format='diff'] - Diff output format
9897
+ * @returns {Promise<string>} Formatted diff output
9998
+ * @throws {Error} If git command fails
10099
+ */

src/cli/index.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ const pkg = require("../../package.json");
1212
* @param {string} [options.endRef] - Ending git reference to compare to
1313
* @param {string} [options.output=git-diffs] - Directory to output the diff files
1414
* @param {string[]} [options.exclude] - File patterns to exclude from the diff
15-
* @param {string} [options.format=diff] - Diff format:
16-
* - 'diff': Traditional git diff format
17-
* - 'unified': Unified diff format
18-
* - 'side-by-side': Two column comparison view
1915
* @param {boolean} [options.lightMode=false] - Use light mode theme instead of dark
2016
* @param {string} [options.mode] - Comparison mode (pr, commit, tag)
2117
*
@@ -32,13 +28,6 @@ const pkg = require("../../package.json");
3228
* - Navigation links between files
3329
*/
3430

35-
// Add this helper function
36-
function isCommitHash(ref) {
37-
// Git commit hashes are 40 chars or abbreviated to at least 7 chars
38-
// and contain only hexadecimal characters
39-
return ref && /^[0-9a-f]{7,40}$/i.test(ref);
40-
}
41-
4231
// Add this branding function
4332
function showBranding() {
4433
console.log(`
@@ -55,7 +44,6 @@ program
5544
.option("-e, --end-ref <ref>", "Ending reference (commit hash, branch name, or tag)")
5645
.option("-o, --output <dir>", "Output directory", "git-diffs")
5746
.option("--exclude <patterns...>", "Additional file patterns to exclude")
58-
.option("-f, --format <format>", "Diff format (diff, unified, side-by-side)", "diff")
5947
.option("--light-mode", "Use light mode theme instead of dark mode")
6048
.option("-m, --mode <mode>", "Comparison mode (pr, commit, tag)", "pr")
6149
.addHelpText('after', `
@@ -72,8 +60,8 @@ Examples:
7260
# Compare commits (use -m commit for commit comparison)
7361
$ gitloom-diff -s abc123 -e def456 -m commit
7462
75-
# Side-by-side diff with custom output
76-
$ gitloom-diff -s main -e develop -o pr-diffs -f side-by-side
63+
# Diff with custom output
64+
$ gitloom-diff -s main -e develop -o pr-diffs
7765
7866
Note:
7967
Mode (-m) affects how git compares the references:
@@ -86,7 +74,6 @@ Note:
8674
const config = {
8775
outputDir: options.output,
8876
exclusions: options.exclude || [],
89-
diffFormat: options.format,
9077
darkMode: !options.lightMode,
9178
mode: options.mode
9279
};

src/sdk/GitLoomDiff.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class GitLoomDiff {
1212
* @param {Object} options - Configuration options
1313
* @param {string} [options.outputDir='git-diffs'] - Directory to output the diff files
1414
* @param {string[]} [options.exclude=[]] - File patterns to exclude from the diff
15-
* @param {string} [options.format='diff'] - Diff format (diff, unified, side-by-side)
1615
* @param {boolean} [options.darkMode=true] - Whether to use dark mode theme
1716
* @param {string} [options.mode='pr'] - Diff mode ('pr', 'commit', or 'tag')
1817
*/
@@ -144,7 +143,7 @@ class GitLoomDiff {
144143
* @private
145144
*/
146145
async #generateFileContent(file, range, fileInfo) {
147-
const diffOutput = await gitUtils.getFileDiff(file, range, this.config.diffFormat);
146+
const diffOutput = await gitUtils.getFileDiff(file, range);
148147

149148
return [
150149
this.config.getCssStyle(),

src/sdk/config/Config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ class Config {
88
* @param {Object} options - Configuration options
99
* @param {string} [options.outputDir='git-diffs'] - Directory to output the diff files
1010
* @param {string[]} [options.exclusions=[]] - Additional file patterns to exclude from diff
11-
* @param {('diff'|'unified'|'side-by-side')} [options.diffFormat='diff'] - Format for git diff output
1211
* @param {boolean} [options.darkMode=true] - Whether to use dark mode styling
1312
*/
1413
constructor(options = {}) {
1514
this.outputDir = options.outputDir || "git-diffs";
1615
this.exclusions = options.exclusions || [];
17-
this.diffFormat = options.diffFormat || "diff"; // possible values: diff, unified, side-by-side
1816
this.darkMode = options.darkMode ?? true;
1917
}
2018

src/sdk/utils/gitUtils.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,11 @@ const gitUtils = {
6868
* Gets the diff output for a specific file
6969
* @param {string} file - Path to the file
7070
* @param {string} range - Git range to compare
71-
* @param {('diff'|'unified'|'side-by-side')} [format='diff'] - Diff output format
7271
* @returns {Promise<string>} Formatted diff output
7372
* @throws {Error} If git command fails
7473
*/
75-
async getFileDiff(file, range, format = 'diff') {
76-
const formatFlags = {
77-
'diff': '',
78-
'unified': ' -U3',
79-
'side-by-side': ' --side-by-side --width=180'
80-
};
81-
82-
const flag = formatFlags[format] || '';
83-
const cmd = `git diff${flag} ${range} -- "${file}"`;
74+
async getFileDiff(file, range) {
75+
const cmd = `git diff ${range} -- "${file}"`;
8476
const { stdout } = await execAsync(cmd, {
8577
maxBuffer: 10 * 1024 * 1024
8678
});

0 commit comments

Comments
 (0)