renovate 44.29.4 → 44.30.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.
@@ -1,5 +1,5 @@
1
1
  import { __exportAll } from "../../../_virtual/_rolldown/runtime.js";
2
- import { PLATFORM_RATE_LIMIT_EXCEEDED, PLATFORM_UNKNOWN_ERROR, REPOSITORY_ACCESS_FORBIDDEN, REPOSITORY_ARCHIVED, REPOSITORY_BLOCKED, REPOSITORY_CANNOT_FORK, REPOSITORY_CHANGED, REPOSITORY_EMPTY, REPOSITORY_FORKED, REPOSITORY_FORK_MISSING, REPOSITORY_NOT_FOUND, REPOSITORY_RENAMED } from "../../../constants/error-messages.js";
2
+ import { PLATFORM_RATE_LIMIT_EXCEEDED, PLATFORM_UNKNOWN_ERROR, PR_ALREADY_IN_MERGE_QUEUE, REPOSITORY_ACCESS_FORBIDDEN, REPOSITORY_ARCHIVED, REPOSITORY_BLOCKED, REPOSITORY_CANNOT_FORK, REPOSITORY_CHANGED, REPOSITORY_EMPTY, REPOSITORY_FORKED, REPOSITORY_FORK_MISSING, REPOSITORY_NOT_FOUND, REPOSITORY_RENAMED } from "../../../constants/error-messages.js";
3
3
  import { getEnv } from "../../../util/env.js";
4
4
  import { regEx } from "../../../util/regex.js";
5
5
  import { GlobalConfig } from "../../../config/global.js";
@@ -27,10 +27,10 @@ import { repoFingerprint } from "../util.js";
27
27
  import { smartTruncate } from "../utils/pr-body.js";
28
28
  import { coerceRestPr, githubApi, mapMergeStartegy } from "./common.js";
29
29
  import { remoteBranchExists } from "./branch.js";
30
- import { enableAutoMergeMutation, getIssuesQuery, repoInfoQuery } from "./graphql.js";
30
+ import { enableAutoMergeMutation, getIssuesQuery, repoInfoQuery, repoMergeQueueQuery } from "./graphql.js";
31
31
  import { GithubIssueCache } from "./issue.js";
32
32
  import { massageMarkdownLinks } from "./massage-markdown-links.js";
33
- import { getPrCache, updatePrCache } from "./pr.js";
33
+ import { getPrCache, isPrInMergeQueue, updatePrCache } from "./pr.js";
34
34
  import { getAppDetails, getUserDetails, getUserEmail } from "./user.js";
35
35
  import { getRepoUrl, warnIfDefaultGitAuthorEmail } from "./utils.js";
36
36
  import { isArray, isNonEmptyObject, isNonEmptyString } from "@sindresorhus/is";
