renovate 44.198.2 → 44.199.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.
Files changed (60) hide show
  1. package/dist/data/replacements.js +11 -0
  2. package/dist/modules/manager/fingerprint.generated.js +1 -1
  3. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  4. package/dist/modules/manager/git-submodules/update.js +8 -2
  5. package/dist/modules/manager/git-submodules/update.js.map +1 -1
  6. package/dist/modules/manager/types.d.ts +8 -1
  7. package/dist/util/http/github.d.ts +4 -0
  8. package/dist/util/http/github.js +8 -2
  9. package/dist/util/http/github.js.map +1 -1
  10. package/dist/workers/repository/config-migration/branch/commit-message.js +9 -9
  11. package/dist/workers/repository/config-migration/branch/commit-message.js.map +1 -1
  12. package/dist/workers/repository/config-migration/branch/create.js +13 -16
  13. package/dist/workers/repository/config-migration/branch/create.js.map +1 -1
  14. package/dist/workers/repository/config-migration/branch/rebase.js +15 -20
  15. package/dist/workers/repository/config-migration/branch/rebase.js.map +1 -1
  16. package/dist/workers/repository/config-migration/pr/index.js +13 -58
  17. package/dist/workers/repository/config-migration/pr/index.js.map +1 -1
  18. package/dist/workers/repository/model/commit-body.js +27 -0
  19. package/dist/workers/repository/model/commit-body.js.map +1 -0
  20. package/dist/workers/repository/model/commit-config-file.js +40 -0
  21. package/dist/workers/repository/model/commit-config-file.js.map +1 -0
  22. package/dist/workers/repository/model/commit-message-factory.js.map +1 -1
  23. package/dist/workers/repository/onboarding/branch/commit-message.js +8 -17
  24. package/dist/workers/repository/onboarding/branch/commit-message.js.map +1 -1
  25. package/dist/workers/repository/onboarding/branch/create.js +9 -27
  26. package/dist/workers/repository/onboarding/branch/create.js.map +1 -1
  27. package/dist/workers/repository/onboarding/branch/rebase.js +9 -15
  28. package/dist/workers/repository/onboarding/branch/rebase.js.map +1 -1
  29. package/dist/workers/repository/onboarding/common.js +5 -1
  30. package/dist/workers/repository/onboarding/common.js.map +1 -1
  31. package/dist/workers/repository/onboarding/pr/index.js +16 -65
  32. package/dist/workers/repository/onboarding/pr/index.js.map +1 -1
  33. package/dist/workers/repository/process/lookup/filter-checks.js +1 -1
  34. package/dist/workers/repository/update/branch/automerge.js +2 -2
  35. package/dist/workers/repository/update/branch/automerge.js.map +1 -1
  36. package/dist/workers/repository/update/branch/check-existing.js +61 -1
  37. package/dist/workers/repository/update/branch/check-existing.js.map +1 -1
  38. package/dist/workers/repository/update/branch/errors.js +90 -0
  39. package/dist/workers/repository/update/branch/errors.js.map +1 -0
  40. package/dist/workers/repository/update/branch/get-updated.js +8 -5
  41. package/dist/workers/repository/update/branch/get-updated.js.map +1 -1
  42. package/dist/workers/repository/update/branch/index.js +43 -302
  43. package/dist/workers/repository/update/branch/index.js.map +1 -1
  44. package/dist/workers/repository/update/branch/pr-blocked-by.js +25 -0
  45. package/dist/workers/repository/update/branch/pr-blocked-by.js.map +1 -0
  46. package/dist/workers/repository/update/branch/reuse.js +84 -7
  47. package/dist/workers/repository/update/branch/reuse.js.map +1 -1
  48. package/dist/workers/repository/update/branch/status-checks.js +84 -2
  49. package/dist/workers/repository/update/branch/status-checks.js.map +1 -1
  50. package/dist/workers/repository/update/pr/body/controls.js +6 -2
  51. package/dist/workers/repository/update/pr/body/controls.js.map +1 -1
  52. package/dist/workers/repository/update/pr/body/footer.js.map +1 -1
  53. package/dist/workers/repository/update/pr/body/header.js.map +1 -1
  54. package/dist/workers/repository/update/pr/body/index.js +2 -2
  55. package/dist/workers/repository/update/pr/ensure-config-pr.js +75 -0
  56. package/dist/workers/repository/update/pr/ensure-config-pr.js.map +1 -0
  57. package/dist/workers/repository/update/pr/index.js +6 -5
  58. package/dist/workers/repository/update/pr/index.js.map +1 -1
  59. package/package.json +1 -1
  60. package/renovate-schema.json +2 -2
