Skip to content

Commit c829d9b

Browse files
committed
chore: ensure branch push works for lts even if first time
1 parent 39a8023 commit c829d9b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

release/core/promote/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export async function promoteToLTS(args: string[]) {
2222
const versionsToPromote = getPublicPackageVersions(packages);
2323

2424
await updateTags(config.full, versionsToPromote);
25+
2526
if (config.full.get('upstream') && !config.full.get('dry_run')) {
2627
try {
2728
await pushLTSTagToRemoteBranch(gitTag, true);

release/utils/git.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ export async function getAllPackagesForGitTag(tag: GIT_TAG): Promise<Map<string,
181181
export async function pushLTSTagToRemoteBranch(tag: GIT_TAG, force?: boolean): Promise<void> {
182182
const sha = await exec({ cmd: `git rev-list -n 1 ${tag}` });
183183
const branch = npmDistTagForChannelAndVersion('lts-prev', tag.slice(1) as SEMVER_VERSION);
184-
const oldSha = await exec({ cmd: `git rev-list -n 1 refs/heads/${branch}` });
184+
let oldSha = '<none>';
185+
try {
186+
oldSha = await exec({ cmd: `git rev-list -n 1 refs/heads/${branch}` });
187+
} catch {
188+
// no-op, branch does not exist
189+
}
185190
let cmd = `git push origin refs/tags/${tag}:refs/heads/${branch}`;
186191
if (force) cmd += ' -f';
187192
await exec({ cmd });

0 commit comments

Comments
 (0)