MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / closePromotedChannelReleasePrs

Function closePromotedChannelReleasePrs

packages/bumpy/src/commands/ci.ts:877–921  ·  view source on GitHub ↗

* Close lingering channel release PRs whose cycles were promoted: once a channel's * bump files are pending on this branch (via a promotion or graduation merge), the * source channel's own release PR is obsolete — merging it would re-publish a cycle * that's already moving to its next stage. A fr

(
  rootDir: string,
  config: BumpyConfig,
  bumpFiles: BumpFile[],
  /** The channel whose release PR is being maintained right now (never close our own) */
  currentChannel?: ResolvedChannel,
)

Source from the content-addressed store, hash-verified

875 * later push in that window would kill the release PR of a newly restarted cycle.
876 */
877async function closePromotedChannelReleasePrs(
878 rootDir: string,
879 config: BumpyConfig,
880 bumpFiles: BumpFile[],
881 /** The channel whose release PR is being maintained right now (never close our own) */
882 currentChannel?: ResolvedChannel,
883): Promise<void> {
884 const arrived = detectArrivedChannelFiles(rootDir, config);
885 const promoted = [...new Set(bumpFiles.map((bf) => bf.channel))].filter(
886 (name): name is string => name != null && name !== currentChannel?.name && arrived.has(name),
887 );
888 if (promoted.length === 0) return;
889
890 const channels = resolveChannels(config);
891 for (const name of promoted) {
892 const channel = channels.get(name);
893 if (!channel) continue;
894 const pr = tryRunArgs(
895 ['gh', 'pr', 'list', '--head', channel.versionPr.branch, '--json', 'number', '--jq', '.[0].number'],
896 { cwd: rootDir },
897 );
898 if (!pr) continue;
899 const validPr = validatePrNumber(pr);
900 log.step(`Closing release PR #${validPr} — the "${name}" cycle's changes are pending here now...`);
901 try {
902 await withPatToken(() =>
903 runArgsAsync(
904 [
905 'gh',
906 'pr',
907 'close',
908 validPr,
909 '--comment',
910 `Closing — the \`${name}\` cycle's bump files were promoted and are now pending a release here. ` +
911 `A new release PR will be created automatically if more changes land on \`${channel.branch}\`.`,
912 ],
913 { cwd: rootDir },
914 ),
915 );
916 log.success(`🐸 Closed obsolete release PR #${validPr}`);
917 } catch (e) {
918 log.warn(` Failed to close release PR #${validPr}: ${e}`);
919 }
920 }
921}
922
923// ---- channel (prerelease) release flow ----
924

Callers 2

createVersionPrFunction · 0.85
createChannelReleasePrFunction · 0.85

Calls 6

resolveChannelsFunction · 0.90
tryRunArgsFunction · 0.90
runArgsAsyncFunction · 0.90
validatePrNumberFunction · 0.85
withPatTokenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…