Skip to content

Commit c466e9b

Browse files
committed
initial commit
0 parents  commit c466e9b

64 files changed

Lines changed: 13124 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: lts/*
21+
22+
- name: Setup Bun
23+
uses: oven-sh/setup-bun@v2
24+
with:
25+
bun-version: latest
26+
27+
- name: Install dependencies
28+
run: bun install --frozen-lockfile
29+
30+
- name: Run lint
31+
run: bun run lint
32+
33+
- name: Check formatting
34+
run: bun run fmt:check
35+
36+
typecheck:
37+
name: Type Check
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Setup Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: lts/*
47+
48+
- name: Setup Bun
49+
uses: oven-sh/setup-bun@v2
50+
with:
51+
bun-version: latest
52+
53+
- name: Install dependencies
54+
run: bun install --frozen-lockfile
55+
56+
- name: Run type check
57+
run: bun run typecheck
58+
59+
test:
60+
name: Test
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
66+
- name: Setup Node.js
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: lts/*
70+
71+
- name: Setup Bun
72+
uses: oven-sh/setup-bun@v2
73+
with:
74+
bun-version: latest
75+
76+
- name: Install dependencies
77+
run: bun install --frozen-lockfile
78+
79+
- name: Run unit tests
80+
run: bun run test
81+
82+
- name: Run e2e tests
83+
run: bun run test:e2e
84+
85+
coverage:
86+
name: Coverage
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v4
91+
92+
- name: Setup Node.js
93+
uses: actions/setup-node@v4
94+
with:
95+
node-version: lts/*
96+
97+
- name: Setup Bun
98+
uses: oven-sh/setup-bun@v2
99+
with:
100+
bun-version: latest
101+
102+
- name: Install dependencies
103+
run: bun install --frozen-lockfile
104+
105+
- name: Run tests with coverage
106+
run: bun run test:all --coverage
107+
108+
- name: Upload coverage to Codecov
109+
uses: codecov/codecov-action@v4
110+
with:
111+
token: ${{ secrets.CODECOV_TOKEN }}
112+
files: ./coverage/coverage-final.json
113+
fail_ci_if_error: false

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
3+
# opensrc - source code for packages
4+
opensrc/
5+
6+
# Build output
7+
dist/
8+
coverage/
9+
10+
# IDE
11+
.vscode/
12+
.claude/

.oxfmtrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"useTabs": true
4+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License Copyright (c) 2026 jaydenfyi
2+
3+
Permission is hereby granted, free of
4+
charge, to any person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the Software without
6+
restriction, including without limitation the rights to use, copy, modify, merge,
7+
publish, distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to the
9+
following conditions:
10+
11+
The above copyright notice and this permission notice
12+
(including the next paragraph) shall be included in all copies or substantial
13+
portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
18+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
<h1 align="center">diffx</h1>
2+
3+
<p align="center">A CLI utility for easily diffing Git changes across your working tree, local refs, remote refs, GitHub PRs, GitLab MRs, or any Git URLs.</p>
4+
5+
## Quick Start
6+
7+
### Install
8+
9+
```bash
10+
# npm
11+
npm install -g @jaydenfyi/diffx
12+
13+
# bun
14+
bun add -g @jaydenfyi/diffx
15+
16+
# no install
17+
npx @jaydenfyi/diffx --help
18+
```
19+
20+
### Most useful commands
21+
22+
```bash
23+
# 1) Show all current local changes (tracked + untracked)
24+
diffx
25+
26+
# 2) Compare two refs
27+
diffx main..feature
28+
29+
# 3) Diff a GitHub PR
30+
diffx https://github.com/owner/repo/pull/123
31+
32+
# 4) Generate an apply-able patch
33+
diffx main..feature --mode patch
34+
35+
# 5) Quick status view
36+
diffx --name-status
37+
```
38+
39+
## `diffx` vs `git diff`
40+
41+
| Capability | `diffx` | `git diff` |
42+
| ---------- | ------- | ---------- |
43+
| Full working tree snapshot (tracked + untracked) |||
44+
| Direct GitHub PR and GitLab MR diffing |||
45+
| Cross-remote and fork comparisons |||
46+
| Include/exclude glob filtering |||
47+
| `git diff` compatibility |||
48+
49+
## Command
50+
51+
```bash
52+
diffx [range-or-url] [options] [-- <pathspec...>]
53+
```
54+
55+
Use `--index` for strict `git diff` compatibility (index vs worktree behavior).
56+
57+
## Input Formats
58+
59+
### No range argument (default behavior)
60+
61+
```bash
62+
# Uses current worktree first (tracked + untracked)
63+
diffx
64+
65+
# If there are no local changes, falls back to inferred base..HEAD
66+
```
67+
68+
### Local ranges
69+
70+
```bash
71+
diffx main..feature
72+
diffx abc123..def456
73+
diffx refs/heads/main..refs/tags/v1.0
74+
```
75+
76+
### Remote shorthand ranges
77+
78+
```bash
79+
diffx owner/repo@main..owner/repo@feature
80+
diffx owner/repo@main..feature
81+
```
82+
83+
### Git URL ranges (SSH/HTTPS, any host)
84+
85+
```bash
86+
diffx git@github.com:owner/repo.git@main..feature
87+
diffx https://github.com/owner/repo.git@v1.0..v2.0
88+
diffx git@github.com:owner/repo.git@main..git@gitlab.com:owner/fork.git@feature
89+
```
90+
91+
### GitHub refs and URLs
92+
93+
```bash
94+
# GitHub ref shorthand
95+
diffx github:owner/repo@main..feature
96+
97+
# PR reference
98+
diffx github:owner/repo#123
99+
100+
# PR URL
101+
diffx https://github.com/owner/repo/pull/123
102+
103+
# PR vs PR
104+
diffx github:owner/repo#123..github:owner/repo#456
105+
106+
# Commit URL
107+
diffx https://github.com/owner/repo/commit/abc123
108+
109+
# PR changes URL
110+
diffx https://github.com/owner/repo/pull/123/changes/abc123..def456
111+
112+
# Compare URL (same repo or cross-fork)
113+
diffx https://github.com/owner/repo/compare/main...feature
114+
diffx https://github.com/owner/repo/compare/main...other-owner:other-repo:feature
115+
```
116+
117+
### GitLab refs
118+
119+
```bash
120+
# GitLab shorthand range
121+
diffx gitlab:owner/repo@main..feature
122+
123+
# Merge request ref
124+
diffx gitlab:owner/repo!123
125+
```
126+
127+
## Output Modes
128+
129+
`diffx` defaults to `diff` mode.
130+
131+
- `diff`: unified diff output.
132+
- `patch`: patch output (for `git apply` style use).
133+
- `stat`: per-file histogram + summary line.
134+
- `numstat`: tab-delimited additions/deletions per file.
135+
- `shortstat`: one summary line only.
136+
- `name-only`: changed filenames only.
137+
- `name-status`: status + filename (e.g. `M`, `A`, `D`, `U`).
138+
- `summary`: structural summary (`create mode`, `rename`, etc.), equivalent to `git diff --summary`.
139+
140+
Examples:
141+
142+
```bash
143+
diffx main..feature --mode patch
144+
diffx https://github.com/owner/repo/pull/123 --stat
145+
diffx --name-status
146+
```
147+
148+
## Filtering
149+
150+
```bash
151+
# Include only TypeScript files
152+
diffx main..feature --include "src/**/*.ts"
153+
154+
# Exclude tests
155+
diffx main..feature --exclude "**/*.test.ts"
156+
157+
# Combine include + exclude
158+
diffx main..feature --include "src/**" --exclude "**/*.spec.ts"
159+
160+
# Repeat include/exclude flags (matches any include; excludes any exclude)
161+
diffx --include "*.ts" --include "*.tsx" --exclude "*.js" --exclude "*.jsx"
162+
```
163+
164+
## Pager behavior
165+
166+
- Diff/patch output auto-pages on TTY (git-like behavior).
167+
- Honors `GIT_PAGER`, `core.pager`, `PAGER`.
168+
- Use `--pager` to force paging.
169+
- Use `--no-pager` to disable paging.
170+
171+
## Options Reference
172+
173+
| Option | Short | Description |
174+
| --------------------- | ----- | ---------------------------------------------------------------------------------------------------------- |
175+
| `--mode <mode>` | | Select output mode: `diff`, `patch`, `stat`, `numstat`, `shortstat`, `name-only`, `name-status`, `summary` |
176+
| `--stat` | | Shortcut for stat output |
177+
| `--numstat` | | Shortcut for numstat output |
178+
| `--summary` | | Structural summary (native `git diff --summary`) |
179+
| `--shortstat` | | Shortcut for shortstat output |
180+
| `--name-only` | | Show filenames only |
181+
| `--name-status` | | Show status + filename |
182+
| `--include <pattern>` | `-i` | Include only files matching glob (repeatable) |
183+
| `--exclude <pattern>` | `-e` | Exclude files matching glob (repeatable) |
184+
| `--pager` | | Force pager |
185+
| `--no-pager` | | Disable pager |
186+
| `--index` | | Strict `git diff` compatibility mode |
187+
| `--help` | `-h` | Show help |
188+
| `--version` | `-v` | Show version |
189+
190+
## Git Pass-through Compatibility
191+
192+
`diffx` forwards unknown/standard `git diff` flags to git when possible, including pathspec support after `--`.
193+
194+
```bash
195+
diffx main..feature -U10 --word-diff
196+
197+
diffx --stat -- src/cli src/utils
198+
```
199+
200+
This allows existing `git diff` habits while still using `diffx` input resolution and workflows.
201+
202+
## Exit Codes
203+
204+
| Code | Meaning |
205+
| ---- | ---------------------------------------- |
206+
| `0` | Success |
207+
| `1` | No files matched filters |
208+
| `2` | Invalid input / unsupported range format |
209+
| `3` | Git execution/fetch error |
210+
211+
## Development
212+
213+
This repository uses `bun`.
214+
215+
```bash
216+
bun install
217+
bun run build
218+
bun run test
219+
bun run test:e2e
220+
bun run lint
221+
bun run typecheck
222+
```
223+
224+
## License
225+
226+
MIT

0 commit comments

Comments
 (0)