clearedforpush 0.1.0

Pre-push merge conflict predictor — catch conflicts before you push, not during CI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
<div align="center">

<h1>&nbsp;C L E A R E D &nbsp;&nbsp; F O R &nbsp;&nbsp; P U S H</h1>

<h3><i>Know before you push.</i></h3>

**Catch merge conflicts _before_ you push** &mdash; not during CI, not in PR review,<br/>not when your teammate pings you at 5 p.m.

<br/>

[![Crates.io](https://img.shields.io/crates/v/clearedforpush.svg?style=for-the-badge&logo=rust&color=D2691E)](https://crates.io/crates/clearedforpush)
[![License](https://img.shields.io/badge/license-MIT%20%7C%20Apache--2.0-4B0082?style=for-the-badge)](#-license)
[![Rust](https://img.shields.io/badge/rust-1.70+-CD853F?style=for-the-badge&logo=rust)](https://www.rust-lang.org)
[![Git](https://img.shields.io/badge/git-2.38+-F05032?style=for-the-badge&logo=git&logoColor=white)](https://git-scm.com)

<br/>

<a href="#-quick-start"><b>Quick Start</b></a>&nbsp;&nbsp;·&nbsp;&nbsp;
<a href="#-how-it-works"><b>How It Works</b></a>&nbsp;&nbsp;·&nbsp;&nbsp;
<a href="#-installation"><b>Install</b></a>&nbsp;&nbsp;·&nbsp;&nbsp;
<a href="#-usage"><b>Usage</b></a>&nbsp;&nbsp;·&nbsp;&nbsp;
<a href="#-configuration"><b>Config</b></a>

<br/>

<img src="assets/screenshot-clean.png" alt="Cleared for Push — clean check" width="720"/>

</div>

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ▸ &nbsp;The Problem

Every developer knows this pain:

```console
$ git push origin feature-branch
  ✓ Pushed! Time for coffee ☕

  ... 20 minutes later ...

  ✗ CI failed: merge conflicts in 4 files
  ✗ Or worse — your reviewer finds them
  ✗ Or worse still — you discover them mid-rebase
```

By the time conflicts surface, **you've lost all context.** The code is cold, the CI queue is
backed up, and a teammate is blocked. A 2-minute fix becomes a 30-minute detour.

<br/>

## ▸ &nbsp;The Solution

> **Cleared for Push tells you the moment a conflict exists — _before_ you push.**

<table>
<tr>
<td width="50%" valign="top">

**✓ &nbsp;All clear**

```
╭──────────────────────────────╮
│      CLEAR FOR TAKEOFF       │
│                              │
│  No conflicts. Safe to push! │
╰──────────────────────────────╯
```

Push with confidence.

</td>
<td width="50%" valign="top">

**✗ &nbsp;Conflicts ahead**

```
╭──────────────────────────────╮
│  HOLD FOR CLEARANCE          │
│                              │
│  Conflicts detected.         │
╰──────────────────────────────╯
  ✗ src/auth.rs
  ✗ src/main.rs
```

Fix now, while it's fresh.

</td>
</tr>
</table>

Fast. Safe. Zero setup. **It never touches your working directory.**

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ◈ &nbsp;How It Works

Under the hood, Cleared for Push shells out to Git's own `merge-tree --write-tree` plumbing
to **simulate** a merge in memory. Nothing on disk is ever modified.

```
YOU                            CLEARED FOR PUSH                 GIT
  │                              │                                │
  │                              clearedforpush check             │
  ├──────────────────────────────▶                                │
  │                              │                                │
  │                              ①  detect current & base branch │
  │                              ├────────────────────────────────▶
  │                              │                                │
  │                              ②  fetch base branch (read-only) │
  │                              ├────────────────────────────────▶
  │                              │                                │
  │                              ③  merge-tree --write-tree      │
  │                              ├────────────────────────────────▶
  │                              │                                │
  │                              simulated merge tree             │
  │                              ◀────────────────────────────────┤
  │                              │                                │
  │                              ④  parse conflict markers       │
  │                                  (+ open-PR awareness)        │
  │                              │                                │
  │                              ✓ CLEAR  /  ✗ HOLD               │
  ◀──────────────────────────────┤
  exit 0  /  exit 1

┌────────────────────────────────────────────────────────────────────────────┐
│  READ-ONLY GUARANTEE                                                       │
│  ✗ no working-dir changes    ✗ no index writes                             │
│  ✗ no branch updates         ✗ no stash operations                         │
└────────────────────────────────────────────────────────────────────────────┘
```

**Why not `git merge --no-commit`?** &nbsp;That still mutates your index and can leave you in a
half-merged state. We use the lower-level plumbing so your repo is **guaranteed untouched.**

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ⚡ &nbsp;Quick Start

```bash
# 1. Install
cargo install clearedforpush

# 2. Check before you push
cd your-git-repo
clearedforpush check
```

That's the whole thing. If there's a conflict, you'll know instantly — with the exact files listed.

<br/>

## ✦ &nbsp;Why You'll Love It

<table>
<tr>
<td width="33%" valign="top" align="center">

### 
**Beautiful CLI**

An aviation-themed interface that makes conflict checking genuinely pleasant.

</td>
<td width="33%" valign="top" align="center">

### 
**Lightning Fast**

Powered by Git's native `merge-tree`. Typically under 2 seconds.

</td>
<td width="33%" valign="top" align="center">

### 
**100% Safe**

Read-only. Never touches your working directory, index, or branches.

</td>
</tr>
<tr>
<td width="33%" valign="top" align="center">

### 
**Smart Stats**

See ahead/behind counts, files changed, and line diffs at a glance.

</td>
<td width="33%" valign="top" align="center">

### 
**PR Awareness**

Detects conflicts with open pull requests targeting the same base.

</td>
<td width="33%" valign="top" align="center">

### 
**CI Friendly**

Text, JSON, and compact output formats. Stable exit codes.

</td>
</tr>
</table>

<br/>

## ⏱ &nbsp;Before & After

| | Without Cleared for Push | With Cleared for Push |
|:---:|:---|:---|
| **Feedback** | Push → wait for CI → CI fails | Check locally in ~1 second |
| **Context** | Lost, code gone cold | Fresh in your head |
| **Team** | Blocked on your branch | Stays unblocked |
| **CI** | Wasted minutes and queue time | Clean runs, every time |
| **Rebase** | Surprise conflicts mid-rebase | Know exactly what collides |

<div align="center">

_One command saves you a broken CI run, a context switch, and a frustrating rebase._

</div>

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ⬇ &nbsp;Installation

<table>
<tr>
<td valign="top" width="50%">

**Cargo** &nbsp;·&nbsp; _recommended_
```bash
cargo install clearedforpush
```

**Homebrew** &nbsp;·&nbsp; _macOS / Linux_
```bash
brew install sanjayrohith/tap/clearedforpush
```

**AUR** &nbsp;·&nbsp; _Arch Linux_
```bash
yay -S clearedforpush
```

</td>
<td valign="top" width="50%">

**From source**
```bash
git clone https://github.com/sanjayrohith/clearedforpush
cd clearedforpush
cargo install --path .
```

**Requirements**
- Git **2.38+** &nbsp;·&nbsp; `git --version`
- Rust **1.70+** &nbsp;·&nbsp; _source builds only_

</td>
</tr>
</table>

**Prebuilt binaries** &mdash; grab the latest from [Releases](https://github.com/sanjayrohith/clearedforpush/releases):

| Platform | Asset |
|:---|:---|
|&nbsp;Linux (x86_64) | `clearedforpush-vX.Y.Z-x86_64-unknown-linux-musl.tar.gz` |
|&nbsp;macOS (Intel) | `clearedforpush-vX.Y.Z-x86_64-apple-darwin.tar.gz` |
|&nbsp;macOS (Apple Silicon) | `clearedforpush-vX.Y.Z-aarch64-apple-darwin.tar.gz` |
|&nbsp;Windows (x86_64) | `clearedforpush-vX.Y.Z-x86_64-pc-windows-msvc.zip` |

```bash
# Example: Linux
curl -LO https://github.com/sanjayrohith/clearedforpush/releases/latest/download/clearedforpush-v0.1.0-x86_64-unknown-linux-musl.tar.gz
tar xzf clearedforpush-*.tar.gz
sudo mv clearedforpush /usr/local/bin/
```

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ▶ &nbsp;Usage

### Basic check
```bash
clearedforpush check
```
Checks your current branch against the base branch (auto-detected as `main` or `master`).

### With statistics
```bash
clearedforpush check --stats
```

<div align="center">
<img src="assets/screenshot-clean.png" alt="clearedforpush check --stats" width="680"/>
</div>

Adds a detailed breakdown:

| Symbol | Meaning |
|:---:|:---|
|| Commits you're **ahead** of base |
|| Commits base is **ahead** of you |
|| Number of **files changed** |
| ± | **Insertions** and deletions |

### Custom base branch
```bash
clearedforpush check --base develop
```

### Show conflict diffs
```bash
clearedforpush check --diff
```
When conflicts exist, prints the actual diff hunks with syntax highlighting
(additions in green, deletions in red).

### JSON output &nbsp;·&nbsp; _for CI / scripting_
```bash
clearedforpush check --format json --skip-prs
```

<div align="center">
<img src="assets/screenshot-json.png" alt="clearedforpush check --format json" width="680"/>
</div>

A stable, versioned schema:

```json
{
  "version": 1,
  "current_branch": "feature-x",
  "base_branch": "main",
  "has_conflicts": false,
  "exit_code": 0,
  "conflicted_files": [],
  "conflict_diffs": [],
  "stats": { "ahead": 3, "behind": 1, "files_changed": 5 },
  "pr_conflicts": []
}
```

### Compact output
```bash
clearedforpush check --format compact
```
Single line: &nbsp;`OK: no conflicts` &nbsp;or&nbsp; `CONFLICT: file1.rs, file2.rs`

### In a script or CI
```bash
clearedforpush check && git push
```
Exits `0` when clean and `1` when conflicts exist &mdash; composes cleanly with `&&` and CI pipelines.

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ⎇ &nbsp;Git Hook &nbsp;·&nbsp; _auto-check on every push_

```bash
clearedforpush install-hook
```

<div align="center">
<img src="assets/screenshot-hook.png" alt="clearedforpush install-hook" width="680"/>
</div>

Now every push runs a conflict check first. If conflicts exist, the push is **blocked**.

```bash
# Bypass when you really need to:
git push --no-verify
```

Already have a pre-push hook? It won't clobber it — it warns you, and `--force` **chains**
onto the existing hook instead of overwriting:

```bash
clearedforpush install-hook --force     # append safely
clearedforpush uninstall-hook           # remove only our section
```

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ⚙ &nbsp;Configuration

Generate a `.clearedforpush.toml` in your repo root:

```bash
clearedforpush init
```

```toml
# Base branch (auto-detected if not set)
base = "develop"

# Check open PRs for conflicts (default: true)
check_prs = true

# Default output format: "text", "json", or "compact"
format = "text"

# Show statistics by default
stats = true

# Show conflict diffs by default
diff = false

# Paths to ignore when reporting conflicts
ignore = ["*.lock", "docs/**", "*.generated.*"]

[github]
# Alternative to the GITHUB_TOKEN env var
token = "ghp_..."
```

> CLI flags **always** override config-file values.

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ⌨ &nbsp;Command Reference

```bash
clearedforpush --help
```

<div align="center">
<img src="assets/screenshot-help.png" alt="clearedforpush --help" width="680"/>
</div>

| Command | Description |
|:---|:---|
| `check` | Run conflict detection (PR-aware by default) |
| `check --stats` | Include ahead/behind and diff statistics |
| `check --diff` | Show conflicting diff hunks with highlighting |
| `check --base <branch>` | Check against a specific base branch |
| `check --skip-prs` | Skip checking against open PRs |
| `check --format <fmt>` | Output as `text`, `json`, or `compact` |
| `install-hook [--force]` | Install as a pre-push git hook |
| `uninstall-hook` | Remove the pre-push hook |
| `init` | Generate a `.clearedforpush.toml` template |

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ❔ &nbsp;FAQ

<details>
<summary><b>Does it modify my repository?</b></summary>
<br/>
No. It only reads. Your working directory, index, HEAD, and branches remain completely untouched. This is a hard guarantee.
</details>

<details>
<summary><b>What Git version do I need?</b></summary>
<br/>
Git 2.38.0 or later (October 2022), which introduced the <code>--write-tree</code> flag for <code>merge-tree</code>. Check with <code>git --version</code>.
</details>

<details>
<summary><b>Can I use a base branch other than main?</b></summary>
<br/>
Yes — <code>clearedforpush check --base develop</code> works with any branch.
</details>

<details>
<summary><b>Does it work with remote branches?</b></summary>
<br/>
Yes. It fetches the latest state of the base branch from origin before checking, so you always compare against the most recent remote state.
</details>

<details>
<summary><b>Can I use it in CI?</b></summary>
<br/>
Absolutely. Use <code>--format json</code> for structured output with a stable schema, or rely on exit codes (0 = clean, 1 = conflicts) in shell scripts.
</details>

<details>
<summary><b>Is it fast enough for a git hook?</b></summary>
<br/>
Yes — designed to run in under 2 seconds for typical repos.
</details>

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ⬢ &nbsp;Roadmap

```
[✓] Core conflict detection
[✓] Statistics display
[✓] Git hook integration        install-hook / uninstall-hook
[✓] GitHub PR awareness         conflicts against open PRs
[✓] Better reporting            diff hunks · JSON · compact
[✓] Configuration               .clearedforpush.toml
[✓] Distribution                CI/CD · binaries · AUR · Homebrew
[ ] CI integrations             GitHub Actions · GitLab CI templates
```

<br/>

<div align="center">

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

</div>

## ⚑ &nbsp;Contributing

Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) to get started.

## § &nbsp;License

Licensed under either of **MIT** ([LICENSE-MIT](LICENSE-MIT)) or
**Apache-2.0** ([LICENSE-APACHE](LICENSE-APACHE)), at your option.

<br/>

<div align="center">

**Built with ♥ by developers, for developers**

<a href="https://github.com/sanjayrohith/clearedforpush/issues"><b>Report a Bug</b></a>
&nbsp;·&nbsp;
<a href="https://github.com/sanjayrohith/clearedforpush/issues"><b>Request a Feature</b></a>

<br/><br/>

_Clear skies and clean merges._ &nbsp;✈

</div>