git-tm 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/package.json +2 -2
- package/src/cli.js +76 -9
- package/src/git.js +73 -0
- package/src/public/app.css +288 -1
- package/src/public/index.html +3 -1
- package/src/public/js/detail.js +8 -3
- package/src/public/js/diff.js +78 -32
- package/src/public/js/highlight.js +481 -0
- package/src/public/js/insights.js +2 -2
- package/src/public/js/main.js +9 -1
- package/src/public/js/reflog.js +215 -0
- package/src/public/js/ui.js +9 -7
- package/src/server.js +8 -0
- package/src/types/git.d.ts +36 -0
package/README.md
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
<p>Explore any Git repository's history in your browser.<br>
|
|
7
7
|
Commit graph, diffs, blame, insights and time travel between any two commits. One command, zero dependencies.</p>
|
|
8
8
|
|
|
9
|
+
<a href="https://github.com/nandhu-44/Git-Time-Machine/actions/workflows/ci.yml"><img src="https://github.com/nandhu-44/Git-Time-Machine/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status"></a>
|
|
9
10
|
<a href="https://www.npmjs.com/package/git-tm"><img src="https://img.shields.io/npm/v/git-tm?color=f05133" alt="npm version"></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/git-tm"><img src="https://img.shields.io/npm/dm/git-tm?color=f05133" alt="npm downloads per month"></a>
|
|
12
|
+
<img src="https://img.shields.io/node/v/git-tm?color=339933" alt="node version">
|
|
10
13
|
<img src="https://img.shields.io/badge/dependencies-0-2ea44f" alt="zero dependencies">
|
|
11
14
|
<img src="https://img.shields.io/npm/l/git-tm" alt="license">
|
|
12
15
|
<a href="https://git-time-machine.js.org"><img src="https://img.shields.io/badge/docs-git--time--machine.js.org-0969da" alt="documentation"></a>
|
|
@@ -50,6 +53,8 @@ git tm
|
|
|
50
53
|
|
|
51
54
|
`git -C ../other-repo tm` works too. Use `git tm -h` for help: Git handles `git tm --help` itself and looks for a manual page instead.
|
|
52
55
|
|
|
56
|
+
While it runs, press `o` in the terminal to open the browser, `h` to list these keys and `q` (or `Ctrl+C`) to stop.
|
|
57
|
+
|
|
53
58
|
| Option | Description |
|
|
54
59
|
| --- | --- |
|
|
55
60
|
| `-p, --port <number>` | Port to listen on (default `7890`; the next free port is used if it is busy) |
|
|
@@ -70,6 +75,7 @@ git tm
|
|
|
70
75
|
**Commits**
|
|
71
76
|
- Full message, author and committer, parents, and every branch and tag that contains the commit
|
|
72
77
|
- Unified or split diffs with word-level highlights, a hide-whitespace toggle and full-file context
|
|
78
|
+
- Syntax highlighting in diffs and the file viewer for common languages (JavaScript and TypeScript, Python, Go, Rust, C and C++, Java, Ruby, shell, HTML, CSS, JSON, YAML, SQL, Markdown, Dockerfiles), with no dependencies
|
|
73
79
|
- Merge commits can be diffed against any parent
|
|
74
80
|
- Open the commit on GitHub, GitLab or Bitbucket when the repository has a remote
|
|
75
81
|
|
|
@@ -85,6 +91,11 @@ git tm
|
|
|
85
91
|
- Pick commits with a searchable picker, with *Time travel* mode in History (click From, then To), from a commit's detail pane, or by shift-clicking a second commit
|
|
86
92
|
- *Direct* (`a..b`) or *since branch point* (`a...b`, like a pull request)
|
|
87
93
|
|
|
94
|
+
**Reflog**
|
|
95
|
+
- Recent `HEAD` movements: commits, checkouts, resets, rebases, merges and pulls
|
|
96
|
+
- Commits that are no longer on any branch or tag are marked *lost*, with copyable commands to recover them
|
|
97
|
+
- Read-only like everything else: git-tm shows the commands, you decide whether to run them
|
|
98
|
+
|
|
88
99
|
**Search**
|
|
89
100
|
|
|
90
101
|
| Query | Finds |
|
|
@@ -102,7 +113,7 @@ git tm
|
|
|
102
113
|
- Light and dark themes (follows your system by default)
|
|
103
114
|
- Notices when the repository changes on disk and offers to refresh; if the git-tm process stops, the page says so and reconnects when it is back
|
|
104
115
|
- Fetch all remotes with one click
|
|
105
|
-
- Keyboard shortcuts: `j`/`k` to move, `Enter` to open, `t` for time travel mode, `←`/`→` to step through a journey, `/` to search, `Esc` to close, `g h`/`g c`/`g i` to switch views, `?` for help
|
|
116
|
+
- Keyboard shortcuts: `j`/`k` to move, `Enter` to open, `t` for time travel mode, `←`/`→` to step through a journey, `/` to search, `Esc` to close, `g h`/`g c`/`g r`/`g i` to switch views, `?` for help
|
|
106
117
|
- Works on phones and tablets
|
|
107
118
|
|
|
108
119
|
## Use it from code
|
|
@@ -153,7 +164,7 @@ cd Git-Time-Machine
|
|
|
153
164
|
node src/cli.js .
|
|
154
165
|
```
|
|
155
166
|
|
|
156
|
-
Run the tests with `npm test`. See [CONTRIBUTING.md](CONTRIBUTING.md) for how the project is organised, its principles and how to send a pull request.
|
|
167
|
+
Run the tests with `npm test`. Questions and ideas are welcome in [Discussions](https://github.com/nandhu-44/Git-Time-Machine/discussions). See [CONTRIBUTING.md](CONTRIBUTING.md) for how the project is organised, its principles and how to send a pull request.
|
|
157
168
|
|
|
158
169
|
## Background
|
|
159
170
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-tm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Explore any Git repository in your browser: commit graph, diffs, blame, insights and time travel between any two commits. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"start": "node src/cli.js",
|
|
35
|
-
"test": "node --test
|
|
35
|
+
"test": "node --test"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=18.3"
|
package/src/cli.js
CHANGED
|
@@ -114,6 +114,39 @@ async function main() {
|
|
|
114
114
|
fail(`Could not start server: ${err.message}`);
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
let rawModeEnabled = false;
|
|
118
|
+
let stopping = false;
|
|
119
|
+
let onKeypress;
|
|
120
|
+
const restoreTerminal = () => {
|
|
121
|
+
if (onKeypress) {
|
|
122
|
+
process.stdin.off("data", onKeypress);
|
|
123
|
+
onKeypress = undefined;
|
|
124
|
+
}
|
|
125
|
+
if (!rawModeEnabled) return;
|
|
126
|
+
try {
|
|
127
|
+
process.stdin.setRawMode(false);
|
|
128
|
+
} catch {
|
|
129
|
+
// The process may be exiting after the terminal has already disconnected.
|
|
130
|
+
}
|
|
131
|
+
rawModeEnabled = false;
|
|
132
|
+
process.stdin.pause();
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Restore terminal input even if another code path exits the process.
|
|
136
|
+
process.once("exit", restoreTerminal);
|
|
137
|
+
|
|
138
|
+
// Handle Ctrl+C and SIGTERM before printing the address, so a signal that
|
|
139
|
+
// arrives right after startup still shuts down cleanly with exit code 0.
|
|
140
|
+
const stop = () => {
|
|
141
|
+
if (stopping) return;
|
|
142
|
+
stopping = true;
|
|
143
|
+
restoreTerminal();
|
|
144
|
+
server.close();
|
|
145
|
+
process.exit(0);
|
|
146
|
+
};
|
|
147
|
+
process.on("SIGINT", stop);
|
|
148
|
+
process.on("SIGTERM", stop);
|
|
149
|
+
|
|
117
150
|
const shownHost = ["127.0.0.1", "::1", "0.0.0.0", "::"].includes(values.host) ? "localhost" : values.host;
|
|
118
151
|
const url = `http://${shownHost}:${actual}`;
|
|
119
152
|
const info = await repo.info().catch(() => ({}));
|
|
@@ -126,22 +159,56 @@ async function main() {
|
|
|
126
159
|
console.log(` ${c.dim("url ")} ${c.cyan(url)}`);
|
|
127
160
|
if (actual !== port && port !== 0) console.log(` ${c.dim(`port ${port} was busy, using ${actual}`)}`);
|
|
128
161
|
console.log();
|
|
129
|
-
console.log(c.dim(" Press Ctrl+C to stop"));
|
|
130
|
-
console.log();
|
|
131
162
|
|
|
132
163
|
if (values.open) openBrowser(url);
|
|
133
164
|
|
|
165
|
+
let interactiveInput = false;
|
|
166
|
+
let shortcutsShown = false;
|
|
167
|
+
if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
|
|
168
|
+
try {
|
|
169
|
+
process.stdin.setRawMode(true);
|
|
170
|
+
rawModeEnabled = true;
|
|
171
|
+
onKeypress = (chunk) => {
|
|
172
|
+
for (const key of chunk.toString()) {
|
|
173
|
+
const normalizedKey = key.toLowerCase();
|
|
174
|
+
if (key === "\u0003" || normalizedKey === "q") {
|
|
175
|
+
stop();
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
if (normalizedKey === "o") {
|
|
179
|
+
openBrowser(url);
|
|
180
|
+
} else if (normalizedKey === "h" && !shortcutsShown) {
|
|
181
|
+
shortcutsShown = true;
|
|
182
|
+
console.log(c.dim(" Keyboard shortcuts:"));
|
|
183
|
+
console.log(c.dim(" o Open browser"));
|
|
184
|
+
console.log(c.dim(" h Show shortcuts"));
|
|
185
|
+
console.log(c.dim(" q Quit server"));
|
|
186
|
+
console.log(c.dim(" Ctrl+C Quit server"));
|
|
187
|
+
console.log();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
process.stdin.on("data", onKeypress);
|
|
192
|
+
process.stdin.resume();
|
|
193
|
+
interactiveInput = true;
|
|
194
|
+
} catch {
|
|
195
|
+
restoreTerminal();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
console.log(
|
|
200
|
+
c.dim(
|
|
201
|
+
interactiveInput
|
|
202
|
+
? " Press o to open, h for help, q to quit (Ctrl+C to quit)"
|
|
203
|
+
: " Press Ctrl+C to stop",
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
console.log();
|
|
207
|
+
|
|
134
208
|
// Keep serving if something unexpected goes wrong; say what happened instead of dying silently.
|
|
135
209
|
const report = (err) => console.error(`${c.red("error")} ${err?.stack || err}`);
|
|
136
210
|
process.on("uncaughtException", report);
|
|
137
211
|
process.on("unhandledRejection", report);
|
|
138
|
-
|
|
139
|
-
const stop = () => {
|
|
140
|
-
server.close();
|
|
141
|
-
process.exit(0);
|
|
142
|
-
};
|
|
143
|
-
process.on("SIGINT", stop);
|
|
144
|
-
process.on("SIGTERM", stop);
|
|
145
212
|
}
|
|
146
213
|
|
|
147
214
|
main();
|
package/src/git.js
CHANGED
|
@@ -626,6 +626,67 @@ class Repo {
|
|
|
626
626
|
});
|
|
627
627
|
}
|
|
628
628
|
|
|
629
|
+
// ---------------------------------------------------------- reflog
|
|
630
|
+
|
|
631
|
+
async reflog({ ref = "HEAD", skip = 0, limit = 200 } = {}) {
|
|
632
|
+
checkRev(ref);
|
|
633
|
+
const n = Math.max(1, Math.min(Number(limit) || 200, 1000));
|
|
634
|
+
const offset = Math.max(0, Number(skip) || 0);
|
|
635
|
+
const format = ["%H", "%gd", "%gs", "%ct", "%an", "%ae", "%s", "%D"].join("%x00") + "%x1e";
|
|
636
|
+
const out = await tryGit(this.root, [
|
|
637
|
+
"reflog",
|
|
638
|
+
"show",
|
|
639
|
+
`--format=${format}`,
|
|
640
|
+
"--decorate=full",
|
|
641
|
+
"--date=unix",
|
|
642
|
+
`--skip=${offset}`,
|
|
643
|
+
`-n`,
|
|
644
|
+
String(n + 1),
|
|
645
|
+
ref,
|
|
646
|
+
]);
|
|
647
|
+
if (!out) return { entries: [], done: true };
|
|
648
|
+
|
|
649
|
+
const entries = [];
|
|
650
|
+
for (const rec of out.split(RS)) {
|
|
651
|
+
const r = rec.replace(/^\n/, "");
|
|
652
|
+
if (!r) continue;
|
|
653
|
+
const [hash, gd, gs, ct, an, ae, subject, refs] = r.split(FS);
|
|
654
|
+
if (!hash || hash.length < 40) continue;
|
|
655
|
+
const idx = offset + entries.length;
|
|
656
|
+
const tsMatch = gd ? gd.match(/@\{(\d+)\}$/) : null;
|
|
657
|
+
const message = gs ?? "";
|
|
658
|
+
entries.push({
|
|
659
|
+
hash,
|
|
660
|
+
selector: `${ref}@{${idx}}`,
|
|
661
|
+
index: idx,
|
|
662
|
+
action: parseReflogAction(message),
|
|
663
|
+
message,
|
|
664
|
+
date: tsMatch ? Number(tsMatch[1]) : Number(ct) || 0,
|
|
665
|
+
author: an ?? "",
|
|
666
|
+
email: ae ?? "",
|
|
667
|
+
subject: subject ?? "",
|
|
668
|
+
refs: parseDecorations(refs),
|
|
669
|
+
orphaned: false,
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
const done = entries.length <= n;
|
|
674
|
+
if (!done) entries.pop();
|
|
675
|
+
|
|
676
|
+
if (entries.length) {
|
|
677
|
+
const unique = [...new Set(entries.map((e) => e.hash))];
|
|
678
|
+
const lostOut = await tryGit(this.root, ["rev-list", "--stdin", "--not", "--branches", "--remotes", "--tags"], {
|
|
679
|
+
input: unique.join("\n") + "\n",
|
|
680
|
+
});
|
|
681
|
+
if (lostOut) {
|
|
682
|
+
const lost = new Set(lostOut.trim().split("\n").filter(Boolean));
|
|
683
|
+
for (const e of entries) e.orphaned = lost.has(e.hash);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
return { entries, done };
|
|
688
|
+
}
|
|
689
|
+
|
|
629
690
|
// ---------------------------------------------------------- insights
|
|
630
691
|
|
|
631
692
|
async insights(ref) {
|
|
@@ -681,6 +742,18 @@ class Repo {
|
|
|
681
742
|
}
|
|
682
743
|
}
|
|
683
744
|
|
|
745
|
+
function parseReflogAction(msg) {
|
|
746
|
+
if (!msg) return "other";
|
|
747
|
+
const lower = msg.toLowerCase();
|
|
748
|
+
if (lower.startsWith("commit (amend):")) return "amend";
|
|
749
|
+
if (lower.startsWith("commit (merge):")) return "merge";
|
|
750
|
+
if (lower.startsWith("commit (initial):") || lower.startsWith("commit:")) return "commit";
|
|
751
|
+
if (lower.startsWith("rebase")) return "rebase";
|
|
752
|
+
if (lower.startsWith("pull")) return "pull";
|
|
753
|
+
const m = lower.match(/^([a-z][a-z0-9-]*)(?=[:\s]|$)/);
|
|
754
|
+
return m ? m[1] : "other";
|
|
755
|
+
}
|
|
756
|
+
|
|
684
757
|
function emptyInsights() {
|
|
685
758
|
return { total: 0, first: null, last: null, days: {}, punch: Array.from({ length: 7 }, () => Array(24).fill(0)), contributorCount: 0, contributors: [] };
|
|
686
759
|
}
|
package/src/public/app.css
CHANGED
|
@@ -48,6 +48,14 @@
|
|
|
48
48
|
--heat-2: #f8a28c;
|
|
49
49
|
--heat-3: #f3734f;
|
|
50
50
|
--heat-4: #d8401d;
|
|
51
|
+
--tok-keyword: #cf222e;
|
|
52
|
+
--tok-string: #0a3069;
|
|
53
|
+
--tok-function: #8250df;
|
|
54
|
+
--tok-number: #0550ae;
|
|
55
|
+
--tok-comment: #6e7781;
|
|
56
|
+
--tok-type: #953800;
|
|
57
|
+
--tok-tag: #116329;
|
|
58
|
+
--tok-attr: #0550ae;
|
|
51
59
|
color-scheme: light;
|
|
52
60
|
}
|
|
53
61
|
|
|
@@ -86,6 +94,14 @@
|
|
|
86
94
|
--heat-2: #7f2f1d;
|
|
87
95
|
--heat-3: #c54424;
|
|
88
96
|
--heat-4: #ff6a4a;
|
|
97
|
+
--tok-keyword: #ff7b72;
|
|
98
|
+
--tok-string: #a5d6ff;
|
|
99
|
+
--tok-function: #d2a8ff;
|
|
100
|
+
--tok-number: #79c0ff;
|
|
101
|
+
--tok-comment: #8b949e;
|
|
102
|
+
--tok-type: #ffa657;
|
|
103
|
+
--tok-tag: #7ee787;
|
|
104
|
+
--tok-attr: #79c0ff;
|
|
89
105
|
color-scheme: dark;
|
|
90
106
|
}
|
|
91
107
|
|
|
@@ -125,6 +141,14 @@
|
|
|
125
141
|
--heat-2: #7f2f1d;
|
|
126
142
|
--heat-3: #c54424;
|
|
127
143
|
--heat-4: #ff6a4a;
|
|
144
|
+
--tok-keyword: #ff7b72;
|
|
145
|
+
--tok-string: #a5d6ff;
|
|
146
|
+
--tok-function: #d2a8ff;
|
|
147
|
+
--tok-number: #79c0ff;
|
|
148
|
+
--tok-comment: #8b949e;
|
|
149
|
+
--tok-type: #ffa657;
|
|
150
|
+
--tok-tag: #7ee787;
|
|
151
|
+
--tok-attr: #79c0ff;
|
|
128
152
|
color-scheme: dark;
|
|
129
153
|
}
|
|
130
154
|
}
|
|
@@ -1451,6 +1475,39 @@ mark.del {
|
|
|
1451
1475
|
border-radius: 2px;
|
|
1452
1476
|
}
|
|
1453
1477
|
|
|
1478
|
+
.tok-keyword {
|
|
1479
|
+
color: var(--tok-keyword);
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
.tok-string {
|
|
1483
|
+
color: var(--tok-string);
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
.tok-function {
|
|
1487
|
+
color: var(--tok-function);
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
.tok-number {
|
|
1491
|
+
color: var(--tok-number);
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
.tok-comment {
|
|
1495
|
+
color: var(--tok-comment);
|
|
1496
|
+
font-style: italic;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
.tok-type {
|
|
1500
|
+
color: var(--tok-type);
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
.tok-tag {
|
|
1504
|
+
color: var(--tok-tag);
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
.tok-attr {
|
|
1508
|
+
color: var(--tok-attr);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1454
1511
|
.diff tr.hunk td {
|
|
1455
1512
|
white-space: nowrap;
|
|
1456
1513
|
overflow: hidden;
|
|
@@ -2239,7 +2296,7 @@ mark.del {
|
|
|
2239
2296
|
.punch {
|
|
2240
2297
|
display: block;
|
|
2241
2298
|
width: 100%;
|
|
2242
|
-
min-width:
|
|
2299
|
+
min-width: 360px;
|
|
2243
2300
|
}
|
|
2244
2301
|
|
|
2245
2302
|
.punch circle {
|
|
@@ -2457,6 +2514,236 @@ dialog.help .btn {
|
|
|
2457
2514
|
float: right;
|
|
2458
2515
|
}
|
|
2459
2516
|
|
|
2517
|
+
/* ------------------------------------------------------------------ reflog */
|
|
2518
|
+
|
|
2519
|
+
.reflog-bar {
|
|
2520
|
+
display: flex;
|
|
2521
|
+
flex-wrap: wrap;
|
|
2522
|
+
align-items: center;
|
|
2523
|
+
gap: 10px;
|
|
2524
|
+
margin-bottom: 14px;
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
.seg-count {
|
|
2528
|
+
display: inline-block;
|
|
2529
|
+
margin-left: 5px;
|
|
2530
|
+
padding: 0 5px;
|
|
2531
|
+
border-radius: 999px;
|
|
2532
|
+
font-size: 11px;
|
|
2533
|
+
background: var(--bg-active);
|
|
2534
|
+
color: var(--muted);
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
.seg-count.warn {
|
|
2538
|
+
background: rgba(212, 160, 23, 0.2);
|
|
2539
|
+
color: var(--lane-4);
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
.reflog-search {
|
|
2543
|
+
flex: 1 1 200px;
|
|
2544
|
+
max-width: 320px;
|
|
2545
|
+
height: 30px;
|
|
2546
|
+
padding: 0 10px;
|
|
2547
|
+
border: 1px solid var(--border);
|
|
2548
|
+
border-radius: var(--radius-sm);
|
|
2549
|
+
background: var(--bg-elev);
|
|
2550
|
+
font-size: 12.5px;
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
.reflog-search:focus {
|
|
2554
|
+
outline: none;
|
|
2555
|
+
border-color: var(--accent);
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
.reflog-list {
|
|
2559
|
+
display: flex;
|
|
2560
|
+
flex-direction: column;
|
|
2561
|
+
gap: 8px;
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
.reflog-item {
|
|
2565
|
+
border: 1px solid var(--border);
|
|
2566
|
+
border-radius: var(--radius);
|
|
2567
|
+
background: var(--bg-panel);
|
|
2568
|
+
overflow: hidden;
|
|
2569
|
+
transition: border-color 0.12s;
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
.reflog-item:hover {
|
|
2573
|
+
border-color: var(--border-strong);
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
.reflog-item.orphaned {
|
|
2577
|
+
border-left: 3px solid var(--lane-4);
|
|
2578
|
+
background: color-mix(in srgb, var(--lane-4) 5%, var(--bg-panel));
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
.reflog-row {
|
|
2582
|
+
display: flex;
|
|
2583
|
+
align-items: center;
|
|
2584
|
+
gap: 12px;
|
|
2585
|
+
padding: 10px 14px;
|
|
2586
|
+
flex-wrap: wrap;
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
.reflog-left {
|
|
2590
|
+
display: flex;
|
|
2591
|
+
align-items: center;
|
|
2592
|
+
gap: 6px;
|
|
2593
|
+
flex: none;
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
.reflog-sel {
|
|
2597
|
+
font: 11.5px var(--mono);
|
|
2598
|
+
color: var(--muted);
|
|
2599
|
+
min-width: 72px;
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
.reflog-act,
|
|
2603
|
+
.reflog-lost {
|
|
2604
|
+
display: inline-flex;
|
|
2605
|
+
align-items: center;
|
|
2606
|
+
padding: 1px 7px;
|
|
2607
|
+
border-radius: 999px;
|
|
2608
|
+
font: 600 11px/1.6 var(--font);
|
|
2609
|
+
letter-spacing: 0.01em;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
.reflog-act {
|
|
2613
|
+
background: var(--bg-active);
|
|
2614
|
+
color: var(--text-2);
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
.reflog-act.act-commit {
|
|
2618
|
+
background: color-mix(in srgb, var(--add) 16%, transparent);
|
|
2619
|
+
color: var(--add);
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
.reflog-act.act-move {
|
|
2623
|
+
background: color-mix(in srgb, var(--lane-1) 16%, transparent);
|
|
2624
|
+
color: var(--lane-1);
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
.reflog-act.act-merge {
|
|
2628
|
+
background: color-mix(in srgb, var(--lane-3) 16%, transparent);
|
|
2629
|
+
color: var(--lane-3);
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
.reflog-act.act-warn {
|
|
2633
|
+
background: color-mix(in srgb, var(--lane-4) 18%, transparent);
|
|
2634
|
+
color: var(--lane-4);
|
|
2635
|
+
}
|
|
2636
|
+
|
|
2637
|
+
.reflog-act.act-danger {
|
|
2638
|
+
background: color-mix(in srgb, var(--del) 16%, transparent);
|
|
2639
|
+
color: var(--del);
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
.reflog-lost {
|
|
2643
|
+
background: color-mix(in srgb, var(--lane-4) 22%, transparent);
|
|
2644
|
+
color: var(--lane-4);
|
|
2645
|
+
border: 1px solid color-mix(in srgb, var(--lane-4) 40%, transparent);
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
.reflog-main {
|
|
2649
|
+
flex: 1 1 260px;
|
|
2650
|
+
min-width: 0;
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
.reflog-msg {
|
|
2654
|
+
display: flex;
|
|
2655
|
+
flex-wrap: wrap;
|
|
2656
|
+
align-items: center;
|
|
2657
|
+
gap: 6px;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
.reflog-link {
|
|
2661
|
+
font-weight: 500;
|
|
2662
|
+
color: var(--text);
|
|
2663
|
+
overflow-wrap: anywhere;
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
.reflog-link:hover {
|
|
2667
|
+
color: var(--accent);
|
|
2668
|
+
text-decoration: underline;
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
.reflog-sub {
|
|
2672
|
+
margin-top: 2px;
|
|
2673
|
+
white-space: nowrap;
|
|
2674
|
+
overflow: hidden;
|
|
2675
|
+
text-overflow: ellipsis;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
.reflog-meta {
|
|
2679
|
+
display: flex;
|
|
2680
|
+
align-items: center;
|
|
2681
|
+
gap: 8px;
|
|
2682
|
+
flex: none;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
.reflog-when {
|
|
2686
|
+
min-width: 68px;
|
|
2687
|
+
text-align: right;
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
.reflog-actions {
|
|
2691
|
+
display: flex;
|
|
2692
|
+
align-items: center;
|
|
2693
|
+
gap: 6px;
|
|
2694
|
+
flex: none;
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2697
|
+
.rescue-box {
|
|
2698
|
+
padding: 12px 14px;
|
|
2699
|
+
border-top: 1px solid var(--border);
|
|
2700
|
+
background: var(--bg-elev);
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
.rescue-head {
|
|
2704
|
+
display: flex;
|
|
2705
|
+
flex-wrap: wrap;
|
|
2706
|
+
align-items: baseline;
|
|
2707
|
+
justify-content: space-between;
|
|
2708
|
+
gap: 6px 12px;
|
|
2709
|
+
margin-bottom: 10px;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
.rescue-cmds {
|
|
2713
|
+
display: flex;
|
|
2714
|
+
flex-direction: column;
|
|
2715
|
+
gap: 8px;
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
.rescue-cmd {
|
|
2719
|
+
display: flex;
|
|
2720
|
+
flex-direction: column;
|
|
2721
|
+
gap: 3px;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
.rescue-line {
|
|
2725
|
+
display: flex;
|
|
2726
|
+
align-items: center;
|
|
2727
|
+
justify-content: space-between;
|
|
2728
|
+
gap: 8px;
|
|
2729
|
+
padding: 6px 8px 6px 10px;
|
|
2730
|
+
border: 1px solid var(--border);
|
|
2731
|
+
border-radius: var(--radius-sm);
|
|
2732
|
+
background: var(--bg-panel);
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
.rescue-line code {
|
|
2736
|
+
font-size: 12px;
|
|
2737
|
+
user-select: all;
|
|
2738
|
+
overflow-x: auto;
|
|
2739
|
+
}
|
|
2740
|
+
|
|
2741
|
+
.reflog-more {
|
|
2742
|
+
display: flex;
|
|
2743
|
+
justify-content: center;
|
|
2744
|
+
margin-top: 16px;
|
|
2745
|
+
}
|
|
2746
|
+
|
|
2460
2747
|
/* ------------------------------------------------------------------ responsive */
|
|
2461
2748
|
|
|
2462
2749
|
/* Columns adapt to the width of the list itself, not the window. */
|
package/src/public/index.html
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<link rel="modulepreload" href="/js/ui.js" />
|
|
12
12
|
<link rel="modulepreload" href="/js/graph.js" />
|
|
13
13
|
<link rel="modulepreload" href="/js/diff.js" />
|
|
14
|
+
<link rel="modulepreload" href="/js/highlight.js" />
|
|
14
15
|
<script type="module" src="/js/main.js"></script>
|
|
15
16
|
</head>
|
|
16
17
|
<body>
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
<nav class="tabs" id="tabs" aria-label="Views">
|
|
28
29
|
<a href="#/" data-view="history">History</a>
|
|
29
30
|
<a href="#/compare" data-view="compare">Compare</a>
|
|
31
|
+
<a href="#/reflog" data-view="reflog">Reflog</a>
|
|
30
32
|
<a href="#/insights" data-view="insights">Insights</a>
|
|
31
33
|
</nav>
|
|
32
34
|
<form class="search" id="search-form" role="search">
|
|
@@ -62,7 +64,7 @@
|
|
|
62
64
|
<dt><kbd>←</kbd> <kbd>→</kbd></dt><dd>Step through a journey (Compare)</dd>
|
|
63
65
|
<dt><kbd>/</kbd></dt><dd>Search</dd>
|
|
64
66
|
<dt><kbd>Esc</kbd></dt><dd>Close panel / clear search</dd>
|
|
65
|
-
<dt><kbd>g</kbd> <kbd>h</kbd> / <kbd>c</kbd> / <kbd>i</kbd></dt><dd>History / Compare / Insights</dd>
|
|
67
|
+
<dt><kbd>g</kbd> <kbd>h</kbd> / <kbd>c</kbd> / <kbd>r</kbd> / <kbd>i</kbd></dt><dd>History / Compare / Reflog / Insights</dd>
|
|
66
68
|
</dl>
|
|
67
69
|
<h2>Search syntax</h2>
|
|
68
70
|
<dl>
|
package/src/public/js/detail.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { api, html, raw, esc, $, avatar, refBadges, relTime, fullDate, short, bytes, plural, icons, copyText, loading, errorBox, empty, WORKTREE } from "./ui.js";
|
|
4
4
|
import { mountChanges } from "./diff.js";
|
|
5
|
+
import { detectLanguage, highlightLine } from "./highlight.js";
|
|
5
6
|
|
|
6
7
|
const enc = (p) => p.split("/").map(encodeURIComponent).join("/");
|
|
7
8
|
|
|
@@ -178,13 +179,15 @@ export function renderDetail(pane, app, hash, initial = {}) {
|
|
|
178
179
|
<button class="btn btn-sm" data-act="file-history">${raw(icons.history)} History</button>
|
|
179
180
|
${blob.binary ? "" : html`<button class="btn btn-sm" data-act="copy-file">${raw(icons.copy)} Copy</button>`}
|
|
180
181
|
</div>
|
|
181
|
-
${blob.binary ? empty("Binary file", "Binary content is not displayed.") : raw(codeTable(lines, bl))}
|
|
182
|
+
${blob.binary ? empty("Binary file", "Binary content is not displayed.") : raw(codeTable(lines, bl, path))}
|
|
182
183
|
${blob.truncated ? html`<div class="diff-note">File truncated (showing the first 2 MB)</div>` : ""}`);
|
|
183
184
|
body._content = blob.content;
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
function codeTable(lines, bl) {
|
|
187
|
+
function codeTable(lines, bl, path) {
|
|
187
188
|
const limit = 20000;
|
|
189
|
+
const lang = detectLanguage(path);
|
|
190
|
+
let hlState = null;
|
|
188
191
|
let out = `<table class="code-view${bl ? " blame" : ""}"><tbody>`;
|
|
189
192
|
let prev = null;
|
|
190
193
|
let now = Date.now() / 1000;
|
|
@@ -202,7 +205,9 @@ export function renderDetail(pane, app, hash, initial = {}) {
|
|
|
202
205
|
first ? `<a href="#/commit/${h}" title="${esc(c.subject || "")}"><span class="sha">${short(h)}</span><span class="who">${esc(c.author || "")}</span><span class="when">${c.date ? esc(relTime(c.date)) : ""}</span></a>` : ""
|
|
203
206
|
}</td>`;
|
|
204
207
|
}
|
|
205
|
-
|
|
208
|
+
const res = highlightLine(lines[i], lang, hlState);
|
|
209
|
+
hlState = res.state;
|
|
210
|
+
out += `<tr>${gutter}<td class="ln" data-n="${i + 1}"></td><td class="code">${res.html || " "}</td></tr>`;
|
|
206
211
|
}
|
|
207
212
|
out += "</tbody></table>";
|
|
208
213
|
if (lines.length > limit) out += `<div class="diff-note">Showing the first ${limit.toLocaleString()} lines</div>`;
|