@self-review/core 1.43.0 → 1.43.2
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/index.cjs +12 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
createGitLabProvider: () => createGitLabProvider,
|
|
42
42
|
createIgnoreFilter: () => createIgnoreFilter,
|
|
43
43
|
defaultGitRunner: () => defaultGitRunner,
|
|
44
|
+
detectExistingClone: () => detectExistingClone,
|
|
44
45
|
generateSyntheticDiffs: () => generateSyntheticDiffs,
|
|
45
46
|
generateUntrackedDiffs: () => generateUntrackedDiffs,
|
|
46
47
|
getGitDiffStats: () => getGitDiffStats,
|
|
@@ -2598,7 +2599,7 @@ async function revParse(runner, repoPath, ref) {
|
|
|
2598
2599
|
}
|
|
2599
2600
|
return result.stdout.trim();
|
|
2600
2601
|
}
|
|
2601
|
-
async function detectExistingClone(
|
|
2602
|
+
async function detectExistingClone(url, cwd, runner = defaultGitRunner) {
|
|
2602
2603
|
const toplevel = await runner("git", ["-C", cwd, "rev-parse", "--show-toplevel"]);
|
|
2603
2604
|
if (toplevel.exitCode !== 0) {
|
|
2604
2605
|
return null;
|
|
@@ -2679,8 +2680,8 @@ async function materializeIntoTempClone(runner, url, baseBranch) {
|
|
|
2679
2680
|
throw error;
|
|
2680
2681
|
}
|
|
2681
2682
|
}
|
|
2682
|
-
async function materialize(url, baseBranch, cwd, runner = defaultGitRunner) {
|
|
2683
|
-
const existing = await detectExistingClone(
|
|
2683
|
+
async function materialize(url, baseBranch, cwd, runner = defaultGitRunner, existingClone) {
|
|
2684
|
+
const existing = existingClone === void 0 ? await detectExistingClone(url, cwd, runner) : existingClone;
|
|
2684
2685
|
if (existing) {
|
|
2685
2686
|
return materializeIntoExistingClone(
|
|
2686
2687
|
runner,
|
|
@@ -2692,16 +2693,19 @@ async function materialize(url, baseBranch, cwd, runner = defaultGitRunner) {
|
|
|
2692
2693
|
}
|
|
2693
2694
|
return materializeIntoTempClone(runner, url, baseBranch);
|
|
2694
2695
|
}
|
|
2695
|
-
async function resolveRemoteDefaultBranch(url, runner = defaultGitRunner) {
|
|
2696
|
+
async function resolveRemoteDefaultBranch(url, runner = defaultGitRunner, existing = null) {
|
|
2696
2697
|
const cloneUrl = cloneUrlFor(url);
|
|
2697
|
-
const
|
|
2698
|
+
const remote = existing?.remoteName ?? cloneUrl;
|
|
2699
|
+
const label = existing ? `${remote} (${cloneUrl})` : cloneUrl;
|
|
2700
|
+
const args = existing ? ["-C", existing.repoPath, "ls-remote", "--symref", remote, "HEAD"] : ["ls-remote", "--symref", remote, "HEAD"];
|
|
2701
|
+
const result = await runner("git", args);
|
|
2698
2702
|
if (result.exitCode !== 0) {
|
|
2699
|
-
throw gitFailure(`ls-remote of ${
|
|
2703
|
+
throw gitFailure(`ls-remote of ${label}`, result, true);
|
|
2700
2704
|
}
|
|
2701
2705
|
const match = /^ref:\s+refs\/heads\/(\S+)\s+HEAD$/m.exec(result.stdout);
|
|
2702
2706
|
if (!match) {
|
|
2703
2707
|
throw new Error(
|
|
2704
|
-
`Failed to resolve the default branch of ${
|
|
2708
|
+
`Failed to resolve the default branch of ${label}: git ls-remote returned no HEAD symref.`
|
|
2705
2709
|
);
|
|
2706
2710
|
}
|
|
2707
2711
|
return match[1];
|
|
@@ -2719,6 +2723,7 @@ async function resolveRemoteDefaultBranch(url, runner = defaultGitRunner) {
|
|
|
2719
2723
|
createGitLabProvider,
|
|
2720
2724
|
createIgnoreFilter,
|
|
2721
2725
|
defaultGitRunner,
|
|
2726
|
+
detectExistingClone,
|
|
2722
2727
|
generateSyntheticDiffs,
|
|
2723
2728
|
generateUntrackedDiffs,
|
|
2724
2729
|
getGitDiffStats,
|