@n-seiji/nuthatch 0.1.5 → 0.1.7
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/dist/clean-n2f9z8n3.js +208 -0
- package/dist/cli-23z98dw1.js +116 -0
- package/dist/cli-2bhb9p0x.js +19 -0
- package/dist/cli-3ya15je0.js +114 -0
- package/dist/cli-71jgs14h.js +112 -0
- package/dist/cli-7jg5qqs9.js +88 -0
- package/dist/cli-dbzx9nzg.js +40 -0
- package/dist/cli-g72ra4e5.js +104 -0
- package/dist/cli-pick-w9qk71fy.js +1533 -0
- package/dist/cli-pqd2qe7v.js +35 -0
- package/dist/cli-qrxgkskr.js +69 -0
- package/dist/cli-rcw5adqd.js +124 -0
- package/dist/cli-update-7exha1em.js +891 -0
- package/dist/cli-ygt2w4e1.js +195 -0
- package/dist/cli.js +220 -5841
- package/dist/init-s0dafa83.js +65 -0
- package/dist/jump-nvdkeega.js +103 -0
- package/dist/ls-kvz4wmc9.js +34 -0
- package/dist/render-ls-6r3vv7y0.js +160 -0
- package/dist/rm-231qjgd8.js +7 -0
- package/dist/root-mmyazwc3.js +7 -0
- package/package.json +2 -3
- package/shell/init.zsh +7 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// src/domain/classify.ts
|
|
2
|
+
var isWithin = (parent, child) => {
|
|
3
|
+
if (parent === child) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const parentWithSlash = parent.endsWith("/") ? parent : `${parent}/`;
|
|
7
|
+
return child.startsWith(parentWithSlash);
|
|
8
|
+
};
|
|
9
|
+
var classifyWorktreePath = (path, rootPath, managedRoot) => {
|
|
10
|
+
if (path === rootPath) {
|
|
11
|
+
return "root";
|
|
12
|
+
}
|
|
13
|
+
if (path === managedRoot || isWithin(managedRoot, path)) {
|
|
14
|
+
return "managed";
|
|
15
|
+
}
|
|
16
|
+
return "external";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/domain/porcelain.ts
|
|
20
|
+
var REFS_HEADS_PREFIX = "refs/heads/";
|
|
21
|
+
var branchNameFromRef = (ref) => ref.startsWith(REFS_HEADS_PREFIX) ? ref.slice(REFS_HEADS_PREFIX.length) : ref;
|
|
22
|
+
var parseRecord = (lines) => {
|
|
23
|
+
let path = null;
|
|
24
|
+
let head = null;
|
|
25
|
+
let branch = null;
|
|
26
|
+
let detached = false;
|
|
27
|
+
let bare = false;
|
|
28
|
+
let locked = false;
|
|
29
|
+
let lockReason = null;
|
|
30
|
+
let prunable = false;
|
|
31
|
+
let prunableReason = null;
|
|
32
|
+
for (const line of lines.filter((candidate) => candidate.length > 0)) {
|
|
33
|
+
const spaceIndex = line.indexOf(" ");
|
|
34
|
+
const key = spaceIndex === -1 ? line : line.slice(0, spaceIndex);
|
|
35
|
+
const value = spaceIndex === -1 ? "" : line.slice(spaceIndex + 1);
|
|
36
|
+
switch (key) {
|
|
37
|
+
case "worktree": {
|
|
38
|
+
path = value;
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case "HEAD": {
|
|
42
|
+
head = value;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case "branch": {
|
|
46
|
+
branch = branchNameFromRef(value);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "detached": {
|
|
50
|
+
detached = true;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case "bare": {
|
|
54
|
+
bare = true;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case "locked": {
|
|
58
|
+
locked = true;
|
|
59
|
+
lockReason = value.length > 0 ? value : null;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case "prunable": {
|
|
63
|
+
prunable = true;
|
|
64
|
+
prunableReason = value.length > 0 ? value : null;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
default: {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (path === null) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
path,
|
|
77
|
+
head,
|
|
78
|
+
branch,
|
|
79
|
+
detached,
|
|
80
|
+
bare,
|
|
81
|
+
locked,
|
|
82
|
+
lockReason,
|
|
83
|
+
prunable,
|
|
84
|
+
prunableReason
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
var parsePorcelain = (output) => {
|
|
88
|
+
if (output.length === 0) {
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
const trimmed = output.endsWith("\x00") ? output.slice(0, -1) : output;
|
|
92
|
+
const records = trimmed.split("\x00\x00");
|
|
93
|
+
const result = [];
|
|
94
|
+
for (const record of records.filter((candidate) => candidate.length > 0)) {
|
|
95
|
+
const lines = record.split("\x00");
|
|
96
|
+
const parsed = parseRecord(lines);
|
|
97
|
+
if (parsed !== null) {
|
|
98
|
+
result.push(parsed);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export { isWithin, classifyWorktreePath, REFS_HEADS_PREFIX, parsePorcelain };
|