Skip to content

Commit

Permalink
Move initial branchDiff to prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Mar 17, 2020
1 parent c0693d7 commit eec2250
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
23 changes: 0 additions & 23 deletions components/git/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,6 @@ async function main(state, argv, cli, dir) {
}
}

// Check the branch diff to determine if the releaser
// wants to backport any more commits before proceeding.
cli.startSpinner('Fetching branch-diff');
const raw = prep.getBranchDiff({ onlyNotableChanges: false });
const diff = raw.split('*');
cli.stopSpinner('Got branch diff');

const outstandingCommits = diff.length - 1;
if (outstandingCommits !== 0) {
const staging = `v${semver.major(prep.newVersion)}.x-staging`;
const proceed = await cli.prompt(
`There are ${outstandingCommits} commits that may be ` +
`backported to ${staging} - do you still want to proceed?`,
{ defaultAnswer: false });

if (!proceed) {
const seeDiff = await cli.prompt(
'Do you want to see the branch diff?');
if (seeDiff) cli.log(raw);
return;
}
}

return prep.prepare();
} else if (state === PROMOTE) {
// TODO(codebytere): implement release promotion.
Expand Down
27 changes: 27 additions & 0 deletions lib/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ class ReleasePreparation {
async prepare() {
const { cli, newVersion, versionComponents } = this;

// Check the branch diff to determine if the releaser
// wants to backport any more commits before proceeding.
cli.startSpinner('Fetching branch-diff');
const raw = this.getBranchDiff({
onlyNotableChanges: false,
comparisonBranch: newVersion
});

const diff = raw.split('*');
cli.stopSpinner('Got branch diff');

const outstandingCommits = diff.length - 1;
if (outstandingCommits !== 0) {
const staging = `v${semver.major(prep.newVersion)}.x-staging`;
const proceed = await cli.prompt(
`There are ${outstandingCommits} commits that may be ` +
`backported to ${staging} - do you still want to proceed?`,
{ defaultAnswer: false });

if (!proceed) {
const seeDiff = await cli.prompt(
'Do you want to see the branch diff?');
if (seeDiff) cli.log(raw);
return;
}
}

// Create new proposal branch.
cli.startSpinner(`Creating new proposal branch for ${newVersion}`);
await this.createProposalBranch();
Expand Down

0 comments on commit eec2250

Please sign in to comment.