also looking at this
fix: stop releases when a required command fails
#2014
3 files
+40
-34
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -684,6 +684,8 @@ export async function versionBump(options: VersionBumpOptions): Promise<void> { | ||
| 684 | 684 | |
| 685 | 685 | // Create a backup of the file content before modification |
| 686 | 686 | const originalContent = readFileSync(filePath, 'utf-8') |
| 687 | fileBackups.set(filePath, { content: originalContent, version: fileCurrentVersion }) | |
| 688 | hasStartedUpdates = true | |
| 687 | 689 | // Always call updateVersionInFile to ensure mocks are triggered in tests |
| 688 | 690 | const fileInfo = updateVersionInFile(filePath, fileCurrentVersion, fileNewVersion, forceUpdate) |
| 689 | 691 | // If in dry run mode, restore the original content after the operation |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { afterEach, beforeEach, describe, expect, it } from 'bun:test' |
| 2 | import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs' | |
| 2 | import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' | |
| 3 | 3 | import { tmpdir } from 'node:os' |
| 4 | 4 | import { join } from 'node:path' |
| 5 | 5 | |
| @@ -124,15 +124,17 @@ describe('Git push & tag integration (local bare remote)', () => { | ||
| 124 | 124 | it('does not commit, tag or push when a required release command fails', async () => { |
| 125 | 125 | const localHead = runGit(['rev-parse', 'HEAD'], workDir).trim() |
| 126 | 126 | const remoteHead = runGit(['--git-dir', bareDir, 'rev-parse', 'refs/heads/main'], tempDir).trim() |
| 127 | const manifest = readFileSync(join(workDir, 'package.json'), 'utf8') | |
| 127 | 128 | const res = await runCLI(['patch', '--commit', '--tag', '--push', '--yes', '--no-changelog', '--execute', 'bun -e "process.exit(23)"'], workDir) |
| 128 | 129 | |
| 129 | 130 | expect({ |
| 130 | 131 | succeeded: res.code === 0, |
| 132 | manifest: readFileSync(join(workDir, 'package.json'), 'utf8'), | |
| 131 | 133 | localHead: runGit(['rev-parse', 'HEAD'], workDir).trim(), |
| 132 | 134 | remoteHead: runGit(['--git-dir', bareDir, 'rev-parse', 'refs/heads/main'], tempDir).trim(), |
| 133 | 135 | localTags: runGit(['tag', '--list'], workDir).trim(), |
| 134 | 136 | remoteTags: runGit(['--git-dir', bareDir, 'tag', '--list'], tempDir).trim(), |
| 135 | }).toEqual({ succeeded: false, localHead, remoteHead, localTags: '', remoteTags: '' }) | |
| 137 | }).toEqual({ succeeded: false, manifest, localHead, remoteHead, localTags: '', remoteTags: '' }) | |
| 136 | 138 | }) |
| 137 | 139 | |
| 138 | 140 | it('pushes commit and tag to local bare remote (single package)', async () => { |