@in-the-loop-labs/pair-review 5.3.0 → 5.3.1
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/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/src/config.js +92 -5
- package/src/git/worktree.js +29 -10
- package/src/github/client.js +30 -10
- package/src/setup/pr-setup.js +54 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pair-review",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "pair-review app integration — Open PRs and local changes in the pair-review web UI, run server-side AI analysis, and address review feedback. Requires the pair-review MCP server.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "in-the-loop-labs",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pair-loop",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.1",
|
|
4
4
|
"description": "Agent-orchestrated review loop — implement, review with pair-review multi-model councils via the headless CLI, triage, fix, and repeat until a final review returns no blockers. MCP-independent.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "in-the-loop-labs",
|
package/src/config.js
CHANGED
|
@@ -627,6 +627,10 @@ function isExclusiveAltHost(repoConfig) {
|
|
|
627
627
|
* is consulted. The repo's explicit `features` block (written for the alt host)
|
|
628
628
|
* also does not apply to its github.com binding.
|
|
629
629
|
*
|
|
630
|
+
* The binding also carries `cloneUrl` — the repo's explicitly configured
|
|
631
|
+
* `clone_url`, or `null` when unset. Like `features`, it describes the ALT
|
|
632
|
+
* host, so the github.com binding of a DUAL repo always reports `null`.
|
|
633
|
+
*
|
|
630
634
|
* Refreshable sources (`repo:token_command`, `config:github_token_command`)
|
|
631
635
|
* additionally carry a `refresh` closure on the returned binding. Calling
|
|
632
636
|
* `refresh()` busts the cached token for that exact source, re-runs the
|
|
@@ -638,7 +642,7 @@ function isExclusiveAltHost(repoConfig) {
|
|
|
638
642
|
* @param {string|null|undefined} repository - "owner/repo" identifier, or null/undefined for no-repo fallback
|
|
639
643
|
* @param {Object} config - Configuration object from loadConfig()
|
|
640
644
|
* @param {{ host?: string|null }} [options] - Per-PR host override (see above)
|
|
641
|
-
* @returns {{ apiHost: string|null, host: string|null, token: string, features: Object, source: string, refresh: (function(): string)|null }}
|
|
645
|
+
* @returns {{ apiHost: string|null, host: string|null, token: string, features: Object, cloneUrl: string|null, source: string, refresh: (function(): string)|null }}
|
|
642
646
|
*/
|
|
643
647
|
function resolveHostBinding(repository, config, options = {}) {
|
|
644
648
|
const safeConfig = config || {};
|
|
@@ -688,6 +692,14 @@ function resolveHostBinding(repository, config, options = {}) {
|
|
|
688
692
|
const explicitFeatures = isDualGithubBinding ? undefined : repoConfig?.features;
|
|
689
693
|
const features = _resolveFeatures(apiHost, explicitFeatures);
|
|
690
694
|
|
|
695
|
+
// Explicitly configured canonical clone URL for this repo. Like `features`,
|
|
696
|
+
// it describes the alt host, so a dual repo's github.com binding does not
|
|
697
|
+
// carry it (github.com's API reports the right clone_url itself).
|
|
698
|
+
const configuredCloneUrl = (repoConfig && typeof repoConfig.clone_url === 'string' && repoConfig.clone_url)
|
|
699
|
+
? repoConfig.clone_url
|
|
700
|
+
: null;
|
|
701
|
+
const cloneUrl = isDualGithubBinding ? null : configuredCloneUrl;
|
|
702
|
+
|
|
691
703
|
// Token resolution
|
|
692
704
|
let token = '';
|
|
693
705
|
let source = 'none';
|
|
@@ -697,7 +709,7 @@ function resolveHostBinding(repository, config, options = {}) {
|
|
|
697
709
|
token = process.env.GITHUB_TOKEN;
|
|
698
710
|
source = 'env:GITHUB_TOKEN';
|
|
699
711
|
logger.debug('Using GitHub token from GITHUB_TOKEN environment variable');
|
|
700
|
-
return { apiHost, host: apiHost, token, features, source, refresh: null };
|
|
712
|
+
return { apiHost, host: apiHost, token, features, cloneUrl, source, refresh: null };
|
|
701
713
|
}
|
|
702
714
|
|
|
703
715
|
// 2. Repo-level literal token (alt-host credential; not used for a dual
|
|
@@ -706,7 +718,7 @@ function resolveHostBinding(repository, config, options = {}) {
|
|
|
706
718
|
token = repoConfig.token;
|
|
707
719
|
source = 'repo:token';
|
|
708
720
|
logger.debug(`Using token from repos[${repository}].token`);
|
|
709
|
-
return { apiHost, host: apiHost, token, features, source, refresh: null };
|
|
721
|
+
return { apiHost, host: apiHost, token, features, cloneUrl, source, refresh: null };
|
|
710
722
|
}
|
|
711
723
|
|
|
712
724
|
// 3. Repo-level token_command
|
|
@@ -718,6 +730,7 @@ function resolveHostBinding(repository, config, options = {}) {
|
|
|
718
730
|
host: apiHost,
|
|
719
731
|
token: result,
|
|
720
732
|
features,
|
|
733
|
+
cloneUrl,
|
|
721
734
|
source: 'repo:token_command',
|
|
722
735
|
refresh: _makeRefresh(repository, safeConfig, 'repo:token_command', options)
|
|
723
736
|
};
|
|
@@ -731,7 +744,7 @@ function resolveHostBinding(repository, config, options = {}) {
|
|
|
731
744
|
token = safeConfig.github_token;
|
|
732
745
|
source = 'config:github_token';
|
|
733
746
|
logger.debug('Using GitHub token from config.github_token');
|
|
734
|
-
return { apiHost, host: apiHost, token, features, source, refresh: null };
|
|
747
|
+
return { apiHost, host: apiHost, token, features, cloneUrl, source, refresh: null };
|
|
735
748
|
}
|
|
736
749
|
|
|
737
750
|
// 5. Top-level github_token_command. Like step 4, github.com-only.
|
|
@@ -747,6 +760,7 @@ function resolveHostBinding(repository, config, options = {}) {
|
|
|
747
760
|
host: apiHost,
|
|
748
761
|
token: result,
|
|
749
762
|
features,
|
|
763
|
+
cloneUrl,
|
|
750
764
|
source: 'config:github_token_command',
|
|
751
765
|
refresh: _makeRefresh(repository, safeConfig, 'config:github_token_command', options)
|
|
752
766
|
};
|
|
@@ -758,7 +772,7 @@ function resolveHostBinding(repository, config, options = {}) {
|
|
|
758
772
|
} else {
|
|
759
773
|
logger.debug('No token resolved for host binding');
|
|
760
774
|
}
|
|
761
|
-
return { apiHost, host: apiHost, token: '', features, source: 'none', refresh: null };
|
|
775
|
+
return { apiHost, host: apiHost, token: '', features, cloneUrl, source: 'none', refresh: null };
|
|
762
776
|
}
|
|
763
777
|
|
|
764
778
|
/**
|
|
@@ -1091,6 +1105,18 @@ function validateRepoConfig(config) {
|
|
|
1091
1105
|
}
|
|
1092
1106
|
}
|
|
1093
1107
|
|
|
1108
|
+
// Optional canonical clone URL for the repository. Primarily for alt
|
|
1109
|
+
// hosts whose API omits `base.repo.clone_url` on the PR response; without
|
|
1110
|
+
// it pair-review falls back to a github.com URL, which matches the wrong
|
|
1111
|
+
// local remote and clones from the wrong host.
|
|
1112
|
+
if (repoEntry.clone_url !== undefined && repoEntry.clone_url !== null) {
|
|
1113
|
+
if (typeof repoEntry.clone_url !== 'string' || !repoEntry.clone_url) {
|
|
1114
|
+
throw new Error(
|
|
1115
|
+
`Invalid pair-review config: repos["${repoKey}"].clone_url must be a non-empty string.`
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1094
1120
|
const links = repoEntry.links;
|
|
1095
1121
|
if (links && typeof links === 'object' && links.external !== undefined && links.external !== null) {
|
|
1096
1122
|
const ext = links.external;
|
|
@@ -1482,6 +1508,65 @@ function getRepoSkipBulkFetch(config, repository) {
|
|
|
1482
1508
|
return repoConfig?.skip_bulk_fetch === true;
|
|
1483
1509
|
}
|
|
1484
1510
|
|
|
1511
|
+
/**
|
|
1512
|
+
* Gets the explicitly configured canonical clone URL for a repository.
|
|
1513
|
+
*
|
|
1514
|
+
* Primarily for alt hosts whose GitHub-compatible REST API omits
|
|
1515
|
+
* `base.repo.clone_url` from the pull request response. When configured, it
|
|
1516
|
+
* is the URL matched against the local checkout's `git remote -v` entries to
|
|
1517
|
+
* pick the fetch remote, and the URL used for a fresh clone when no local
|
|
1518
|
+
* checkout exists.
|
|
1519
|
+
*
|
|
1520
|
+
* @param {Object} config - Configuration object from loadConfig()
|
|
1521
|
+
* @param {string} repository - Repository in "owner/repo" format
|
|
1522
|
+
* @returns {string|null} - Clone URL or null if not configured
|
|
1523
|
+
*/
|
|
1524
|
+
function getRepoCloneUrl(config, repository) {
|
|
1525
|
+
const repoConfig = getRepoConfig(config || {}, repository);
|
|
1526
|
+
const value = repoConfig?.clone_url;
|
|
1527
|
+
return (typeof value === 'string' && value) ? value : null;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* Host-aware variant of {@link getRepoCloneUrl}.
|
|
1532
|
+
*
|
|
1533
|
+
* `clone_url`, like `features`, describes the repo's ALT host, so the
|
|
1534
|
+
* github.com binding of a DUAL repo (`api_host` set with `exclusive: false`)
|
|
1535
|
+
* must not report it — github.com's API reports the right `clone_url` itself.
|
|
1536
|
+
* This mirrors the `isDualGithubBinding` guard in `resolveHostBinding`, for
|
|
1537
|
+
* callers that need the configured URL WITHOUT resolving a full binding (e.g.
|
|
1538
|
+
* restore mode, which never contacts an API).
|
|
1539
|
+
*
|
|
1540
|
+
* `host` follows the `resolveHostBinding` options convention:
|
|
1541
|
+
* - `undefined` — host unknown; apply the ambiguity rule (an EXCLUSIVE
|
|
1542
|
+
* alt-host repo binds to its alt host, a DUAL or plain repo to github.com).
|
|
1543
|
+
* - `null` — github.com.
|
|
1544
|
+
* - `'<url>'` — an alt host.
|
|
1545
|
+
*
|
|
1546
|
+
* Unlike `resolveHostBinding` this never throws on a contradictory host: it
|
|
1547
|
+
* is an advisory lookup, and a bad host simply yields the conservative answer.
|
|
1548
|
+
*
|
|
1549
|
+
* @param {Object} config - Configuration object from loadConfig()
|
|
1550
|
+
* @param {string} repository - `repos[...]` config-lookup key
|
|
1551
|
+
* @param {string|null|undefined} host - The host this lookup is for (see above)
|
|
1552
|
+
* @returns {string|null} - Clone URL, or null when unset or not applicable
|
|
1553
|
+
*/
|
|
1554
|
+
function getRepoCloneUrlForHost(config, repository, host) {
|
|
1555
|
+
const repoConfig = getRepoConfig(config || {}, repository);
|
|
1556
|
+
const configuredApiHost = (repoConfig && typeof repoConfig.api_host === 'string' && repoConfig.api_host)
|
|
1557
|
+
? repoConfig.api_host
|
|
1558
|
+
: null;
|
|
1559
|
+
if (configuredApiHost !== null && !isExclusiveAltHost(repoConfig)) {
|
|
1560
|
+
// Dual repo: the ambiguity rule (host unknown) binds github.com, and so
|
|
1561
|
+
// does an explicit `null`. Either way the configured URL does not apply.
|
|
1562
|
+
const effectiveHost = host === undefined ? null : host;
|
|
1563
|
+
if (effectiveHost === null) {
|
|
1564
|
+
return null;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
return getRepoCloneUrl(config, repository);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1485
1570
|
/**
|
|
1486
1571
|
* Gets the configured pool size for a repository from file config only.
|
|
1487
1572
|
* Prefer resolvePoolConfig() when DB repo_settings are available.
|
|
@@ -1732,6 +1817,8 @@ module.exports = {
|
|
|
1732
1817
|
resolveRepoOptions,
|
|
1733
1818
|
getRepoResetScript,
|
|
1734
1819
|
getRepoSkipBulkFetch,
|
|
1820
|
+
getRepoCloneUrl,
|
|
1821
|
+
getRepoCloneUrlForHost,
|
|
1735
1822
|
getRepoPoolSize,
|
|
1736
1823
|
getRepoPoolFetchInterval,
|
|
1737
1824
|
getRepoLoadSkills,
|
package/src/git/worktree.js
CHANGED
|
@@ -73,6 +73,11 @@ class GitWorktreeManager {
|
|
|
73
73
|
* repository's git config. This preserves proxy/mirror setups where the
|
|
74
74
|
* canonical fetch URL may differ from GitHub's clone URL.
|
|
75
75
|
*
|
|
76
|
+
* A remote matching `cloneUrl` always wins over one matching `sshUrl`,
|
|
77
|
+
* regardless of `git remote -v` ordering: `cloneUrl` may be the user's
|
|
78
|
+
* explicitly configured `repos[...].clone_url`, while `sshUrl` still comes
|
|
79
|
+
* from the API and can name a different host.
|
|
80
|
+
*
|
|
76
81
|
* @param {Object} git - simple-git instance
|
|
77
82
|
* @param {string} cloneUrl - HTTPS clone URL of the target repository
|
|
78
83
|
* @param {string} sshUrl - SSH URL of the target repository (may be empty/null)
|
|
@@ -88,10 +93,15 @@ class GitWorktreeManager {
|
|
|
88
93
|
throw new Error(`No remotes configured — cannot resolve base repository for ${cloneUrl}`);
|
|
89
94
|
}
|
|
90
95
|
|
|
91
|
-
// Parse remote output into { name: url } map (fetch URLs only)
|
|
96
|
+
// Parse remote output into { name: url } map (fetch URLs only).
|
|
97
|
+
// `git remote -v` annotates a partial-clone remote's fetch line with its
|
|
98
|
+
// object filter (`origin<TAB>https://… (fetch) [blob:none]`), so the
|
|
99
|
+
// `(fetch)` marker is not always the end of the line. Anchoring on it
|
|
100
|
+
// would drop every filtered remote — typically `origin` itself on a
|
|
101
|
+
// partial clone — and send resolution to an unrelated remote.
|
|
92
102
|
const remotes = {};
|
|
93
103
|
for (const line of remoteOutput.trim().split('\n')) {
|
|
94
|
-
const match = line.match(/^(\S+)\s+(\S+)\s+\(fetch\)
|
|
104
|
+
const match = line.match(/^(\S+)\s+(\S+)\s+\(fetch\)(?:\s|$)/);
|
|
95
105
|
if (match) {
|
|
96
106
|
remotes[match[1]] = match[2];
|
|
97
107
|
}
|
|
@@ -122,16 +132,25 @@ class GitWorktreeManager {
|
|
|
122
132
|
? 'origin'
|
|
123
133
|
: remoteNames.find((name) => name !== MANAGED_REMOTE) || 'origin';
|
|
124
134
|
|
|
125
|
-
// Check each non-managed remote for a direct URL match
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
// Check each non-managed remote for a direct URL match, in TWO passes:
|
|
136
|
+
// the clone URL first across every remote, only then the SSH URL.
|
|
137
|
+
//
|
|
138
|
+
// A single pass would let `git remote -v` ordering decide between them,
|
|
139
|
+
// which breaks an explicitly configured `repos[...].clone_url`: that value
|
|
140
|
+
// replaces the API's `base.repo.clone_url` but NOT its `ssh_url`, so an
|
|
141
|
+
// earlier-sorting remote matching the (possibly wrong-host) API ssh_url
|
|
142
|
+
// would outrank the remote the user pointed us at. When both URLs name the
|
|
143
|
+
// same repository the two passes pick the same remote as before.
|
|
144
|
+
const nonManagedRemotes = Object.entries(remotes).filter(([name]) => name !== MANAGED_REMOTE);
|
|
145
|
+
for (const target of [normalizedCloneUrl, normalizedSshUrl]) {
|
|
146
|
+
if (!target) {
|
|
128
147
|
continue;
|
|
129
148
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
|
|
134
|
-
|
|
149
|
+
for (const [name, url] of nonManagedRemotes) {
|
|
150
|
+
if (normalizeUrl(url) === target) {
|
|
151
|
+
console.log(`Found matching remote '${name}' for base repository`);
|
|
152
|
+
return name;
|
|
153
|
+
}
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
156
|
|
package/src/github/client.js
CHANGED
|
@@ -50,8 +50,15 @@ function withAuthorizationPrefix(token) {
|
|
|
50
50
|
* `refresh: null`, so a github.com PAT client behaves exactly as before
|
|
51
51
|
* (no hook-driven retry).
|
|
52
52
|
*
|
|
53
|
+
* The optional `cloneUrl` from an object binding (the repo's explicitly
|
|
54
|
+
* configured `clone_url`) is carried through so `fetchPullRequest` can report
|
|
55
|
+
* it in place of the API's `base.repo.clone_url` — some GitHub-compatible
|
|
56
|
+
* hosts omit that field entirely. The legacy bare-token path keeps
|
|
57
|
+
* `cloneUrl: null`, so a github.com PAT client reports exactly what the API
|
|
58
|
+
* returned.
|
|
59
|
+
*
|
|
53
60
|
* @param {string|Object} arg - Token string or binding object
|
|
54
|
-
* @returns {{ token: string, apiHost: string|null, features: Object, refresh: (function(): (string|Promise<string>))|null }}
|
|
61
|
+
* @returns {{ token: string, apiHost: string|null, features: Object, cloneUrl: string|null, refresh: (function(): (string|Promise<string>))|null }}
|
|
55
62
|
*/
|
|
56
63
|
function normaliseBinding(arg) {
|
|
57
64
|
if (typeof arg === 'string') {
|
|
@@ -59,6 +66,7 @@ function normaliseBinding(arg) {
|
|
|
59
66
|
token: arg,
|
|
60
67
|
apiHost: null,
|
|
61
68
|
features: { ...DEFAULT_FEATURES },
|
|
69
|
+
cloneUrl: null,
|
|
62
70
|
refresh: null
|
|
63
71
|
};
|
|
64
72
|
}
|
|
@@ -68,20 +76,23 @@ function normaliseBinding(arg) {
|
|
|
68
76
|
const features = (arg.features && typeof arg.features === 'object')
|
|
69
77
|
? { ...DEFAULT_FEATURES, ...arg.features }
|
|
70
78
|
: { ...DEFAULT_FEATURES };
|
|
79
|
+
const cloneUrl = (typeof arg.cloneUrl === 'string' && arg.cloneUrl) ? arg.cloneUrl : null;
|
|
71
80
|
const refresh = typeof arg.refresh === 'function' ? arg.refresh : null;
|
|
72
|
-
return { token, apiHost, features, refresh };
|
|
81
|
+
return { token, apiHost, features, cloneUrl, refresh };
|
|
73
82
|
}
|
|
74
|
-
return { token: '', apiHost: null, features: { ...DEFAULT_FEATURES }, refresh: null };
|
|
83
|
+
return { token: '', apiHost: null, features: { ...DEFAULT_FEATURES }, cloneUrl: null, refresh: null };
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
/**
|
|
78
87
|
* GitHub API client wrapper with error handling and rate limiting.
|
|
79
88
|
*
|
|
80
89
|
* Constructor accepts either a bare token string (legacy) or a binding
|
|
81
|
-
* object `{ token, apiHost, features }` returned by
|
|
90
|
+
* object `{ token, apiHost, features, cloneUrl }` returned by
|
|
82
91
|
* `resolveHostBinding()`. When a binding is provided, `apiHost` is passed
|
|
83
|
-
* to Octokit as `baseUrl` (defaults to `api.github.com` when null)
|
|
84
|
-
* `features` controls per-area dispatch into the operations layer
|
|
92
|
+
* to Octokit as `baseUrl` (defaults to `api.github.com` when null),
|
|
93
|
+
* `features` controls per-area dispatch into the operations layer, and
|
|
94
|
+
* `cloneUrl` (the repo's configured `clone_url`) overrides the clone URL
|
|
95
|
+
* reported by `fetchPullRequest`.
|
|
85
96
|
*
|
|
86
97
|
* The public method signatures remain identical to the pre-refactor
|
|
87
98
|
* shape — all GraphQL operations are now thin delegations to the
|
|
@@ -98,6 +109,11 @@ class GitHubClient {
|
|
|
98
109
|
this.features = binding.features;
|
|
99
110
|
this.apiHost = binding.apiHost;
|
|
100
111
|
this.token = binding.token;
|
|
112
|
+
// Explicitly configured canonical clone URL for this repo (`repos[...]
|
|
113
|
+
// .clone_url`), or null. Wins over the API's `base.repo.clone_url` in
|
|
114
|
+
// `fetchPullRequest` — it is the user's direct statement of where the git
|
|
115
|
+
// objects live, and some alt hosts omit the API field altogether.
|
|
116
|
+
this.cloneUrl = binding.cloneUrl;
|
|
101
117
|
// Capability to obtain a fresh token (e.g. re-run a token_command).
|
|
102
118
|
// Only present for refreshable bindings; null for bare-token / literal
|
|
103
119
|
// / env sources, which therefore get NO 401 refresh-and-retry behaviour.
|
|
@@ -257,11 +273,15 @@ class GitHubClient {
|
|
|
257
273
|
mergeable: data.mergeable,
|
|
258
274
|
mergeable_state: data.mergeable_state,
|
|
259
275
|
html_url: data.html_url,
|
|
276
|
+
// `base.repo` is absent on some GitHub-compatible hosts, so every
|
|
277
|
+
// field is read defensively. A configured `clone_url` wins over the
|
|
278
|
+
// API's value: it is the user's explicit statement of where the git
|
|
279
|
+
// objects live.
|
|
260
280
|
repository: {
|
|
261
|
-
full_name: data.base
|
|
262
|
-
clone_url: data.base
|
|
263
|
-
ssh_url: data.base
|
|
264
|
-
default_branch: data.base
|
|
281
|
+
full_name: data.base?.repo?.full_name || `${owner}/${repo}`,
|
|
282
|
+
clone_url: this.cloneUrl || data.base?.repo?.clone_url,
|
|
283
|
+
ssh_url: data.base?.repo?.ssh_url,
|
|
284
|
+
default_branch: data.base?.repo?.default_branch
|
|
265
285
|
}
|
|
266
286
|
};
|
|
267
287
|
} catch (error) {
|
package/src/setup/pr-setup.js
CHANGED
|
@@ -17,7 +17,7 @@ const { WorktreePoolLifecycle } = require('../git/worktree-pool-lifecycle');
|
|
|
17
17
|
const { GitHubClient } = require('../github/client');
|
|
18
18
|
const { normalizeRepository } = require('../utils/paths');
|
|
19
19
|
const { findMainGitRoot } = require('../local-review');
|
|
20
|
-
const { getConfigDir, getRepoPath, resolveRepoOptions, resolvePoolConfig, getRepoResetScript, resolveHostBinding, resolveBindingRepositoryFromPR, getRepoConfig, DEFAULT_CHECKOUT_TIMEOUT_MS } = require('../config');
|
|
20
|
+
const { getConfigDir, getRepoPath, resolveRepoOptions, resolvePoolConfig, getRepoResetScript, resolveHostBinding, resolveBindingRepositoryFromPR, getRepoConfig, getRepoCloneUrlForHost, DEFAULT_CHECKOUT_TIMEOUT_MS } = require('../config');
|
|
21
21
|
const { storedHostToOption, isDualHostRepoConfig, resolveRecordedHost, bindingRepositoryForHost } = require('../utils/host-resolution');
|
|
22
22
|
const logger = require('../utils/logger');
|
|
23
23
|
const { fireReviewStartedHook } = require('../hooks/payloads');
|
|
@@ -373,6 +373,37 @@ async function resolvePrHostBinding({ db, config, bindingRepository, owner, repo
|
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
/**
|
|
377
|
+
* Resolve which host a RESTORED PR lives on, without contacting any API.
|
|
378
|
+
*
|
|
379
|
+
* Restore mode replays a stored snapshot, so `resolvePrHostBinding` (which
|
|
380
|
+
* fetches) never runs. This applies the same host precedence minus the probe:
|
|
381
|
+
*
|
|
382
|
+
* 1. the explicit `host` parameter when defined (URL paste / dashboard row);
|
|
383
|
+
* 2. otherwise the stored `pr_metadata` row, read through the SAME
|
|
384
|
+
* `getPRHostWithRecordedUrl` + `resolveRecordedHost` pair that
|
|
385
|
+
* `resolvePrHostBinding` uses, so a pre-stamping NULL row is interpreted
|
|
386
|
+
* identically;
|
|
387
|
+
* 3. otherwise `undefined` — host unknown, leaving the caller's ambiguity
|
|
388
|
+
* rule to decide.
|
|
389
|
+
*
|
|
390
|
+
* @param {Object} params
|
|
391
|
+
* @param {Object} params.db
|
|
392
|
+
* @param {Object} params.config
|
|
393
|
+
* @param {string} params.bindingRepository - `repos[...]` config-lookup key
|
|
394
|
+
* @param {string} params.repository - normalized "owner/repo"
|
|
395
|
+
* @param {number} params.prNumber
|
|
396
|
+
* @param {string|null|undefined} params.host - explicit host override
|
|
397
|
+
* @returns {Promise<string|null|undefined>} The host, or `undefined` if unknown
|
|
398
|
+
*/
|
|
399
|
+
async function resolveRestoreHost({ db, config, bindingRepository, repository, prNumber, host }) {
|
|
400
|
+
if (host !== undefined) return host;
|
|
401
|
+
if (!db) return undefined;
|
|
402
|
+
const recorded = await new PRMetadataRepository(db).getPRHostWithRecordedUrl(repository, prNumber);
|
|
403
|
+
if (recorded === undefined) return undefined;
|
|
404
|
+
return resolveRecordedHost(config, bindingRepository, recorded.host, recorded.recordedUrl);
|
|
405
|
+
}
|
|
406
|
+
|
|
376
407
|
/**
|
|
377
408
|
* Register the known location of a GitHub repository in the database.
|
|
378
409
|
* This allows the web UI to find the repo without cloning when reviewing PRs.
|
|
@@ -646,6 +677,28 @@ async function setupPRReview({ db, owner, repo, prNumber, githubToken, bindingRe
|
|
|
646
677
|
|
|
647
678
|
if (isRestore) {
|
|
648
679
|
prData = restoreMetadata;
|
|
680
|
+
// Restore mode replays a stored snapshot and never calls the API, so
|
|
681
|
+
// `fetchPullRequest` never gets to substitute the repo's configured
|
|
682
|
+
// `clone_url`. Snapshots taken before the option existed (or from a host
|
|
683
|
+
// that omits `base.repo.clone_url` entirely) therefore carry no clone URL
|
|
684
|
+
// at all, and restore also skips `storePRData` — so the gap never heals.
|
|
685
|
+
// Hydrate a copy here so EVERY downstream consumer sees it: the clone in
|
|
686
|
+
// `findRepositoryPath` AND the `resolveRemoteForPR` calls reached via
|
|
687
|
+
// `acquireForPR` / `createWorktreeForPR`. Never mutate `restoreMetadata`
|
|
688
|
+
// itself — the caller may reuse that object.
|
|
689
|
+
if (config && !prData?.repository?.clone_url) {
|
|
690
|
+
const configuredCloneUrl = getRepoCloneUrlForHost(
|
|
691
|
+
config,
|
|
692
|
+
bindingRepository,
|
|
693
|
+
await resolveRestoreHost({ db, config, bindingRepository, repository, prNumber, host })
|
|
694
|
+
);
|
|
695
|
+
if (configuredCloneUrl) {
|
|
696
|
+
prData = {
|
|
697
|
+
...restoreMetadata,
|
|
698
|
+
repository: { ...(restoreMetadata.repository || {}), clone_url: configuredCloneUrl }
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
}
|
|
649
702
|
progress({ step: 'verify', status: 'completed', message: 'Restoring previous review state.' });
|
|
650
703
|
progress({ step: 'fetch', status: 'completed', message: 'Using stored PR data.' });
|
|
651
704
|
} else {
|