@@ -1,61 +1,39 @@
1
- import { MANAGER_LOCKFILE_ERROR, PLATFORM_AUTHENTICATION_ERROR, PLATFORM_BAD_CREDENTIALS, REPOSITORY_CHANGED, SYSTEM_INSUFFICIENT_DISK_SPACE } from "../../../../constants/error-messages.js";
1
+ import { MANAGER_LOCKFILE_ERROR, REPOSITORY_CHANGED } from "../../../../constants/error-messages.js";
2
2
  import { GlobalConfig } from "../../../../config/global.js";
3
3
  import { coerceArray } from "../../../../util/array.js";
4
4
  import { logger, removeMeta } from "../../../../logger/index.js";
5
- import { withoutUrlCredentials } from "../../../../util/url.js";
6
5
  import { compile } from "../../../../util/template/index.js";
7
- import { filterValidCommitTrailers } from "../../../../util/git/commit-trailers.js";
8
6
  import { isScheduledNow } from "./schedule.js";
9
7
  import { ExternalHostError } from "../../../../types/errors/external-host-error.js";
10
8
  import { getCount, isLimitReached } from "../../../global/limits.js";
11
- import { getElapsedMs } from "../../../../util/date.js";
12
9
  import { emojify } from "../../../../util/emoji.js";
13
10
  import { scm } from "../../../../modules/platform/scm.js";
14
- import { enforcesMinimumReleaseAge } from "../../../../modules/manager/index.js";
15
11
  import { platform } from "../../../../modules/platform/index.js";
12
+ import { compileCommitBody, compileCommitTrailers } from "../../model/commit-body.js";
16
13
  import { ensureComment, ensureCommentRemoval } from "../../../../modules/platform/comment.js";
17
14
  import { embedChangelogs } from "../../changelog/index.js";
18
- import { getMergeConfidenceLevel, isActiveConfidenceLevel, satisfiesConfidenceLevel } from "../../../../util/merge-confidence/index.js";
19
- import { setConfidence, setStability } from "./status-checks.js";
15
+ import { computeInternalChecksStatus, setConfidence, setStability } from "./status-checks.js";
20
16
  import { ensurePr, getPlatformPrOptions } from "../pr/index.js";
21
- import { calculateMinimumReleaseAgeMs } from "../../../../util/minimum-release-age.js";
22
17
  import { updateActionsLockfile } from "../../../../modules/manager/github-actions/artifacts.js";
23
18
  import { getAdditionalFiles } from "../../../../modules/manager/npm/post-update/index.js";
24
19
  import { checkAutoMerge } from "../pr/automerge.js";
25
20
  import { setArtifactErrorStatus } from "./artifacts.js";
26
21
  import { tryBranchAutomerge } from "./automerge.js";
27
22
  import { bumpVersions } from "./bump-versions.js";
28
- import { prAlreadyExisted } from "./check-existing.js";
23
+ import { findClosedPrForModifiedBranch, prAlreadyExisted, rebaseCheck, userChangedTargetBranch } from "./check-existing.js";
29
24
  import { commitFilesToBranch } from "./commit.js";
25
+ import { handleBranchError } from "./errors.js";
30
26
  import executePostUpgradeCommands from "./execute-post-upgrade-commands.js";
31
27
  import { getUpdatedPackageFiles } from "./get-updated.js";
32
28
  import { handleClosedPr, handleModifiedPr } from "./handle-existing.js";
33
- import { shouldReuseExistingBranch } from "./reuse.js";
34
- import { isNonEmptyString } from "@sindresorhus/is";
29
+ import { prBlockedByToResult } from "./pr-blocked-by.js";
30
+ import { decideBranchReuse, hasKeepUpdatedLabel, shouldReuseExistingBranch } from "./reuse.js";
35
31
  import { DateTime } from "luxon";
36
32
  //#region lib/workers/repository/update/branch/index.ts
