Skip to content

Commit

Permalink
Merge pull request #20 from wemogy/main
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
SebastianKuesters authored Mar 25, 2024
2 parents 8cf1ed8 + fcc7d87 commit 276afae
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
15 changes: 12 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29089,24 +29089,33 @@ function wrappy (fn, cb) {
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
function generateLabelFilter(label) {
return (issue) => issue.labels.find((l) => {
if (typeof l === "string") {
return l.toLowerCase() === label.toLowerCase();
}
return l.name.toLowerCase() === label.toLowerCase();
}) !== undefined;
}
class ReleaseNotesGenerator {
generateReleaseNotes(issues) {
let releaseNotes = "## Release Notes\n\n";
const enhancements = issues.filter((issue) => issue.labels.includes("enhancement"));
const enhancements = issues.filter(generateLabelFilter("enhancement"));
if (enhancements.length > 0) {
releaseNotes += "### Enhancements 🎁\n\n";
enhancements.forEach((issue) => {
releaseNotes += `- ${issue.title} (#${issue.number})\n`;
});
}
const bugs = issues.filter((issue) => issue.labels.includes("bug"));
const bugs = issues.filter(generateLabelFilter("bug"));
if (bugs.length > 0) {
releaseNotes += "### Bug Fixes 🐞\n\n";
bugs.forEach((issue) => {
releaseNotes += `- ${issue.title} (#${issue.number})\n`;
});
}
const others = issues.filter((issue) => !issue.labels.includes("enhancement") && !issue.labels.includes("bug"));
const others = issues.filter((issue) => !generateLabelFilter("enhancement")(issue) &&
!generateLabelFilter("bug")(issue));
if (others.length > 0) {
releaseNotes += "### Others 📚\n\n";
others.forEach((issue) => {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

20 changes: 15 additions & 5 deletions src/ReleaseNotesGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import IssueOrPr from "./types/IssueOrPr";

function generateLabelFilter(label: string) {
return (issue: IssueOrPr) =>
issue.labels.find((l) => {
if (typeof l === "string") {
return l.toLowerCase() === label.toLowerCase();
}

return l.name.toLowerCase() === label.toLowerCase();
}) !== undefined;
}

export default class ReleaseNotesGenerator {
public generateReleaseNotes(issues: IssueOrPr[]) {
let releaseNotes = "## Release Notes\n\n";

const enhancements = issues.filter((issue) =>
issue.labels.includes("enhancement")
);
const enhancements = issues.filter(generateLabelFilter("enhancement"));

if (enhancements.length > 0) {
releaseNotes += "### Enhancements 🎁\n\n";
Expand All @@ -15,7 +24,7 @@ export default class ReleaseNotesGenerator {
});
}

const bugs = issues.filter((issue) => issue.labels.includes("bug"));
const bugs = issues.filter(generateLabelFilter("bug"));

if (bugs.length > 0) {
releaseNotes += "### Bug Fixes 🐞\n\n";
Expand All @@ -26,7 +35,8 @@ export default class ReleaseNotesGenerator {

const others = issues.filter(
(issue) =>
!issue.labels.includes("enhancement") && !issue.labels.includes("bug")
!generateLabelFilter("enhancement")(issue) &&
!generateLabelFilter("bug")(issue)
);

if (others.length > 0) {
Expand Down

0 comments on commit 276afae

Please sign in to comment.