@rmartz/pr-lifecycle 8.0.0 → 9.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/dist/bin/pr-lifecycle.js
CHANGED
|
@@ -678,6 +678,7 @@ var LIFECYCLE_LABELS = [
|
|
|
678
678
|
"review requested"
|
|
679
679
|
];
|
|
680
680
|
var AUTO_MERGE_LABEL = "auto-merge enabled";
|
|
681
|
+
var DEPENDABOT_REBASING_LABEL = "dependabot rebasing";
|
|
681
682
|
var UPDATE_REQUIRED_LABEL = "update required";
|
|
682
683
|
function lifecycleLabels(state) {
|
|
683
684
|
switch (state) {
|
|
@@ -733,8 +734,11 @@ function planReconcile(facts, policy) {
|
|
|
733
734
|
autoMerge = facts.immediatelyMergeable ? "merge" : "arm";
|
|
734
735
|
}
|
|
735
736
|
}
|
|
736
|
-
const owned = [...LIFECYCLE_LABELS];
|
|
737
|
+
const owned = [...LIFECYCLE_LABELS, DEPENDABOT_REBASING_LABEL];
|
|
737
738
|
const desired = new Set(lifecycleLabels(state));
|
|
739
|
+
if (facts.updater === "dependabot" && facts.dependabotRebasing) {
|
|
740
|
+
desired.add(DEPENDABOT_REBASING_LABEL);
|
|
741
|
+
}
|
|
738
742
|
if (arming) {
|
|
739
743
|
owned.push(AUTO_MERGE_LABEL);
|
|
740
744
|
if (shouldArm && autoMerge !== "merge") {
|
|
@@ -763,6 +767,10 @@ function withoutReleaseActions(plan) {
|
|
|
763
767
|
// src/github/dependabot-rebase.ts
|
|
764
768
|
var DEPENDABOT_REBASE_COMMAND = "@dependabot rebase";
|
|
765
769
|
var DEPENDABOT_REBASING_NOTICE = "Dependabot is rebasing this PR";
|
|
770
|
+
var DEPENDABOT_RECREATING_NOTICE = "Dependabot is recreating this PR";
|
|
771
|
+
function isDependabotRebasing(prBody) {
|
|
772
|
+
return prBody.includes(DEPENDABOT_REBASING_NOTICE) || prBody.includes(DEPENDABOT_RECREATING_NOTICE);
|
|
773
|
+
}
|
|
766
774
|
function rebaseRequestMarker(headSha) {
|
|
767
775
|
return `<!-- pr-lifecycle:dependabot-rebase head=${headSha} -->`;
|
|
768
776
|
}
|
|
@@ -772,7 +780,7 @@ function buildRebaseRequestBody(headSha) {
|
|
|
772
780
|
${rebaseRequestMarker(headSha)}`;
|
|
773
781
|
}
|
|
774
782
|
function isRebasePending(prBody, comments, headSha) {
|
|
775
|
-
if (prBody
|
|
783
|
+
if (isDependabotRebasing(prBody)) {
|
|
776
784
|
return true;
|
|
777
785
|
}
|
|
778
786
|
const marker = rebaseRequestMarker(headSha);
|
|
@@ -807,6 +815,11 @@ var OWNED_LABEL_DEFINITIONS = {
|
|
|
807
815
|
color: "B60205",
|
|
808
816
|
description: "The PR's required CI (excluding gate checks) is failing on its head."
|
|
809
817
|
},
|
|
818
|
+
"dependabot rebasing": {
|
|
819
|
+
name: DEPENDABOT_REBASING_LABEL,
|
|
820
|
+
color: "0366D6",
|
|
821
|
+
description: "Dependabot is rebasing or recreating this PR; its branch is about to change."
|
|
822
|
+
},
|
|
810
823
|
"fix required": {
|
|
811
824
|
name: "fix required",
|
|
812
825
|
color: "D93F0B",
|
|
@@ -1260,7 +1273,7 @@ async function gatherRebasePending(client, pr, pull, updater, policy) {
|
|
|
1260
1273
|
if (updater !== "dependabot") {
|
|
1261
1274
|
return false;
|
|
1262
1275
|
}
|
|
1263
|
-
if (pull.body
|
|
1276
|
+
if (isDependabotRebasing(pull.body)) {
|
|
1264
1277
|
return true;
|
|
1265
1278
|
}
|
|
1266
1279
|
const couldUpdate = policy.autoUpdate === true && pull.state === "open" && pull.labels.includes(UPDATE_REQUIRED_LABEL);
|
|
@@ -1300,6 +1313,7 @@ async function gatherFacts(client, pr, policy = {}, options = {}) {
|
|
|
1300
1313
|
cleanAncestors: lineage?.cleanAncestors ?? [],
|
|
1301
1314
|
updater,
|
|
1302
1315
|
rebasePending,
|
|
1316
|
+
dependabotRebasing: updater === "dependabot" && isDependabotRebasing(pull.body),
|
|
1303
1317
|
reviews: reviews.map((review) => toReviewFact(review, permissions)),
|
|
1304
1318
|
pendingBotReviewers: pull.requestedBotReviewers
|
|
1305
1319
|
}
|
|
@@ -1519,11 +1533,14 @@ export {
|
|
|
1519
1533
|
computeState,
|
|
1520
1534
|
LIFECYCLE_LABELS,
|
|
1521
1535
|
AUTO_MERGE_LABEL,
|
|
1536
|
+
DEPENDABOT_REBASING_LABEL,
|
|
1522
1537
|
UPDATE_REQUIRED_LABEL,
|
|
1523
1538
|
planReconcile,
|
|
1524
1539
|
withoutReleaseActions,
|
|
1525
1540
|
DEPENDABOT_REBASE_COMMAND,
|
|
1526
1541
|
DEPENDABOT_REBASING_NOTICE,
|
|
1542
|
+
DEPENDABOT_RECREATING_NOTICE,
|
|
1543
|
+
isDependabotRebasing,
|
|
1527
1544
|
rebaseRequestMarker,
|
|
1528
1545
|
buildRebaseRequestBody,
|
|
1529
1546
|
isRebasePending,
|
package/dist/index.d.ts
CHANGED
|
@@ -178,6 +178,13 @@ interface PullRequestFacts {
|
|
|
178
178
|
* error. Always `false` for other PRs.
|
|
179
179
|
*/
|
|
180
180
|
rebasePending: boolean;
|
|
181
|
+
/**
|
|
182
|
+
* For a Dependabot PR: the PR body says Dependabot is rebasing or recreating the
|
|
183
|
+
* branch right now. Unlike `rebasePending`, our own request doesn't count — only
|
|
184
|
+
* Dependabot's notice, which it removes when done. Drives the
|
|
185
|
+
* `dependabot rebasing` label. Always `false` for other PRs.
|
|
186
|
+
*/
|
|
187
|
+
dependabotRebasing: boolean;
|
|
181
188
|
reviews: readonly ReviewFact[];
|
|
182
189
|
/**
|
|
183
190
|
* Logins of the bots (e.g. Copilot) whose review is requested and not yet
|
|
@@ -451,12 +458,18 @@ declare function computeState(facts: PullRequestFacts, policy: ReconcilePolicy):
|
|
|
451
458
|
/**
|
|
452
459
|
* The reconcile plan: the minimal label and auto-merge changes that converge a PR
|
|
453
460
|
* to its computed lifecycle state. Labels are output only — the core owns the
|
|
454
|
-
* lifecycle labels (plus `auto-merge enabled` in arming
|
|
455
|
-
* any other label. See docs/reconciler-design.md §Plan.
|
|
461
|
+
* lifecycle labels and `dependabot rebasing` (plus `auto-merge enabled` in arming
|
|
462
|
+
* mode) and never touches any other label. See docs/reconciler-design.md §Plan.
|
|
456
463
|
*/
|
|
457
464
|
declare const LIFECYCLE_LABELS: readonly ["approved", "changes requested", "escalation needed", "fix required", "ci failing", "review requested"];
|
|
458
465
|
type LifecycleLabel = (typeof LIFECYCLE_LABELS)[number];
|
|
459
466
|
declare const AUTO_MERGE_LABEL = "auto-merge enabled";
|
|
467
|
+
/**
|
|
468
|
+
* Shown while Dependabot rebases or recreates its PR, so workflows can hold off
|
|
469
|
+
* until the branch settles. Owned like the lifecycle labels, but independent of
|
|
470
|
+
* the state.
|
|
471
|
+
*/
|
|
472
|
+
declare const DEPENDABOT_REBASING_LABEL = "dependabot rebasing";
|
|
460
473
|
/** merge-safety's label for a PR whose base moved in a way that matters. Read, never written. */
|
|
461
474
|
declare const UPDATE_REQUIRED_LABEL = "update required";
|
|
462
475
|
/**
|
|
@@ -676,6 +689,14 @@ declare function formatSummary(target: ReconcileTarget, result: ReconcileResult)
|
|
|
676
689
|
declare const DEPENDABOT_REBASE_COMMAND = "@dependabot rebase";
|
|
677
690
|
/** Dependabot puts this in the PR body while a rebase runs, and removes it after. */
|
|
678
691
|
declare const DEPENDABOT_REBASING_NOTICE = "Dependabot is rebasing this PR";
|
|
692
|
+
/** The same notice for `@dependabot recreate`, which force-pushes a fresh branch. */
|
|
693
|
+
declare const DEPENDABOT_RECREATING_NOTICE = "Dependabot is recreating this PR";
|
|
694
|
+
/**
|
|
695
|
+
* Whether Dependabot says, in the PR body, that it is rebasing or recreating the
|
|
696
|
+
* branch right now. Only Dependabot's own notice counts — not our request marker,
|
|
697
|
+
* which means "asked", not "running".
|
|
698
|
+
*/
|
|
699
|
+
declare function isDependabotRebasing(prBody: string): boolean;
|
|
679
700
|
/** Hidden marker recording which head a request was made for. */
|
|
680
701
|
declare function rebaseRequestMarker(headSha: string): string;
|
|
681
702
|
/** The command on its own first line, as Dependabot parses it, then the marker. */
|
|
@@ -709,7 +730,7 @@ declare function executePlan(client: GitHubClient, target: PlanTarget, plan: Rec
|
|
|
709
730
|
* a consumer repo is missing; an existing label's color and description are never
|
|
710
731
|
* changed.
|
|
711
732
|
*/
|
|
712
|
-
declare const OWNED_LABEL_DEFINITIONS: Record<LifecycleLabel | typeof AUTO_MERGE_LABEL, LabelDefinition>;
|
|
733
|
+
declare const OWNED_LABEL_DEFINITIONS: Record<LifecycleLabel | typeof AUTO_MERGE_LABEL | typeof DEPENDABOT_REBASING_LABEL, LabelDefinition>;
|
|
713
734
|
|
|
714
735
|
/**
|
|
715
736
|
* The advisory comment posted when a PR is ready to arm or merge but no release
|
|
@@ -747,4 +768,4 @@ declare function isTrustedAuthor(author: ReviewAuthor, policy: ReconcilePolicy):
|
|
|
747
768
|
/** The latest verdict that counts for the PR's current head, if any. */
|
|
748
769
|
declare function currentVerdict(facts: PullRequestFacts, policy: ReconcilePolicy): Verdict | undefined;
|
|
749
770
|
|
|
750
|
-
export { ACTOR_TYPES, AUTO_MERGE_LABEL, type ActorType, type AutoMergeAction, BRANCH_UPDATERS, type BotEligibility, type BotPrCommit, type BotPrFacts, type BotPrType, type BranchUpdater, type ChangedFile, type CliDeps, type CliIo, type CollaboratorPermission, type CommitData, DEFAULT_SETTLE_MS, DEPENDABOT_LOGIN, DEPENDABOT_REBASE_COMMAND, DEPENDABOT_REBASING_NOTICE, DEPENDABOT_UPDATE_TYPES, type DependabotUpdateType, type GatherOptions, type GatheredPullRequest, GitHubApiError, type GitHubClient, type GitResult, type GitRunner, type HttpClientOptions, LIFECYCLE_LABELS, LIFECYCLE_STATES, type LabelDefinition, type LifecycleLabel, type LifecycleState, type Lineage, type LineageInput, MAX_CHAIN_STEPS, type MergeStep, type MergeVerifier, OWNED_LABEL_DEFINITIONS, PR_STATUSES, type ParsedArgs, type ParsedVerdict, type PlanTarget, type PullRequestData, type PullRequestFacts, type PullRequestStatus, RELEASE_PLEASE_BRANCH_PREFIX, RELEASE_TOKEN_DOCS_URL, REPO_PERMISSIONS, REVIEW_STATES, type ReconcileArgs, type ReconcileJson, type ReconcileOptions, type ReconcilePlan, type ReconcilePolicy, type ReconcileResult, type ReconcileTarget, type ReleaseActions, type ReleaseDiffVerdict, type RepoPermission, type RepoSource, type ReviewAuthor, type ReviewData, type ReviewFact, type ReviewState, SCHEMA_VERSION, type SettleOptions, TOKEN_ADVISORY_MARKER, UPDATE_REQUIRED_LABEL, USAGE, type UpdateAction, VERDICTS, type Verdict, buildRebaseRequestBody, buildTokenAdvisoryBody, classifyBotPr, classifyReleaseDiff, computeState, createGitRunner, createHttpClient, createMergeVerifier, currentVerdict, executePlan, formatSummary, gatherFacts, gatherLineage, isApiStatus, isRebasePending, isTrustedAuthor, isVersionOnlyPatch, parseArgs, parseDependabotUpdateType, parseGitVersion, parseVerdict, planReconcile, postTokenAdvisory, rebaseRequestMarker, reconcilePullRequest, runCli, toReconcileJson, withoutReleaseActions };
|
|
771
|
+
export { ACTOR_TYPES, AUTO_MERGE_LABEL, type ActorType, type AutoMergeAction, BRANCH_UPDATERS, type BotEligibility, type BotPrCommit, type BotPrFacts, type BotPrType, type BranchUpdater, type ChangedFile, type CliDeps, type CliIo, type CollaboratorPermission, type CommitData, DEFAULT_SETTLE_MS, DEPENDABOT_LOGIN, DEPENDABOT_REBASE_COMMAND, DEPENDABOT_REBASING_LABEL, DEPENDABOT_REBASING_NOTICE, DEPENDABOT_RECREATING_NOTICE, DEPENDABOT_UPDATE_TYPES, type DependabotUpdateType, type GatherOptions, type GatheredPullRequest, GitHubApiError, type GitHubClient, type GitResult, type GitRunner, type HttpClientOptions, LIFECYCLE_LABELS, LIFECYCLE_STATES, type LabelDefinition, type LifecycleLabel, type LifecycleState, type Lineage, type LineageInput, MAX_CHAIN_STEPS, type MergeStep, type MergeVerifier, OWNED_LABEL_DEFINITIONS, PR_STATUSES, type ParsedArgs, type ParsedVerdict, type PlanTarget, type PullRequestData, type PullRequestFacts, type PullRequestStatus, RELEASE_PLEASE_BRANCH_PREFIX, RELEASE_TOKEN_DOCS_URL, REPO_PERMISSIONS, REVIEW_STATES, type ReconcileArgs, type ReconcileJson, type ReconcileOptions, type ReconcilePlan, type ReconcilePolicy, type ReconcileResult, type ReconcileTarget, type ReleaseActions, type ReleaseDiffVerdict, type RepoPermission, type RepoSource, type ReviewAuthor, type ReviewData, type ReviewFact, type ReviewState, SCHEMA_VERSION, type SettleOptions, TOKEN_ADVISORY_MARKER, UPDATE_REQUIRED_LABEL, USAGE, type UpdateAction, VERDICTS, type Verdict, buildRebaseRequestBody, buildTokenAdvisoryBody, classifyBotPr, classifyReleaseDiff, computeState, createGitRunner, createHttpClient, createMergeVerifier, currentVerdict, executePlan, formatSummary, gatherFacts, gatherLineage, isApiStatus, isDependabotRebasing, isRebasePending, isTrustedAuthor, isVersionOnlyPatch, parseArgs, parseDependabotUpdateType, parseGitVersion, parseVerdict, planReconcile, postTokenAdvisory, rebaseRequestMarker, reconcilePullRequest, runCli, toReconcileJson, withoutReleaseActions };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,9 @@ import {
|
|
|
5
5
|
DEFAULT_SETTLE_MS,
|
|
6
6
|
DEPENDABOT_LOGIN,
|
|
7
7
|
DEPENDABOT_REBASE_COMMAND,
|
|
8
|
+
DEPENDABOT_REBASING_LABEL,
|
|
8
9
|
DEPENDABOT_REBASING_NOTICE,
|
|
10
|
+
DEPENDABOT_RECREATING_NOTICE,
|
|
9
11
|
DEPENDABOT_UPDATE_TYPES,
|
|
10
12
|
GitHubApiError,
|
|
11
13
|
LIFECYCLE_LABELS,
|
|
@@ -36,6 +38,7 @@ import {
|
|
|
36
38
|
gatherFacts,
|
|
37
39
|
gatherLineage,
|
|
38
40
|
isApiStatus,
|
|
41
|
+
isDependabotRebasing,
|
|
39
42
|
isRebasePending,
|
|
40
43
|
isTrustedAuthor,
|
|
41
44
|
isVersionOnlyPatch,
|
|
@@ -50,7 +53,7 @@ import {
|
|
|
50
53
|
runCli,
|
|
51
54
|
toReconcileJson,
|
|
52
55
|
withoutReleaseActions
|
|
53
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-K5K64YZP.js";
|
|
54
57
|
export {
|
|
55
58
|
ACTOR_TYPES,
|
|
56
59
|
AUTO_MERGE_LABEL,
|
|
@@ -58,7 +61,9 @@ export {
|
|
|
58
61
|
DEFAULT_SETTLE_MS,
|
|
59
62
|
DEPENDABOT_LOGIN,
|
|
60
63
|
DEPENDABOT_REBASE_COMMAND,
|
|
64
|
+
DEPENDABOT_REBASING_LABEL,
|
|
61
65
|
DEPENDABOT_REBASING_NOTICE,
|
|
66
|
+
DEPENDABOT_RECREATING_NOTICE,
|
|
62
67
|
DEPENDABOT_UPDATE_TYPES,
|
|
63
68
|
GitHubApiError,
|
|
64
69
|
LIFECYCLE_LABELS,
|
|
@@ -89,6 +94,7 @@ export {
|
|
|
89
94
|
gatherFacts,
|
|
90
95
|
gatherLineage,
|
|
91
96
|
isApiStatus,
|
|
97
|
+
isDependabotRebasing,
|
|
92
98
|
isRebasePending,
|
|
93
99
|
isTrustedAuthor,
|
|
94
100
|
isVersionOnlyPatch,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmartz/pr-lifecycle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Event-driven PR lifecycle reconciler: recomputes a pull request's lifecycle labels from its current facts on every GitHub event and arms native auto-merge on approval.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|