@henryqw/pi-pr 5.0.0 → 5.0.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/README.md +1 -1
- package/extensions/pr-github.ts +0 -80
- package/extensions/pr-routing.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ If Herdr lookup, JSON validation, or rename fails, the PR and normal UI refresh
|
|
|
116
116
|
|
|
117
117
|
Current-branch discovery reads pull requests associated with the exact push repository ref. It does not run a global branch search. It finds a fork-head PR whose base is an upstream repository. A unique historical match uses the exact remote push-ref OID, not local HEAD.
|
|
118
118
|
|
|
119
|
-
A no-action state includes drafts, merged or closed pull requests,
|
|
119
|
+
A no-action state includes drafts, merged or closed pull requests, unsupported failed CI, pending review, and blocked merge policy. Running CI blocks merge but not other mutating workflows. A dirty tree or mismatched local HEAD also blocks a mutating workflow.
|
|
120
120
|
|
|
121
121
|
### Route priority
|
|
122
122
|
|
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/extensions/pr-routing.ts
CHANGED
|
@@ -93,10 +93,10 @@ export function derivePullRequestNextStep(pullRequest: PullRequest): Exclude<Nex
|
|
|
93
93
|
return localMutationSafe(local) ? "sweep" : "none";
|
|
94
94
|
}
|
|
95
95
|
if (
|
|
96
|
-
conditions.ci === "running" ||
|
|
97
96
|
conditions.review === "pending" ||
|
|
98
97
|
conditions.policy === "pending" ||
|
|
99
|
-
!localMergeSafe(local)
|
|
98
|
+
!localMergeSafe(local) ||
|
|
99
|
+
conditions.ci === "running"
|
|
100
100
|
) return "none";
|
|
101
101
|
return "merge";
|
|
102
102
|
}
|
package/package.json
CHANGED