(workTree: string)
| 131 | } |
| 132 | |
| 133 | function snapshotFixture(workTree: string): FixtureSnapshot { |
| 134 | const versionFile = fs.readFileSync(path.join(workTree, 'VERSION'), 'utf-8').trim(); |
| 135 | const pkg = JSON.parse(fs.readFileSync(path.join(workTree, 'package.json'), 'utf-8')); |
| 136 | const changelog = fs.readFileSync(path.join(workTree, 'CHANGELOG.md'), 'utf-8'); |
| 137 | // Count `## [0.0.2]` headings — should stay at 1 across re-runs. |
| 138 | const changelogEntryCount = (changelog.match(/^##\s*\[0\.0\.2\]/gm) ?? []).length; |
| 139 | const head = spawnSync('git', ['rev-parse', 'HEAD'], { cwd: workTree, stdio: 'pipe' }); |
| 140 | const branchHead = head.stdout?.toString().trim() ?? ''; |
| 141 | // Count "chore: bump version" commits on this branch since main. |
| 142 | const log = spawnSync( |
| 143 | 'git', ['log', '--format=%s', 'main..HEAD'], |
| 144 | { cwd: workTree, stdio: 'pipe' }, |
| 145 | ); |
| 146 | const subjects = log.stdout?.toString() ?? ''; |
| 147 | const bumpCommitCount = subjects.split('\n').filter(s => /chore:\s*bump\s+version/i.test(s)).length; |
| 148 | return { versionFile, packageVersion: pkg.version, changelogEntryCount, bumpCommitCount, branchHead }; |
| 149 | } |
| 150 | |
| 151 | describeE2E('/ship idempotency E2E (periodic, real-PTY)', () => { |
| 152 | test( |
no test coverage detected