Dashboard › craft › Distillation
4998be24-9e1d-47ee-b31c-18bdf56a1875["lore_tm_v1_oHprx0v38aJP3UozDiicdMoPDfqT1vVsEYoWcoSC1YI"]
Date: Aug 24, 2026
/home/byk/Code/getsentry/craft-workspaces-schema/src/commands/prepare.ts:667-785. switchToDefaultBranch(git, defaultBranch) checks git.status().current, returns if already on defaultBranch, otherwise logs and runs git.checkout(defaultBranch).resolveVersion(git, options) gets configuration via getConfiguration() and resolves options.versionArg as follows: absent version uses getVersioningPolicy(); VersioningPolicy.Manual throws ConfigurationError requiring an explicit version or .craft.yml versioning.policy of "auto"/"calver"; otherwise policy becomes the version type.resolveVersion(), "calver" requires requiresMinVersion(AUTO_VERSION_MIN_VERSION) or throws ConfigurationError. CalVer offset precedence is options.calverOffset → CRAFT_CALVER_OFFSET parsed by Number.parseInt(..., 10) → config.versioning?.calver?.offset → DEFAULT_CALVER_CONFIG.offset; format is config.versioning?.calver?.format ?? DEFAULT_CALVER_CONFIG.format; it returns calculateCalVer(git, { offset, format }).resolveVersion(), "auto" and bump types identified by isBumpType(version) require minVersion >= AUTO_VERSION_MIN_VERSION; otherwise a ConfigurationError identifies either "Auto-versioning" or "Version bump types". It obtains latestTag with getLatestTag(git, getGitTagPrefix()); "auto" derives and validates bumpType via getChangelogWithBumpType(git, latestTag) and validateBumpType(), while explicit bump types are cast to BumpType.currentVersion = (latestTag && getVersion(latestTag)) || '0.0.0', calculates newVersion = calculateNextVersion(currentVersion, bumpType), logs Version bump: ${currentVersion} -> ${newVersion} (${bumpType} bump), and returns it. Explicit semver input is returned unchanged.prepareMain(argv) creates a Git client with getGitClient(). With argv.configFrom, it warns that remote .craft.yml preReleaseCommand will execute and the branch must be trusted; it fetches [argv.remote, argv.configFrom], reads ${argv.remote}/${argv.configFrom}:${CONFIG_FILE_NAME} via git.show(), and calls loadConfigurationFromString(configContent). Any failure becomes ConfigurationError: Failed to load ${CONFIG_FILE_NAME} from branch "${argv.configFrom}": ${error.message}.prepareMain() then gets config = getConfiguration() and githubConfig = await getGlobalGitHubConfig(), determines defaultBranch through getDefaultBranch(git, argv.remote), and sets rev = argv.rev || repoStatus.current || defaultBranch. argv.noGitChecks logs that local status is not checked; otherwise it calls checkGitStatus(repoStatus, rev).prepareMain() resolves newVersion via resolveVersion(git, { versionArg: argv.newVersion, calverOffset: argv.calverOffset }), emits GitHub Actions output with setGitHubActionsOutput('version', newVersion), logs the release version/revision, and prompts for confirmation if no argv.rev was supplied and rev !== defaultBranch.createDryRunIsolation(git, rev) and replaces git with isolation.git. It creates the release branch using createReleaseBranch(git, rev, newVersion, argv.remote, config.releaseBranchPrefix) before calling getLatestTag(git, getGitTagPrefix()); code explicitly warns this ordering must not change because retrieving the tag before a custom revision is harder.prepareMain() derives changelogPath from either string config.changelog or config.changelog?.filePath; derives changelogPolicy from object config.changelog?.policy when present, otherwise legacy config.changelogPolicy; and calls prepareChangelog(git, oldVersion, newVersion, argv.noChangelog ? ChangelogPolicy.None : changelogPolicy, changelogPath, ...).