37
33
  async function setBranchStatusChecks(config) {
38
34
  await setStability(config);
39
35
  await setConfidence(config);
40
36
  }
41
- async function rebaseCheck(config, branchPr) {
42
- if (branchPr.title?.startsWith("rebase!")) {
43
- logger.debug(`Manual rebase requested via PR title for #${branchPr.number}`);
44
- return true;
45
- }
46
- if (!!branchPr.labels?.includes(config.rebaseLabel)) {
47
- logger.debug(`Manual rebase requested via PR labels for #${branchPr.number}`);
48
- /* v8 ignore next -- needs test */
49
- if (GlobalConfig.get("dryRun")) logger.info(`DRY-RUN: Would delete label ${config.rebaseLabel} from #${branchPr.number}`);
50
- else await platform.deleteLabel(branchPr.number, config.rebaseLabel);
51
- return true;
52
- }
53
- if (!!branchPr.bodyStruct?.rebaseRequested) {
54
- logger.debug(`Manual rebase requested via PR checkbox for #${branchPr.number}`);
55
- return true;
56
- }
57
- return false;
58
- }
59
37
  async function deleteBranchSilently(branchName) {
60
38
  try {
61
39
  await scm.deleteBranch(branchName);
@@ -67,22 +45,6 @@ async function deleteBranchSilently(branchName) {
67
45
  }, "Branch auto-remove failed");
68
46
  }
69
47
  }
70
- /**
71
- * The minimum release age which Renovate has to check for `upgrade`, which is
72
- * `0` for lock file maintenance if the package manager enforces it itself.
73
- */
74
- async function getMinimumReleaseAgeMsToCheck(upgrade) {
75
- const minimumReleaseAgeMs = calculateMinimumReleaseAgeMs(upgrade);
76
- if (!minimumReleaseAgeMs || !upgrade.isLockFileMaintenance) return minimumReleaseAgeMs;
77
- if (!await enforcesMinimumReleaseAge(upgrade.manager, upgrade)) return minimumReleaseAgeMs;
78
- logger.debug(`Lock file maintenance of ${upgrade.packageFile}: the package manager enforces the minimum release age`);
79
- return 0;
80
- }
81
- function userChangedTargetBranch(pr) {
82
- const oldTargetBranch = pr.bodyStruct?.debugData?.targetBranch;
83
- if (oldTargetBranch && pr.targetBranch) return pr.targetBranch !== oldTargetBranch;
84
- return false;
85
- }
86
48
  async function processBranch(branchConfig, forceRebase = false) {
87
49
  let commitSha = null;
88
50
  let config = { ...branchConfig };
@@ -114,7 +76,6 @@ async function processBranch(branchConfig, forceRebase = false) {
114
76
  config.rebaseRequested = await rebaseCheck(config, branchPr);
115
77
  logger.debug(`PR rebase requested=${config.rebaseRequested}`);
116
78
  }
117
- const keepUpdatedLabel = config.keepUpdatedLabel;
118
79
  const pendingRebaseTopic = emojify(":warning: Rebase not applied");
119
80
  const artifactErrorTopic = emojify(":warning: Artifact update problem");
120
81
  const artifactNoticeTopic = emojify(":information_source: Artifact update notice");
@@ -230,38 +191,10 @@ async function processBranch(branchConfig, forceRebase = false) {
230
191
  result: "pr-edited"
231
192
  };
232
193
  }
233
- } else if (branchIsModified && !dependencyDashboardCheck) {
234
- const oldPr = await platform.findPr({
235
- branchName: config.branchName,
236
- state: "!open",
237
- targetBranch: config.baseBranch
238
- });
239
- if (!oldPr) {
240
- logger.debug("Branch has been edited but found no PR - skipping");
241
- return {
242
- branchExists,
243
- result: "pr-edited"
244
- };
245
- }
246
- const branchSha = await scm.getBranchCommit(config.branchName);
247
- const oldPrSha = oldPr?.sha;
248
- if (!oldPrSha || oldPrSha === branchSha) logger.debug({
249
- oldPrNumber: oldPr.number,
250
- oldPrSha,
251
- branchSha
252
- }, "Found old PR matching this branch - will override it");
253
- else {
254
- logger.debug({
255
- oldPrNumber: oldPr.number,
256
- oldPrSha,
257
- branchSha
258
- }, "Found old PR but the SHA is different");
259
- return {
260
- branchExists,
261
- result: "pr-edited"
262
- };
263
- }
264
- }
194
+ } else if (branchIsModified && !dependencyDashboardCheck && !await findClosedPrForModifiedBranch(config)) return {
195
+ branchExists,
196
+ result: "pr-edited"
197
+ };
265
198
  }