@@ -41,6 +41,7 @@ var github_exports = /* @__PURE__ */ __exportAll({
41
41
  addAssignees: () => addAssignees,
42
42
  addLabels: () => addLabels,
43
43
  addReviewers: () => addReviewers,
44
+ assertPrNotInMergeQueue: () => assertPrNotInMergeQueue,
44
45
  commitFiles: () => commitFiles,
45
46
  createFork: () => createFork,
46
47
  createPr: () => createPr,
@@ -316,7 +317,8 @@ async function initRepo({ repository, forkCreation, forkOrg, forkToken, gitUrl,
316
317
  repository,
317
318
  cloneSubmodules,
318
319
  cloneSubmodulesFilter,
319
- ignorePrAuthor: GlobalConfig.get("ignorePrAuthor")
320
+ ignorePrAuthor: GlobalConfig.get("ignorePrAuthor"),
321
+ mergeQueueEnabled: {}
320
322
  };
321
323
  const opts = find({
322
324
  hostType: "github",
@@ -334,6 +336,7 @@ async function initRepo({ repository, forkCreation, forkOrg, forkToken, gitUrl,
334
336
  infoQuery = infoQuery.replace(/\n\s*hasIssuesEnabled\s*\n/, "\n");
335
337
  }
336
338
  if (platformConfig.isGhe && semver.satisfies(platformConfig.gheVersion, "<3.9.0")) infoQuery = infoQuery.replace(/\n\s*hasVulnerabilityAlertsEnabled\s*\n/, "\n");
339
+ if (platformConfig.isGhe && semver.satisfies(platformConfig.gheVersion, "<3.12.0")) infoQuery = infoQuery.replace(/\n\s*mergeQueue\s*\{\s*id\s*\}\s*\n/, "\n");
337
340
  const res = await githubApi.requestGraphql(infoQuery, {
338
341
  variables: {
339
342
  owner: config.repositoryOwner,
@@ -382,6 +385,7 @@ async function initRepo({ repository, forkCreation, forkOrg, forkToken, gitUrl,
382
385
  config.autoMergeAllowed = repo.autoMergeAllowed;
383
386
  config.hasIssuesEnabled = repo.hasIssuesEnabled;
384
387
  config.hasVulnerabilityAlertsEnabled = repo.hasVulnerabilityAlertsEnabled;
388
+ config.mergeQueueEnabled[config.defaultBranch] = isNonEmptyObject(repo.mergeQueue);
385
389
  const recentIssues = GithubIssue.array().catch([]).parse(res?.data?.repository?.issues?.nodes);
386
390
  GithubIssueCache.addIssuesToReconcile(recentIssues);
387
391
  } catch (err) /* v8 ignore next -- initRepo error mapping needs failure shapes not mocked in specs */ {
@@ -1232,6 +1236,50 @@ async function createPr({ sourceBranch, targetBranch, prTitle: title, prBody: ra
1232
1236
  cachePr(result);
1233
1237
  return result;
1234
1238
  }
1239
+ async function isMergeQueueEnabled(baseBranch) {
1240
+ const cachedResult = config.mergeQueueEnabled[baseBranch];
1241
+ if (cachedResult !== void 0) return cachedResult;
1242
+ if (platformConfig.isGhe && semver.satisfies(platformConfig.gheVersion, "<3.12.0")) {
1243
+ config.mergeQueueEnabled[baseBranch] = false;
1244
+ return false;
1245
+ }
1246
+ let result = true;
1247
+ try {
1248
+ const res = await githubApi.requestGraphql(repoMergeQueueQuery, {
1249
+ variables: {
1250
+ owner: config.repositoryOwner,
1251
+ name: config.repositoryName,
1252
+ branch: baseBranch
1253
+ },
1254
+ readOnly: true,
1255
+ count: 1
1256
+ });
1257
+ if (res?.errors) logger.debug({
1258
+ baseBranch,
1259
+ errors: res.errors
1260
+ }, "Failed to fetch merge queue status - assuming merge queue is enabled");
1261
+ else result = isNonEmptyObject(res?.data?.repository?.mergeQueue);
1262
+ } catch (err) {
1263
+ logger.debug({
1264
+ baseBranch,
1265
+ err
1266
+ }, "Error fetching merge queue status - assuming merge queue is enabled");
1267
+ }
1268
+ config.mergeQueueEnabled[baseBranch] = result;
1269
+ return result;
1270
+ }
1271
+ async function assertPrNotInMergeQueue(branchName, baseBranch) {
1272
+ if (!await isMergeQueueEnabled(baseBranch ?? config.defaultBranch)) return;
1273
+ const pr = await findPr({
1274
+ branchName,
1275
+ state: "open"
1276
+ });
1277
+ if (!pr) return;
1278
+ if (await isPrInMergeQueue(githubApi, config.repositoryOwner, config.repositoryName, pr.number)) {
1279
+ logger.debug(`PR #${pr.number} is in the merge queue - aborting push`);
1280
+ throw new Error(PR_ALREADY_IN_MERGE_QUEUE);
1281
+ }
1282
+ }
1235
1283
  async function updatePr({ number: prNo, prTitle: title, prBody: rawBody, addLabels: labelsToAdd, removeLabels, state, targetBranch }) {
1236
1284
  logger.debug(`updatePr(${prNo}, ${title}, body)`);
1237
1285
  const body = sanitize(rawBody);
@@ -1443,6 +1491,6 @@ async function commitFiles(config) {
1443
1491
  return await fetchBranch(branchName);
1444
1492
  }
1445
1493
  //#endregion
1446
- export { addAssignees, addLabels, addReviewers, commitFiles, createFork, createPr, deleteLabel, detectGhe, ensureComment, ensureCommentRemoval, ensureIssue, ensureIssueClosing, findFork, findIssue, findPr, getBranchForceRebase, getBranchPr, getBranchStatus, getBranchStatusCheck, getIssue, getIssueList, getJsonFile, getPr, getPrList, getRawFile, getRepos, getVulnerabilityAlerts, github_exports, id, initPlatform, initRepo, isGHApp, listForks, massageMarkdown, maxBodyLength, mergePr, reattemptPlatformAutomerge, resetConfigs, setBranchStatus, tryReuseAutoclosedPr, updatePr };
1494
+ export { addAssignees, addLabels, addReviewers, assertPrNotInMergeQueue, commitFiles, createFork, createPr, deleteLabel, detectGhe, ensureComment, ensureCommentRemoval, ensureIssue, ensureIssueClosing, findFork, findIssue, findPr, getBranchForceRebase, getBranchPr, getBranchStatus, getBranchStatusCheck, getIssue, getIssueList, getJsonFile, getPr, getPrList, getRawFile, getRepos, getVulnerabilityAlerts, github_exports, id, initPlatform, initRepo, isGHApp, listForks, massageMarkdown, maxBodyLength, mergePr, reattemptPlatformAutomerge, resetConfigs, setBranchStatus, tryReuseAutoclosedPr, updatePr };
1447
1495
 
1448
1496
  //# sourceMappingURL=index.js.map