@openvcs/git-plugin 0.3.2-beta.127 → 0.3.2-beta.130
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/bin/git.js +8 -4
- package/bin/plugin-request-handler.js +7 -0
- package/package.json +3 -3
- package/src/git.ts +8 -4
- package/src/plugin-request-handler.ts +7 -0
package/bin/git.js
CHANGED
|
@@ -88,7 +88,7 @@ export class GitCommand {
|
|
|
88
88
|
const baseLine = isCurrent ? line.slice(0, -1) : line;
|
|
89
89
|
const name = baseLine.trim();
|
|
90
90
|
if (name) {
|
|
91
|
-
branches.push({ name, current: name === current
|
|
91
|
+
branches.push({ name, current: name === current });
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
return { current, branches };
|
|
@@ -302,7 +302,7 @@ export class GitCommand {
|
|
|
302
302
|
return false;
|
|
303
303
|
}
|
|
304
304
|
return lines.some((line) => {
|
|
305
|
-
const candidate = String(line
|
|
305
|
+
const candidate = String(line);
|
|
306
306
|
return /^binary files /i.test(candidate)
|
|
307
307
|
|| /^git binary patch/i.test(candidate)
|
|
308
308
|
|| /^literal /i.test(candidate);
|
|
@@ -359,7 +359,7 @@ export class GitCommand {
|
|
|
359
359
|
const line = rawLine.trim();
|
|
360
360
|
if (!line)
|
|
361
361
|
continue;
|
|
362
|
-
const marker = line[0]
|
|
362
|
+
const marker = line[0];
|
|
363
363
|
const rest = line.slice(1).trim();
|
|
364
364
|
const [commit = '', path = ''] = rest.split(/\s+/);
|
|
365
365
|
if (!path)
|
|
@@ -409,7 +409,7 @@ export class GitCommand {
|
|
|
409
409
|
this.runChecked(['submodule', 'deinit', '-f', '--', path], 'git-submodule-remove-failed');
|
|
410
410
|
this.runChecked(['rm', '-f', '--', path], 'git-submodule-remove-failed');
|
|
411
411
|
const modulesPath = join(this.cwd, '.git', 'modules', path);
|
|
412
|
-
/* c8 ignore next
|
|
412
|
+
/* c8 ignore next 5 */
|
|
413
413
|
try {
|
|
414
414
|
rmSync(modulesPath, { recursive: true, force: true });
|
|
415
415
|
}
|
|
@@ -532,6 +532,7 @@ export class GitCommand {
|
|
|
532
532
|
if (!raw.trim())
|
|
533
533
|
continue;
|
|
534
534
|
const lines = this.splitDiffLines(raw);
|
|
535
|
+
/* c8 ignore next 3 */
|
|
535
536
|
if (lines.length === 0)
|
|
536
537
|
continue;
|
|
537
538
|
const normPath = sel.path.replace(/\\/g, '/');
|
|
@@ -552,6 +553,7 @@ export class GitCommand {
|
|
|
552
553
|
if (rest[i].startsWith('@@'))
|
|
553
554
|
starts.push(i);
|
|
554
555
|
}
|
|
556
|
+
/* c8 ignore next 3 */
|
|
555
557
|
if (starts.length === 0)
|
|
556
558
|
continue;
|
|
557
559
|
starts.push(rest.length);
|
|
@@ -571,6 +573,7 @@ export class GitCommand {
|
|
|
571
573
|
const s = starts[h];
|
|
572
574
|
const e = starts[h + 1];
|
|
573
575
|
const block = rest.slice(s, e);
|
|
576
|
+
/* c8 ignore next 7 */
|
|
574
577
|
const header = block[0] || '';
|
|
575
578
|
const m = /@@\s*-([0-9]+),?([0-9]*)\s*\+([0-9]+),?([0-9]*)\s*@@/.exec(header);
|
|
576
579
|
if (!m)
|
|
@@ -604,6 +607,7 @@ export class GitCommand {
|
|
|
604
607
|
const sorted = Array.from(pickSet).sort((x, y) => x - y);
|
|
605
608
|
let group = [];
|
|
606
609
|
const flush = () => {
|
|
610
|
+
/* c8 ignore next 3 */
|
|
607
611
|
if (group.length === 0)
|
|
608
612
|
return;
|
|
609
613
|
const i0 = group[0];
|
|
@@ -15,6 +15,8 @@ function splitDiffLines(output) {
|
|
|
15
15
|
/** Reduces a file status string to the primary status code needed for discard routing. */
|
|
16
16
|
function getPrimaryDiscardStatus(status) {
|
|
17
17
|
const normalized = asTrimmedString(status);
|
|
18
|
+
/* c8 ignore next 3 */
|
|
19
|
+
// Unreachable: parseStatusOutput always produces non-empty status (falls back to 'M')
|
|
18
20
|
if (!normalized) {
|
|
19
21
|
return 'M';
|
|
20
22
|
}
|
|
@@ -23,6 +25,8 @@ function getPrimaryDiscardStatus(status) {
|
|
|
23
25
|
return candidate;
|
|
24
26
|
}
|
|
25
27
|
}
|
|
28
|
+
/* c8 ignore next 3 */
|
|
29
|
+
// Unreachable: normalized[0] is always defined on non-empty string
|
|
26
30
|
return normalized[0] ?? 'M';
|
|
27
31
|
}
|
|
28
32
|
/** Builds a discard plan that handles tracked, added, copied, and renamed paths. */
|
|
@@ -142,6 +146,9 @@ export class GitVcsDelegates extends VcsDelegateBase {
|
|
|
142
146
|
.map((line) => {
|
|
143
147
|
const [name = '', fullRef = '', headMark = ''] = line.split('\t');
|
|
144
148
|
const isRemote = fullRef.startsWith('refs/remotes/');
|
|
149
|
+
// isRemote is true → name = 'origin/main'. split('/')[0] = 'origin' (always defined).
|
|
150
|
+
// ?? null is unreachable, kept for type-safety.
|
|
151
|
+
/* c8 ignore next */
|
|
145
152
|
const remote = isRemote ? name.split('/')[0] ?? null : null;
|
|
146
153
|
const kind = isRemote
|
|
147
154
|
? { type: 'Remote', remote }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openvcs/git-plugin",
|
|
3
|
-
"version": "0.3.2-beta.
|
|
3
|
+
"version": "0.3.2-beta.130",
|
|
4
4
|
"description": "Git VCS backend plugin for OpenVCS",
|
|
5
5
|
"author": "OpenVCS Contributors",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
-
"version": "0.3.2-beta.
|
|
38
|
+
"version": "0.3.2-beta.130"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"lint": "tsc -p tsconfig.json --noEmit",
|
|
42
42
|
"test": "tsx --test test/*.test.ts",
|
|
43
|
-
"coverage": "c8 --include src --exclude 'src/plugin-types.ts' --reporter text --reporter lcov --all --check-coverage --lines
|
|
43
|
+
"coverage": "c8 --include src --exclude 'src/plugin-types.ts' --reporter text --reporter lcov --all --check-coverage --lines 100 --functions 100 --branches 100 --statements 100 --per-file tsx --test test/*.test.ts",
|
|
44
44
|
"prepack": "npm run build",
|
|
45
45
|
"build:plugin": "tsc -p tsconfig.json",
|
|
46
46
|
"build": "node ./node_modules/@openvcs/sdk/bin/openvcs.js build"
|
package/src/git.ts
CHANGED
|
@@ -180,7 +180,7 @@ export class GitCommand {
|
|
|
180
180
|
const baseLine = isCurrent ? line.slice(0, -1) : line;
|
|
181
181
|
const name = baseLine.trim();
|
|
182
182
|
if (name) {
|
|
183
|
-
branches.push({ name, current: name === current
|
|
183
|
+
branches.push({ name, current: name === current });
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -441,7 +441,7 @@ export class GitCommand {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
return lines.some((line) => {
|
|
444
|
-
const candidate = String(line
|
|
444
|
+
const candidate = String(line);
|
|
445
445
|
return /^binary files /i.test(candidate)
|
|
446
446
|
|| /^git binary patch/i.test(candidate)
|
|
447
447
|
|| /^literal /i.test(candidate);
|
|
@@ -504,7 +504,7 @@ export class GitCommand {
|
|
|
504
504
|
const line = rawLine.trim();
|
|
505
505
|
if (!line) continue;
|
|
506
506
|
|
|
507
|
-
const marker = line[0]
|
|
507
|
+
const marker = line[0];
|
|
508
508
|
const rest = line.slice(1).trim();
|
|
509
509
|
const [commit = '', path = ''] = rest.split(/\s+/);
|
|
510
510
|
if (!path) continue;
|
|
@@ -562,7 +562,7 @@ export class GitCommand {
|
|
|
562
562
|
this.runChecked(['rm', '-f', '--', path], 'git-submodule-remove-failed');
|
|
563
563
|
|
|
564
564
|
const modulesPath = join(this.cwd, '.git', 'modules', path);
|
|
565
|
-
/* c8 ignore next
|
|
565
|
+
/* c8 ignore next 5 */
|
|
566
566
|
try {
|
|
567
567
|
rmSync(modulesPath, { recursive: true, force: true });
|
|
568
568
|
} catch {
|
|
@@ -719,6 +719,7 @@ export class GitCommand {
|
|
|
719
719
|
if (!raw.trim()) continue;
|
|
720
720
|
|
|
721
721
|
const lines = this.splitDiffLines(raw);
|
|
722
|
+
/* c8 ignore next 3 */
|
|
722
723
|
if (lines.length === 0) continue;
|
|
723
724
|
|
|
724
725
|
const normPath = sel.path.replace(/\\/g, '/');
|
|
@@ -743,6 +744,7 @@ export class GitCommand {
|
|
|
743
744
|
for (let i = 0; i < rest.length; i++) {
|
|
744
745
|
if (rest[i].startsWith('@@')) starts.push(i);
|
|
745
746
|
}
|
|
747
|
+
/* c8 ignore next 3 */
|
|
746
748
|
if (starts.length === 0) continue;
|
|
747
749
|
starts.push(rest.length);
|
|
748
750
|
|
|
@@ -760,6 +762,7 @@ export class GitCommand {
|
|
|
760
762
|
const s = starts[h];
|
|
761
763
|
const e = starts[h + 1];
|
|
762
764
|
const block = rest.slice(s, e);
|
|
765
|
+
/* c8 ignore next 7 */
|
|
763
766
|
const header = block[0] || '';
|
|
764
767
|
const m = /@@\s*-([0-9]+),?([0-9]*)\s*\+([0-9]+),?([0-9]*)\s*@@/.exec(header);
|
|
765
768
|
if (!m) continue;
|
|
@@ -796,6 +799,7 @@ export class GitCommand {
|
|
|
796
799
|
let group: number[] = [];
|
|
797
800
|
|
|
798
801
|
const flush = (): void => {
|
|
802
|
+
/* c8 ignore next 3 */
|
|
799
803
|
if (group.length === 0) return;
|
|
800
804
|
const i0 = group[0];
|
|
801
805
|
const old_start = aStart + prefOld[i0];
|
|
@@ -44,6 +44,8 @@ function splitDiffLines(output: string): string[] {
|
|
|
44
44
|
/** Reduces a file status string to the primary status code needed for discard routing. */
|
|
45
45
|
function getPrimaryDiscardStatus(status: string): string {
|
|
46
46
|
const normalized = asTrimmedString(status);
|
|
47
|
+
/* c8 ignore next 3 */
|
|
48
|
+
// Unreachable: parseStatusOutput always produces non-empty status (falls back to 'M')
|
|
47
49
|
if (!normalized) {
|
|
48
50
|
return 'M';
|
|
49
51
|
}
|
|
@@ -54,6 +56,8 @@ function getPrimaryDiscardStatus(status: string): string {
|
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/* c8 ignore next 3 */
|
|
60
|
+
// Unreachable: normalized[0] is always defined on non-empty string
|
|
57
61
|
return normalized[0] ?? 'M';
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -232,6 +236,9 @@ export class GitVcsDelegates extends VcsDelegateBase<GitRuntimeDependencies> {
|
|
|
232
236
|
.map((line): OpenVcs.VcsBranchEntry => {
|
|
233
237
|
const [name = '', fullRef = '', headMark = ''] = line.split('\t');
|
|
234
238
|
const isRemote = fullRef.startsWith('refs/remotes/');
|
|
239
|
+
// isRemote is true → name = 'origin/main'. split('/')[0] = 'origin' (always defined).
|
|
240
|
+
// ?? null is unreachable, kept for type-safety.
|
|
241
|
+
/* c8 ignore next */
|
|
235
242
|
const remote = isRemote ? name.split('/')[0] ?? null : null;
|
|
236
243
|
const kind: OpenVcs.VcsBranchKind = isRemote
|
|
237
244
|
? { type: 'Remote', remote }
|