266
199
  config.isScheduledNow = isScheduledNow(config, "schedule");
267
200
  if (!config.isScheduledNow && !dependencyDashboardCheck) {
@@ -289,65 +222,10 @@ async function processBranch(branchConfig, forceRebase = false) {
289
222
  }
290
223
  logger.debug("Branch + PR exists but is not scheduled -- will update if necessary");
291
224
  }
292
- if (config.upgrades.some((upgrade) => isNonEmptyString(upgrade.minimumReleaseAge) || isNonEmptyString(upgrade.minimumReleaseAgeExtracted) || isActiveConfidenceLevel(upgrade.minimumConfidence))) {
293
- const depNamesWithoutReleaseTimestamp = {
294
- "timestamp-required": [],
295
- "timestamp-optional": []
296
- };
297
- config.stabilityStatus = "green";
298
- for (const upgrade of config.upgrades) {
299
- const minimumReleaseAgeMs = await getMinimumReleaseAgeMsToCheck(upgrade);
300
- if (minimumReleaseAgeMs) {
301
- const minimumReleaseAgeBehaviour = upgrade.minimumReleaseAgeBehaviour ?? "timestamp-required";
302
- if (upgrade.releaseTimestamp) {
303
- const timeElapsed = getElapsedMs(upgrade.releaseTimestamp);
304
- if (timeElapsed < minimumReleaseAgeMs) {
305
- logger.debug({
306
- depName: upgrade.depName,
307
- timeElapsed,
308
- minimumReleaseAge: upgrade.minimumReleaseAge
309
- }, "Update has not passed minimum release age");
310
- config.stabilityStatus = "yellow";
311
- continue;
312
- }
313
- } else if (minimumReleaseAgeBehaviour === "timestamp-required") {
314
- depNamesWithoutReleaseTimestamp["timestamp-required"].push({
315
- depName: upgrade.depName,
316
- updateType: upgrade.updateType
317
- });
318
- config.stabilityStatus = "yellow";
319
- continue;
320
- } else depNamesWithoutReleaseTimestamp["timestamp-optional"].push({
321
- depName: upgrade.depName,
322
- updateType: upgrade.updateType
323
- });
324
- }
325
- const datasource = upgrade.datasource;
326
- const depName = upgrade.depName;
327
- const packageName = upgrade.packageName;
328
- const minimumConfidence = upgrade.minimumConfidence;
329
- const updateType = upgrade.updateType;
330
- const currentVersion = upgrade.currentVersion;
331
- const newVersion = upgrade.newVersion;
332
- if (isActiveConfidenceLevel(minimumConfidence)) {
333
- const confidence = await getMergeConfidenceLevel(datasource, packageName, currentVersion, newVersion, updateType) ?? "neutral";
334
- if (satisfiesConfidenceLevel(confidence, minimumConfidence)) config.confidenceStatus = "green";
335
- else {
336
- logger.debug({
337
- depName,
338
- confidence,
339
- minimumConfidence
340
- }, "Update does not meet minimum confidence scores");
341
- config.confidenceStatus = "yellow";
342
- continue;
343
- }
344
- }
345
- }
346
- if (depNamesWithoutReleaseTimestamp["timestamp-required"].length) logger.once.debug({ updates: depNamesWithoutReleaseTimestamp["timestamp-required"] }, `Marking ${depNamesWithoutReleaseTimestamp["timestamp-required"].length} release(s) as pending, as they do not have a releaseTimestamp and we're running with minimumReleaseAgeBehaviour=timestamp-required`);
347
- if (depNamesWithoutReleaseTimestamp["timestamp-optional"].length) {
348
- logger.once.warn("Some upgrade(s) did not have a releaseTimestamp, but as we're running with minimumReleaseAgeBehaviour=timestamp-optional, proceeding. See debug logs for more information");
349
- logger.once.debug({ updates: depNamesWithoutReleaseTimestamp["timestamp-optional"] }, `${depNamesWithoutReleaseTimestamp["timestamp-optional"].length} upgrade(s) did not have a releaseTimestamp, but as we're running with minimumReleaseAgeBehaviour=timestamp-optional, proceeding`);
350
- }
225
+ const internalChecksStatus = await computeInternalChecksStatus(config);
226
+ if (internalChecksStatus) {
227
+ config.stabilityStatus = internalChecksStatus.stabilityStatus;
228
+ config.confidenceStatus = internalChecksStatus.confidenceStatus;
351
229
  if (!dependencyDashboardCheck && !branchExists && config.stabilityStatus === "yellow" && ["not-pending", "status-success"].includes(config.prCreation)) {
352
230
  logger.debug("Skipping branch creation due to internal status checks not met");
353
231
  return {
@@ -356,37 +234,21 @@ async function processBranch(branchConfig, forceRebase = false) {
356
234
  };
357
235
  }
358
236
  }
359
- let userRebaseRequested = dependencyDashboardCheck === "rebase" || !!config.dependencyDashboardRebaseAllOpen || !!config.rebaseRequested;
360
- const userApproveAllPendingPR = !!config.dependencyDashboardAllPending;
361
- const userOpenAllRateLimtedPR = !!config.dependencyDashboardAllRateLimited;
362
- const userOpenAllSchedulePendingPR = !!config.dependencyDashboardAllAwaitingSchedule;
363
- if (forceRebase) {
364
- logger.debug("Force rebase because branch needs updating");
365
- config.reuseExistingBranch = false;
366
- } else if (userRebaseRequested) {
367
- logger.debug("User has requested rebase");
368
- config.reuseExistingBranch = false;
369
- } else if (dependencyDashboardCheck === "global-config") {
370
- logger.debug(`Manual create/rebase requested via checkedBranches`);
371
- config.reuseExistingBranch = false;
372
- userRebaseRequested = true;
373
- } else if (userApproveAllPendingPR) logger.debug("A user manually approved all pending PRs via the Dependency Dashboard.");
374
- else if (userOpenAllRateLimtedPR) logger.debug("A user manually approved all rate-limited PRs via the Dependency Dashboard.");
375
- else if (userOpenAllSchedulePendingPR) logger.debug("A user manually requested all awaiting schedule PRs via the Dependency Dashboard.");
376
- else if (branchExists && config.rebaseWhen === "never" && !(keepUpdatedLabel && branchPr?.labels?.includes(keepUpdatedLabel)) && !dependencyDashboardCheck) {
377
- logger.debug("rebaseWhen=never so skipping branch update check");
378
- return {
379
- branchExists,
380
- prNo: branchPr?.number,
381
- result: "no-work"
382
- };
383
- } else if (branchPr?.targetBranch && branchPr.targetBranch !== config.baseBranch) {
384
- logger.debug("Base branch changed by user, rebasing the branch onto new base");
385
- config.reuseExistingBranch = false;
386
- } else if (config.cacheFingerprintMatch === "no-match") {
387
- logger.debug("Cache fingerprint does not match, cannot reuse existing branch");
388
- config.reuseExistingBranch = false;
389
- } else config = await shouldReuseExistingBranch(config);
237
+ const reuseDecision = decideBranchReuse({
238
+ config,
239
+ branchPr,
240
+ branchExists,
241
+ dependencyDashboardCheck,
242
+ forceRebase
243
+ });
244
+ const { userRebaseRequested } = reuseDecision;
245
+ if (reuseDecision.action === "skip-update") return {
246
+ branchExists,
247
+ prNo: branchPr?.number,
248
+ result: "no-work"
249
+ };
250
+ if (reuseDecision.action === "no-reuse") config.reuseExistingBranch = false;
251
+ else if (reuseDecision.action === "check-reuse") config = await shouldReuseExistingBranch(config, branchPr);
390
252
  logger.debug(`Using reuseExistingBranch: ${config.reuseExistingBranch}`);
391
253
  if (!(config.reuseExistingBranch && config.cacheFingerprintMatch === "matched")) {
392
254
  await scm.checkoutBranch(config.baseBranch);
@@ -458,19 +320,12 @@ async function processBranch(branchConfig, forceRebase = false) {
458
320
  const forcedManually = userRebaseRequested || !branchExists;
459
321
  config.isConflicted ??= branchExists && await scm.isBranchConflicted(config.baseBranch, config.branchName);
460
322
  config.forceCommit = forcedManually || config.isConflicted;
461
- if (config.commitBody) {
462
- const commitBody = compile(config.commitBody, {
463
- ...config,
464
- logJSON: config.upgrades[0].logJSON,
465
- releases: config.upgrades[0].releases
466
- });
467
- config.commitMessage = `${config.commitMessage}\n\n${withoutUrlCredentials(commitBody)}`;
468
- logger.trace(`commitMessage: ${JSON.stringify(config.commitMessage)}`);
469
- }
470
- if (config.commitTrailers) {
471
- config.commitTrailers = filterValidCommitTrailers(config.commitTrailers.map((trailer) => withoutUrlCredentials(compile(trailer, config))));
472
- logger.trace(`commitTrailers: ${JSON.stringify(config.commitTrailers)}`);
473
- }
323
+ config.commitMessage = compileCommitBody(config, config.commitMessage, {
324
+ ...config,
325
+ logJSON: config.upgrades[0].logJSON,
326
+ releases: config.upgrades[0].releases
327
+ });
328
+ config.commitTrailers = compileCommitTrailers(config, config);
474
329
  commitSha = await commitFilesToBranch(config);
475
330
  await scm.checkoutBranch(config.baseBranch);
476
331
  updatesVerified = true;
@@ -515,7 +370,7 @@ async function processBranch(branchConfig, forceRebase = false) {
515
370
  };
516
371
  }
517
372
  if (!config.artifactErrors?.length && (!commitSha || config.ignoreTests)) {
518
- const mergeStatus = await tryBranchAutomerge(config);
373
+ const mergeStatus = await tryBranchAutomerge(config, branchPr);
519
374
  logger.debug(`mergeStatus=${mergeStatus}`);
520
375
  if (mergeStatus === "automerged") {
521
376
  if (GlobalConfig.get("dryRun")) logger.info(`DRY-RUN: Would delete branch${config.branchName}`);
@@ -539,7 +394,7 @@ async function processBranch(branchConfig, forceRebase = false) {
539
394
  }
540
395
  if (mergeStatus === "stale" && ["conflicted", "never"].includes(config.rebaseWhen) &&
541
396
  /* v8 ignore next -- needs test */
542
- !(keepUpdatedLabel && branchPr?.labels?.includes(keepUpdatedLabel))) {
397
+ !hasKeepUpdatedLabel(config, branchPr)) {
543
398
  logger.warn("Branch cannot automerge because it is behind base branch and rebaseWhen setting disallows rebasing - raising a PR instead");
544
399
  config.forcePr = true;
545
400
  config.branchAutomergeFailureMessage = mergeStatus;
@@ -551,91 +406,12 @@ async function processBranch(branchConfig, forceRebase = false) {
551
406
  }
552
407
  }
553
408
  } catch (err) {
554
- /* v8 ignore if -- needs test */
555
- if (err.statusCode === 404) {
556
- logger.debug({ err }, "Received a 404 error - aborting run");
557
- throw new Error(REPOSITORY_CHANGED);
558
- }
559
- /* v8 ignore if -- needs test */
560
- if (err.message === "rate-limit-exceeded") {
561
- logger.debug("Passing rate-limit-exceeded error up");
562
- throw err;
563
- }
564
- if (err.message === "repository-changed") {
565
- logger.debug("Passing repository-changed error up");
566
- throw err;
567
- }
568
- /* v8 ignore if -- needs test */
569
- if (err.message?.startsWith("remote: Invalid username or password")) {
570
- logger.debug("Throwing bad credentials");
571
- throw new Error(PLATFORM_BAD_CREDENTIALS);
572
- }
573
- /* v8 ignore if -- needs test */
574
- if (err.message?.startsWith("ssh_exchange_identification: Connection closed by remote host")) {
575
- logger.debug("Throwing bad credentials");
576
- throw new Error(PLATFORM_BAD_CREDENTIALS);
577
- }
578
- /* v8 ignore if -- needs test */
579
- if (err.message === "bad-credentials") {
580
- logger.debug("Passing bad-credentials error up");
581
- throw err;
582
- }
583
- /* v8 ignore if -- needs test */
584
- if (err.message === "integration-unauthorized") {
585
- logger.debug("Passing integration-unauthorized error up");
586
- throw err;
587
- }
588
- if (err.message === "lockfile-error") {
589
- logger.debug("Passing lockfile-error up");
590
- throw err;
591
- }
592
- if (err.message === "pr-already-in-merge-queue") {
593
- logger.debug("Branch PR is in the merge queue - skipping branch update");
594
- return {
595
- branchExists,
596
- prNo: branchPr?.number,
597
- result: "done",
598
- commitSha
599
- };
600
- }
601
- /* v8 ignore if -- needs test */
602
- if (err.message?.includes("space left on device")) throw new Error(SYSTEM_INSUFFICIENT_DISK_SPACE);
603
- /* v8 ignore if -- needs test */
604
- if (err.message === "disk-space") {
605
- logger.debug("Passing disk-space error up");
606
- throw err;
607
- }
608
- /* v8 ignore if -- needs test */
609
- if (err.message.startsWith("Resource not accessible by integration")) {
610
- logger.debug("Passing 403 error up");
611
- throw err;
612
- }
613
- /* v8 ignore next -- needs test */
614
- if (err.message === "update-failure") logger.warn("Error updating branch: update failure");
615
- else if (err.message.startsWith("bundler-")) return {
616
- branchExists: true,
617
- updatesVerified,
618
- prNo: branchPr?.number,
619
- result: "error",
620
- commitSha
621
- };
622
- else if (err.message?.includes("fatal: Authentication failed")) throw new Error(PLATFORM_AUTHENTICATION_ERROR);
623
- else if (err.message?.includes("fatal: bad revision")) {
624
- logger.debug({ err }, "Aborting job due to bad revision error");
625
- throw new Error(REPOSITORY_CHANGED);
626
- } else if (err.message === "config-validation") {
627
- logger.debug("Passing config validation error up");
628
- throw err;
629
- } else if (err.message === "temporary-error") {
630
- logger.debug("Passing TEMPORARY_ERROR error up");
631
- throw err;
632
- } else if (!(err instanceof ExternalHostError)) logger.warn({ err }, `Error updating branch`);
633
- return {
409
+ return handleBranchError(err, {
634
410
  branchExists,
635
411
  prNo: branchPr?.number,
636
- result: "error",
637
- commitSha
638
- };
412
+ commitSha,
413
+ updatesVerified
414
+ });
639
415
  }
640
416
  try {
641
417
  logger.debug("Ensuring PR");
@@ -643,45 +419,10 @@ async function processBranch(branchConfig, forceRebase = false) {
643
419
  const ensurePrResult = await ensurePr(config);
644
420
  if (ensurePrResult.type === "without-pr") {
645
421
  const { prBlockedBy } = ensurePrResult;
646
- branchPr = null;
647
- if (prBlockedBy === "RateLimited" && !config.isVulnerabilityAlert) {
648
- logger.debug("Reached PR limit - skipping PR creation");
649
- return {
650
- branchExists,
651
- prBlockedBy,
652
- result: "pr-limit-reached",
653
- commitSha
654
- };
655
- }
656
- if (prBlockedBy === "NeedsApproval") return {
657
- branchExists,
658
- prBlockedBy,
659
- result: "needs-pr-approval",
660
- commitSha
661
- };
662
- if (prBlockedBy === "AwaitingTests") return {
663
- branchExists,
664
- prBlockedBy,
665
- result: "pending",
666
- commitSha
667
- };
668
- if (prBlockedBy === "BranchAutomerge") return {
669
- branchExists,
670
- prBlockedBy,
671
- result: "done",
672
- commitSha
673
- };
674
- if (prBlockedBy === "Error") return {
675
- branchExists,
676
- prBlockedBy,
677
- result: "error",
678
- commitSha
679
- };
680
- logger.warn({ prBlockedBy }, "Unknown PrBlockedBy result");
681
422
  return {
682
423
  branchExists,
683
424
  prBlockedBy,
684
- result: "error",
425
+ result: prBlockedByToResult(prBlockedBy, config.isVulnerabilityAlert),
685
426
  commitSha
686
427
  };
687
428
  }