@link-assistant/hive-mind 1.2.8 â 1.2.9
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/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/src/solve.branch.lib.mjs +9 -9
- package/src/solve.mjs +3 -0
- package/src/solve.repository.lib.mjs +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @link-assistant/hive-mind
|
|
2
2
|
|
|
3
|
+
## 1.2.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b5e047a: Fix branch checkout error showing null/null instead of actual repository URL
|
|
8
|
+
- Pass owner/repo/prNumber to branch error handlers for accurate error messages
|
|
9
|
+
- Add upstream remote fallback when PR branch not found in origin (handles bot PRs)
|
|
10
|
+
- Add case study documentation for issue #1120
|
|
11
|
+
|
|
3
12
|
## 1.2.8
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/package.json
CHANGED
package/src/solve.branch.lib.mjs
CHANGED
|
@@ -100,7 +100,7 @@ export function detectBranchFormat(branchName) {
|
|
|
100
100
|
return null;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNumber, tempDir, defaultBranch, argv, log, formatAligned, $, crypto }) {
|
|
103
|
+
export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNumber, tempDir, defaultBranch, argv, log, formatAligned, $, crypto, owner, repo, prNumber }) {
|
|
104
104
|
// Create a branch for the issue or checkout existing PR branch
|
|
105
105
|
let branchName;
|
|
106
106
|
let checkoutResult;
|
|
@@ -136,11 +136,11 @@ export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNu
|
|
|
136
136
|
const { handleBranchCheckoutError } = branchErrors;
|
|
137
137
|
await handleBranchCheckoutError({
|
|
138
138
|
branchName,
|
|
139
|
-
prNumber
|
|
139
|
+
prNumber,
|
|
140
140
|
errorOutput,
|
|
141
141
|
issueUrl: argv['issue-url'] || argv._[0],
|
|
142
|
-
owner
|
|
143
|
-
repo
|
|
142
|
+
owner,
|
|
143
|
+
repo,
|
|
144
144
|
tempDir,
|
|
145
145
|
argv,
|
|
146
146
|
formatAligned,
|
|
@@ -154,8 +154,8 @@ export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNu
|
|
|
154
154
|
branchName,
|
|
155
155
|
errorOutput,
|
|
156
156
|
tempDir,
|
|
157
|
-
owner
|
|
158
|
-
repo
|
|
157
|
+
owner,
|
|
158
|
+
repo,
|
|
159
159
|
formatAligned,
|
|
160
160
|
log,
|
|
161
161
|
});
|
|
@@ -193,9 +193,9 @@ export async function createOrCheckoutBranch({ isContinueMode, prBranch, issueNu
|
|
|
193
193
|
isContinueMode,
|
|
194
194
|
branchName,
|
|
195
195
|
actualBranch,
|
|
196
|
-
prNumber
|
|
197
|
-
owner
|
|
198
|
-
repo
|
|
196
|
+
prNumber,
|
|
197
|
+
owner,
|
|
198
|
+
repo,
|
|
199
199
|
tempDir,
|
|
200
200
|
formatAligned,
|
|
201
201
|
log,
|
package/src/solve.mjs
CHANGED
|
@@ -1208,6 +1208,41 @@ export const checkoutPrBranch = async (tempDir, branchName, prForkRemote, prFork
|
|
|
1208
1208
|
} else {
|
|
1209
1209
|
// Branch doesn't exist locally, try to checkout from remote
|
|
1210
1210
|
checkoutResult = await $({ cwd: tempDir })`git checkout -b ${branchName} ${remoteName}/${branchName}`;
|
|
1211
|
+
|
|
1212
|
+
// If checkout from origin failed, try upstream remote as fallback
|
|
1213
|
+
// This handles the case where we're in fork mode but the PR branch exists in upstream
|
|
1214
|
+
// (e.g., a bot created PR in the upstream repo, not a fork PR)
|
|
1215
|
+
if (checkoutResult.code !== 0 && remoteName === 'origin') {
|
|
1216
|
+
await log(`${formatAligned('đ', 'Branch not in origin:', 'Checking upstream remote...')}`);
|
|
1217
|
+
|
|
1218
|
+
// Check if upstream remote exists
|
|
1219
|
+
const upstreamCheckResult = await $({ cwd: tempDir })`git remote get-url upstream 2>/dev/null`;
|
|
1220
|
+
if (upstreamCheckResult.code === 0) {
|
|
1221
|
+
// Fetch from upstream to ensure we have the latest branches
|
|
1222
|
+
await log(`${formatAligned('đĨ', 'Fetching from upstream:', 'Looking for PR branch...')}`);
|
|
1223
|
+
const fetchUpstreamResult = await $({ cwd: tempDir })`git fetch upstream`;
|
|
1224
|
+
|
|
1225
|
+
if (fetchUpstreamResult.code === 0) {
|
|
1226
|
+
// Check if branch exists in upstream
|
|
1227
|
+
const upstreamBranchCheckResult = await $({ cwd: tempDir })`git show-ref --verify --quiet refs/remotes/upstream/${branchName}`;
|
|
1228
|
+
|
|
1229
|
+
if (upstreamBranchCheckResult.code === 0) {
|
|
1230
|
+
await log(`${formatAligned('â
', 'Found branch in upstream:', `upstream/${branchName}`)}`);
|
|
1231
|
+
// Try to checkout from upstream instead
|
|
1232
|
+
checkoutResult = await $({ cwd: tempDir })`git checkout -b ${branchName} upstream/${branchName}`;
|
|
1233
|
+
|
|
1234
|
+
if (checkoutResult.code === 0) {
|
|
1235
|
+
await log(`${formatAligned('âšī¸', 'Note:', 'PR branch was in upstream repository, not your fork')}`);
|
|
1236
|
+
await log(`${formatAligned('', '', 'This can happen when a bot creates a PR directly in the main repository')}`);
|
|
1237
|
+
}
|
|
1238
|
+
} else {
|
|
1239
|
+
await log(`${formatAligned('â ī¸', 'Branch not found:', `Not in origin or upstream remotes`)}`, { level: 'warning' });
|
|
1240
|
+
}
|
|
1241
|
+
} else {
|
|
1242
|
+
await log(`${formatAligned('â ī¸', 'Warning:', 'Failed to fetch from upstream')}`, { level: 'warning' });
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1211
1246
|
}
|
|
1212
1247
|
|
|
1213
1248
|
return checkoutResult;
|