@henryqw/pi-pr 5.0.1 → 6.0.0
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/extensions/pr-github.ts +0 -80
- package/package.json +6 -4
package/extensions/pr-github.ts
CHANGED
|
@@ -223,11 +223,6 @@ export type BranchUpstreamTarget = {
|
|
|
223
223
|
remoteOid: string;
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
export type BranchUpstreamConfiguration = {
|
|
227
|
-
remote: string[];
|
|
228
|
-
merge: string[];
|
|
229
|
-
};
|
|
230
|
-
|
|
231
226
|
type SearchSelection =
|
|
232
227
|
| { kind: "candidate"; candidate: SearchPullRequest; pullRequest: ListedPullRequest | null }
|
|
233
228
|
| { kind: "none" }
|
|
@@ -969,29 +964,6 @@ function parseBaseRefOid(output: string, candidate: ListedPullRequest): string {
|
|
|
969
964
|
return parseBaseRefAuthority(output, candidate.base);
|
|
970
965
|
}
|
|
971
966
|
|
|
972
|
-
export async function hasLocalCommit(
|
|
973
|
-
pi: Pick<ExtensionAPI, "exec">,
|
|
974
|
-
context: PullRequestLoadContext,
|
|
975
|
-
): Promise<boolean> {
|
|
976
|
-
const branch = singleLine(
|
|
977
|
-
(await execute(pi, context, "Read current branch", "git", ["branch", "--show-current"])).stdout,
|
|
978
|
-
"Read current branch",
|
|
979
|
-
"branch",
|
|
980
|
-
);
|
|
981
|
-
const output = (await execute(pi, context, "Read branch history", "git", [
|
|
982
|
-
"reflog",
|
|
983
|
-
"show",
|
|
984
|
-
"--format=%H",
|
|
985
|
-
`refs/heads/${branch}`,
|
|
986
|
-
])).stdout.replace(/\r\n/g, "\n");
|
|
987
|
-
const entries = output.split("\n");
|
|
988
|
-
if (entries.at(-1) === "") entries.pop();
|
|
989
|
-
if (!entries.length) fail("Read branch history", "missing branch creation entry");
|
|
990
|
-
const commits = entries.map((entry) => oid(entry, "Read branch history", "commit"));
|
|
991
|
-
// ponytail: reflog expiry can hide old branch history; resolve the PR base if this becomes observable.
|
|
992
|
-
return commits[0] !== commits.at(-1);
|
|
993
|
-
}
|
|
994
|
-
|
|
995
967
|
function validatedCreationTarget(target: PullRequestTarget): PullRequestTarget {
|
|
996
968
|
if (!isRecord(target)) fail("Read creation target", "invalid target");
|
|
997
969
|
if (target.provenance !== "configured" && target.provenance !== "inferred") {
|
|
@@ -1347,22 +1319,6 @@ async function readConfigValues(
|
|
|
1347
1319
|
}
|
|
1348
1320
|
}
|
|
1349
1321
|
|
|
1350
|
-
export async function readBranchUpstreamConfiguration(
|
|
1351
|
-
pi: Pick<ExtensionAPI, "exec">,
|
|
1352
|
-
context: PullRequestLoadContext,
|
|
1353
|
-
branch: string,
|
|
1354
|
-
): Promise<BranchUpstreamConfiguration> {
|
|
1355
|
-
const checkedBranch = text(branch, "Read branch upstream", "branch");
|
|
1356
|
-
const [remote, merge] = await Promise.all([
|
|
1357
|
-
readConfigValues(pi, context, `branch.${checkedBranch}.remote`),
|
|
1358
|
-
readConfigValues(pi, context, `branch.${checkedBranch}.merge`),
|
|
1359
|
-
]);
|
|
1360
|
-
if (remote === null || merge === null) {
|
|
1361
|
-
throw new Error("Read branch upstream failed: invalid Git configuration");
|
|
1362
|
-
}
|
|
1363
|
-
return { remote, merge };
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
1322
|
async function readBooleanConfigValues(
|
|
1367
1323
|
pi: Pick<ExtensionAPI, "exec">,
|
|
1368
1324
|
context: PullRequestLoadContext,
|
|
@@ -2090,42 +2046,6 @@ function sameConfigValues(left: readonly string[], right: readonly string[]): bo
|
|
|
2090
2046
|
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
2091
2047
|
}
|
|
2092
2048
|
|
|
2093
|
-
export async function restoreBranchUpstreamConfiguration(
|
|
2094
|
-
pi: Pick<ExtensionAPI, "exec">,
|
|
2095
|
-
context: PullRequestLoadContext,
|
|
2096
|
-
target: Pick<BranchUpstreamTarget, "branch" | "remote" | "ref">,
|
|
2097
|
-
original: BranchUpstreamConfiguration,
|
|
2098
|
-
): Promise<void> {
|
|
2099
|
-
let incomplete = false;
|
|
2100
|
-
for (const [key, expected, values] of [
|
|
2101
|
-
[`branch.${target.branch}.remote`, target.remote, original.remote],
|
|
2102
|
-
[`branch.${target.branch}.merge`, `refs/heads/${target.ref}`, original.merge],
|
|
2103
|
-
] as const) {
|
|
2104
|
-
try {
|
|
2105
|
-
const current = await readConfigValues(pi, context, key);
|
|
2106
|
-
if (current === null) incomplete = true;
|
|
2107
|
-
else if (sameConfigValues(current, values)) continue;
|
|
2108
|
-
else if (current.length === 1 && current[0] === expected) {
|
|
2109
|
-
await restoreConfigValue(pi, context, key, expected, values);
|
|
2110
|
-
} else incomplete = true;
|
|
2111
|
-
} catch {
|
|
2112
|
-
incomplete = true;
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
|
-
for (const [key, values] of [
|
|
2116
|
-
[`branch.${target.branch}.remote`, original.remote],
|
|
2117
|
-
[`branch.${target.branch}.merge`, original.merge],
|
|
2118
|
-
] as const) {
|
|
2119
|
-
try {
|
|
2120
|
-
const current = await readConfigValues(pi, context, key);
|
|
2121
|
-
if (current === null || !sameConfigValues(current, values)) incomplete = true;
|
|
2122
|
-
} catch {
|
|
2123
|
-
incomplete = true;
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
if (incomplete) throw new Error("Restore branch upstream failed and rollback was incomplete");
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
2049
|
async function restoreLinkState(
|
|
2130
2050
|
pi: Pick<ExtensionAPI, "exec">,
|
|
2131
2051
|
context: PullRequestLoadContext,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-pr",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Run /pr to safely discover or link the current pull request, then create, update, address feedback, fix CI, or merge when ready.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -27,17 +27,19 @@
|
|
|
27
27
|
"pack:check": "npm pack --dry-run"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
31
|
-
"@earendil-works/pi-tui": "^0.
|
|
30
|
+
"@earendil-works/pi-coding-agent": "^0.86.0",
|
|
31
|
+
"@earendil-works/pi-tui": "^0.86.0",
|
|
32
32
|
"typebox": "^1.3.15"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@henryqw/pi-config-store": "^
|
|
35
|
+
"@henryqw/pi-config-store": "^2.0.0",
|
|
36
36
|
"@henryqw/pi-herdr": "^0.4.5",
|
|
37
37
|
"@henryqw/pi-process": "^0.1.0",
|
|
38
38
|
"proper-lockfile": "^4.1.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
+
"@earendil-works/pi-coding-agent": "0.86.0",
|
|
42
|
+
"@earendil-works/pi-tui": "0.86.0",
|
|
41
43
|
"@types/proper-lockfile": "^4.1.4"
|
|
42
44
|
},
|
|
43
45
|
"repository": {
|