Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only auto-assign multiple DEPOXXX when landing
  • Loading branch information
codebytere committed Jun 3, 2020
commit f8cbdc2227a99082a4ff5807dea07a4b5593415c
3 changes: 1 addition & 2 deletions lib/deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ async function getUnmarkedDeprecations() {
return unmarkedDeprecations;
}

async function updateDeprecations() {
async function updateDeprecations(unmarkedDeprecations) {
const deprecationPattern =
/<\s*a id="DEP0([0-9]{3})+"[^>]*><\s*\/\s*a>/g;

const deprecationFilePath = path.resolve('doc', 'api', 'deprecations.md');
const deprecationFile = await fs.readFile(deprecationFilePath, 'utf8');

const unmarkedDeprecations = await getUnmarkedDeprecations();
const deprecationNumbers = [
...deprecationFile.matchAll(deprecationPattern)
].map(m => m[1]).reverse();
Expand Down
9 changes: 5 additions & 4 deletions lib/landing_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ class LandingSession extends Session {
}
}

// Update any new deprecations in the codebase.
const unmarkedDepCount = await getUnmarkedDeprecations();
// Check for and maybe assign any unmarked deprecations in the codebase.
const unmarkedDeprecations = await getUnmarkedDeprecations();
const unmarkedDepCount = unmarkedDeprecations.length;
if (unmarkedDepCount > 0) {
cli.startSpinner('Assigning deprecation numbers to DEPOXXX items');
const updatedDepCount = await updateDeprecations();
await updateDeprecations(unmarkedDeprecations);

// Amend the last commit with the updated deprecation items.
await runAsync('git', ['commit', '--amend', '--no-edit']);
Comment thread
codebytere marked this conversation as resolved.
cli.stopSpinner(`Updated ${updatedDepCount} DEPOXXX items in codebase`);
cli.stopSpinner(`Updated ${unmarkedDepCount} DEPOXXX items in codebase`);
}

cli.ok('Patches applied');
Expand Down
23 changes: 13 additions & 10 deletions lib/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,23 @@ class ReleasePreparation {
await this.updateREPLACEMEs();
cli.stopSpinner('Updated REPLACEME items in docs');

// Check for any unmarked deprecations in the codebase.
const unmarkedDepCount = await getUnmarkedDeprecations();
// Check for and maybe assign any unmarked deprecations in the codebase.
const unmarkedDeprecations = await getUnmarkedDeprecations();
const unmarkedDepCount = unmarkedDeprecations.length;
if (unmarkedDepCount > 0) {
const mark = await cli.prompt(
`Automatically mark ${unmarkedDepCount} deprecations?`);
if (mark) {
if (unmarkedDepCount === 1) {
cli.startSpinner(
`Marking ${unmarkedDepCount} unmarked DEPOXXX items in codebase`);
const depCount = await updateDeprecations();
cli.stopSpinner(`Updated ${depCount} DEPOXXX items in codebase`);
'Assigning deprecation number to DEPOXXX item');
await updateDeprecations(unmarkedDeprecations);
cli.stopSpinner('Assigned deprecation numbers to DEPOXXX items');
} else {
await cli.prompt('Finished updating unmarked DEPOXXX items?',
cli.warn(
'More than one unmarked DEPOXXX item - manual resolution required.');

await cli.prompt(
`Finished updating ${unmarkedDepCount} unmarked DEPOXXX items?`,
{ defaultAnswer: false });
cli.stopSpinner('Finished updating DEPOXXX items in codebase');
cli.stopSpinner(`Finished updating ${unmarkedDepCount} DEPOXXX items`);
}
}

Expand Down