(root, { live, command = run })
| 143 | } |
| 144 | |
| 145 | export function assertRepositoryReady(root, { live, command = run }) { |
| 146 | const status = command('git', ['status', '--porcelain', '--untracked-files=normal'], { cwd: root, encoding: 'utf8' }).stdout.trim(); |
| 147 | assert.equal(status, '', 'The release checkout must be clean. Commit or discard every change first.'); |
| 148 | if (!live) return; |
| 149 | |
| 150 | const branch = command('git', ['branch', '--show-current'], { cwd: root, encoding: 'utf8' }).stdout.trim(); |
| 151 | assert.equal(branch, 'master', `Live beta publication must run from master, not ${branch || 'a detached checkout'}.`); |
| 152 | const upstream = command('git', ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}'], { |
| 153 | cwd: root, |
| 154 | encoding: 'utf8', |
| 155 | }).stdout.trim(); |
| 156 | assert.match(upstream, /(?:^|\/)master$/, `master must track a remote master branch; found ${upstream}.`); |
| 157 | const divergence = command('git', ['rev-list', '--left-right', '--count', 'HEAD...@{upstream}'], { |
| 158 | cwd: root, |
| 159 | encoding: 'utf8', |
| 160 | }).stdout.trim(); |
| 161 | assert.match(divergence, /^0\s+0$/, `master must exactly match ${upstream}; divergence was ${divergence}. Fetch and update first.`); |
| 162 | } |
| 163 | |
| 164 | export function assertInteractivePublishingEnvironment({ dryRun, env, stdin, stdout }) { |
| 165 | if (dryRun) return; |
no test coverage detected