Skip to content

Commit 673476f

Browse files
authored
fix(git-node): remove duplicated code in prepare_release.js (#1047)
Security releases preparation follow the same steps as regular releases, having duplicated steps is only cumbersome AFAICT.
1 parent dec276d commit 673476f

File tree

1 file changed

+28
-96
lines changed

1 file changed

+28
-96
lines changed

lib/prepare_release.js

Lines changed: 28 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -133,119 +133,51 @@ export default class ReleasePreparation extends Session {
133133
return true;
134134
}
135135

136-
async prepareSecurity() {
137-
const {
138-
cli,
139-
newVersion,
140-
versionComponents,
141-
releaseBranch,
142-
filterLabels
143-
} = this;
144-
145-
// Create new proposal branch.
146-
cli.startSpinner(`Switching to proposal branch for ${newVersion}`);
147-
const proposalBranch = await this.createProposalBranch(releaseBranch);
148-
cli.stopSpinner(`Switched to proposal branch for ${newVersion}`);
149-
150-
const success = await this.cherryPickSecurityPRs(filterLabels);
151-
if (!success) {
152-
cli.error('Aborting security release preparation. ' +
153-
'Remember to exclude the proposal branch.' +
154-
'git branch -D ' + proposalBranch);
155-
return;
156-
}
157-
// Update version and release info in src/node_version.h.
158-
cli.startSpinner(`Updating 'src/node_version.h' for ${newVersion}`);
159-
await this.updateNodeVersion();
160-
cli.stopSpinner(`Updated 'src/node_version.h' for ${newVersion}`);
161-
162-
// Update any REPLACEME tags in the docs.
163-
cli.startSpinner('Updating REPLACEME items in docs');
164-
await this.updateREPLACEMEs();
165-
cli.stopSpinner('Updated REPLACEME items in docs');
166-
167-
// Fetch date to use in release commit & changelogs.
168-
const todayDate = new Date().toISOString().split('T')[0];
169-
this.date = await cli.prompt('Enter release date in YYYY-MM-DD format:',
170-
{ questionType: 'input', defaultAnswer: todayDate });
171-
172-
cli.startSpinner('Updating CHANGELOG.md');
173-
await this.updateMainChangelog();
174-
cli.stopSpinner('Updated CHANGELOG.md');
175-
176-
cli.startSpinner(`Updating CHANGELOG_V${versionComponents.major}.md`);
177-
await this.updateMajorChangelog();
178-
cli.stopSpinner(`Updated CHANGELOG_V${versionComponents.major}.md`);
179-
180-
// Create release commit.
181-
const shouldCreateReleaseCommit = await cli.prompt(
182-
'Create release commit?');
183-
if (!shouldCreateReleaseCommit) {
184-
cli.warn(`Aborting \`git node release\` for version ${newVersion}`);
185-
return;
186-
}
187-
188-
// Proceed with release only after the releaser has amended
189-
// it to their liking.
190-
const createDefaultCommit = await this.createReleaseCommit();
191-
if (!createDefaultCommit) {
192-
const lastCommitSha = runSync('git', ['rev-parse', '--short', 'HEAD']);
193-
cli.warn(`Please manually edit commit ${lastCommitSha} by running ` +
194-
'`git commit --amend` before proceeding.');
195-
}
196-
197-
cli.separator();
198-
cli.ok(`Release preparation for ${newVersion} complete.\n`);
199-
cli.info(
200-
'To finish the release proposal, run: \n' +
201-
` $ git push -u ${this.upstream} v${newVersion}-proposal\n` +
202-
'Finally, proceed to Jenkins and begin the following CI jobs:\n' +
203-
' * https://ci.nodejs.org/job/node-test-pull-request/\n' +
204-
' * https://ci.nodejs.org/job/citgm-smoker/');
205-
cli.info(
206-
'If this release has deps/v8 changes, you\'ll also need to run:\n' +
207-
' * https://ci.nodejs.org/job/node-test-commit-v8-linux/'
208-
);
209-
}
210-
211136
async prepare() {
212137
const { cli, newVersion, versionComponents, isSecurityRelease } = this;
213138

214139
if (isSecurityRelease) {
215140
this.config.owner = 'nodejs-private';
216141
this.config.repo = 'node-private';
217-
return this.prepareSecurity();
218142
}
219143

220144
const runBranchDiff = await cli.prompt(
221145
'Do you want to check if any additional commits could be backported ' +
222146
'(recommended except for Maintenance releases)?',
223147
{ defaultAnswer: this.runBranchDiff });
224148
if (runBranchDiff) {
225-
// TODO: UPDATE re-use
226-
// Check the branch diff to determine if the releaser
227-
// wants to backport any more commits before proceeding.
228-
cli.startSpinner('Fetching branch-diff');
229-
const raw = await this.getBranchDiff({
230-
onlyNotableChanges: false,
231-
comparisonBranch: newVersion
232-
});
233-
234-
const diff = raw.split('*');
235-
cli.stopSpinner('Got branch diff');
236-
237-
const outstandingCommits = diff.length - 1;
238-
if (outstandingCommits !== 0) {
239-
const proceed = await cli.prompt(
149+
if (isSecurityRelease) {
150+
const success = await this.cherryPickSecurityPRs(this.filterLabels);
151+
if (!success) {
152+
cli.error('Aborting security release preparation.');
153+
return;
154+
}
155+
} else {
156+
// TODO: UPDATE re-use
157+
// Check the branch diff to determine if the releaser
158+
// wants to backport any more commits before proceeding.
159+
cli.startSpinner('Fetching branch-diff');
160+
const raw = await this.getBranchDiff({
161+
onlyNotableChanges: false,
162+
comparisonBranch: newVersion
163+
});
164+
165+
const diff = raw.split('*');
166+
cli.stopSpinner('Got branch diff');
167+
168+
const outstandingCommits = diff.length - 1;
169+
if (outstandingCommits !== 0) {
170+
const proceed = await cli.prompt(
240171
`There are ${outstandingCommits} commits that may be ` +
241172
`backported to ${this.stagingBranch} - do you still want to proceed?`,
242173
{ defaultAnswer: false });
243174

244-
if (!proceed) {
245-
const seeDiff = await cli.prompt(
246-
'Do you want to see the branch diff?');
247-
if (seeDiff) cli.log(raw);
248-
return;
175+
if (!proceed) {
176+
const seeDiff = await cli.prompt(
177+
'Do you want to see the branch diff?');
178+
if (seeDiff) cli.log(raw);
179+
return;
180+
}
249181
}
250182
}
251183
}

0 commit comments

Comments
 (0)