Skip to content

Commit

Permalink
Update to use label prefixes instead of a single label
Browse files Browse the repository at this point in the history
  • Loading branch information
priethor committed Jul 27, 2023
1 parent 9e6db54 commit a7ba2aa
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,21 @@ const createOmitByLabel = ( labels ) => ( text, issue ) =>
? undefined
: text;

/**
* Higher-order function which returns a normalization function to omit by issue
* label starting with any of the given prefixes
*
* @param {string[]} prefixes Label prefixes from which to determine if given entry
* should be omitted.
*
* @return {WPChangelogNormalization} Normalization function.
*/
const createOmitByLabelPrefix = ( prefixes ) => ( text, issue ) =>
issue.labels.some( ( label ) =>
prefixes.some( ( prefix ) => label.name.startsWith( prefix ) )
)
? undefined
: text;
/**
* Given an issue title and issue, returns the title with redundant grouping
* type details removed. The prefix is redundant since it would already be clear
Expand Down Expand Up @@ -513,7 +528,7 @@ function removeFeaturePrefix( text ) {
* @type {Array<WPChangelogNormalization>}
*/
const TITLE_NORMALIZATIONS = [
createOmitByLabel( [ 'Mobile App - i.e. Android or iOS' ] ),
createOmitByLabelPrefix( [ 'Mobile App' ] ),
createOmitByTitlePrefix( [ '[rnmobile]', '[mobile]', 'Mobile Release' ] ),
removeRedundantTypePrefix,
reword,
Expand Down Expand Up @@ -1040,6 +1055,7 @@ async function getReleaseChangelog( options ) {
capitalizeAfterColonSeparatedPrefix,
createOmitByTitlePrefix,
createOmitByLabel,
createOmitByLabelPrefix,
addTrailingPeriod,
getNormalizedTitle,
getReleaseChangelog,
Expand Down

0 comments on commit a7ba2aa

Please sign in to comment.