MCPcopy Index your code
hub / github.com/dmno-dev/bumpy / createVersionPr

Function createVersionPr

packages/bumpy/src/commands/ci.ts:723–834  ·  view source on GitHub ↗
(
  rootDir: string,
  plan: ReleasePlan,
  config: BumpyConfig,
  packageDirs: Map<string, string>,
  branchName?: string,
)

Source from the content-addressed store, hash-verified

721// ---- version-pr mode ----
722
723async function createVersionPr(
724 rootDir: string,
725 plan: ReleasePlan,
726 config: BumpyConfig,
727 packageDirs: Map<string, string>,
728 branchName?: string,
729): Promise<void> {
730 const branch = validateBranchName(branchName || config.versionPr.branch);
731 const baseBranch = validateBranchName(
732 tryRunArgs(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], { cwd: rootDir }) || 'main',
733 );
734
735 // Check if a version PR already exists
736 const existingPr = tryRunArgs(['gh', 'pr', 'list', '--head', branch, '--json', 'number', '--jq', '.[0].number'], {
737 cwd: rootDir,
738 });
739
740 // Create or update the branch
741 log.step(`Creating branch ${branch}...`);
742 const branchExists = tryRunArgs(['git', 'rev-parse', '--verify', branch], { cwd: rootDir }) !== null;
743
744 if (branchExists) {
745 runArgs(['git', 'checkout', branch], { cwd: rootDir });
746 runArgs(['git', 'reset', '--hard', baseBranch], { cwd: rootDir });
747 } else {
748 runArgs(['git', 'checkout', '-b', branch], { cwd: rootDir });
749 }
750
751 // Run bumpy version
752 log.step('Running bumpy version...');
753 const { versionCommand } = await import('./version.ts');
754 await versionCommand(rootDir);
755
756 // Commit and push
757 runArgs(['git', 'add', '-A'], { cwd: rootDir });
758 const status = tryRunArgs(['git', 'status', '--porcelain'], { cwd: rootDir });
759 if (!status) {
760 log.info('No version changes to commit.');
761 runArgs(['git', 'checkout', baseBranch], { cwd: rootDir });
762 return;
763 }
764
765 const commitMsg = await resolveCommitMessage(config.versionCommitMessage, plan, rootDir);
766 runArgs(['git', 'commit', '-F', '-'], { cwd: rootDir, input: commitMsg });
767
768 pushWithToken(rootDir, branch, config);
769
770 // Create or update PR
771 const repo = process.env.GITHUB_REPOSITORY;
772 const noPatWarning = !process.env.BUMPY_GH_TOKEN && !!repo;
773
774 if (existingPr) {
775 const validPr = validatePrNumber(existingPr);
776 const prBody = formatVersionPrBody(plan, config.versionPr.preamble, packageDirs, repo, validPr, noPatWarning);
777 log.step(`Updating existing PR #${validPr}...`);
778 await withPatToken(() =>
779 runArgsAsync(['gh', 'pr', 'edit', validPr, '--title', config.versionPr.title, '--body-file', '-'], {
780 cwd: rootDir,

Callers 1

ciReleaseCommandFunction · 0.85

Calls 11

tryRunArgsFunction · 0.90
runArgsFunction · 0.90
resolveCommitMessageFunction · 0.90
runArgsAsyncFunction · 0.90
validateBranchNameFunction · 0.85
versionCommandFunction · 0.85
pushWithTokenFunction · 0.85
validatePrNumberFunction · 0.85
formatVersionPrBodyFunction · 0.85
withPatTokenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…