Skip to content

Commit

Permalink
# 33 - Make more robust Release notes comment logic (#36)
Browse files Browse the repository at this point in the history
- Improved logic to check release notes lines for presence of '-'. If not present add it with required indent.
  • Loading branch information
miroslavpojer authored Jan 25, 2024
1 parent 6acadaf commit 2f143f4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
### Bugfixes 🛠
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
- note about change in Issue 1
- note about change in Issue 1 (no bullet point at start of line)


### Closed Issues without Pull Request ⚠️
Expand Down
1 change: 1 addition & 0 deletions __tests__/data/rls_notes_fully_populated_first_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### Bugfixes 🛠
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
- note about change in Issue 1
- note about change in Issue 1 (no bullet point at start of line)


### Closed Issues without Pull Request ⚠️
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### Bugfixes 🛠
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
- note about change in Issue 1
- note about change in Issue 1 (no bullet point at start of line)


#### Full Changelog
Expand Down
1 change: 1 addition & 0 deletions __tests__/data/rls_notes_fully_populated_in_default.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### Bugfixes 🛠
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
- note about change in Issue 1
- note about change in Issue 1 (no bullet point at start of line)


### Closed Issues without Pull Request ⚠️
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- note about change in Issue 2
- #1 _Issue title 1_ implemented by @janeDoe in [#1](link-to-pr-1)
- note about change in Issue 1
- note about change in Issue 1 (no bullet point at start of line)


### Closed Issues without Release Notes ⚠️
Expand Down
7 changes: 7 additions & 0 deletions __tests__/mocks/octokit.mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@ const mockFullPerfectData = () => ({
created_at: '2023-01-02T11:00:00Z',
updated_at: '2023-01-02T11:00:00Z'
},
{
id: 103,
user: {login: 'user2'},
body: 'Release notes:\nnote about change in Issue 1 (no bullet point at start of line)',
created_at: '2023-01-02T12:00:00Z',
updated_at: '2023-01-02T12:01:00Z'
},
]
});
} else if (issue_number === 2) {
Expand Down
15 changes: 14 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29177,7 +29177,20 @@ async function getReleaseNotesFromComments(octokit, issueNumber, issueTitle, iss
if (comment.body.toLowerCase().startsWith('release notes')) {
const noteContent = comment.body.replace(/^release notes:?.*(\r\n|\n|\r)?/i, '').trim();
console.log(`Found release notes in comments for issue #${issueNumber}`);
releaseNotes.push(noteContent.replace(/^\s*[\r\n]/gm, '').replace(/^/gm, ' '));

// Process each line of the noteContent
const processedContent = noteContent.split(/\r?\n/).map(line => {
// Check if the line starts with " -"
if (!line.startsWith("-")) {
// Remove leading whitespace and prepend " - "
return " - " + line.trim();
} else {
// Remove leading whitespace
return line.replace(/^\s*[\r\n]/gm, '').replace(/^/gm, ' ');
}
}).join('\n');

releaseNotes.push(processedContent);
}
}

Expand Down
15 changes: 14 additions & 1 deletion scripts/generate-release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,20 @@ async function getReleaseNotesFromComments(octokit, issueNumber, issueTitle, iss
if (comment.body.toLowerCase().startsWith('release notes')) {
const noteContent = comment.body.replace(/^release notes:?.*(\r\n|\n|\r)?/i, '').trim();
console.log(`Found release notes in comments for issue #${issueNumber}`);
releaseNotes.push(noteContent.replace(/^\s*[\r\n]/gm, '').replace(/^/gm, ' '));

// Process each line of the noteContent
const processedContent = noteContent.split(/\r?\n/).map(line => {
// Check if the line starts with " -"
if (!line.startsWith("-")) {
// Remove leading whitespace and prepend " - "
return " - " + line.trim();
} else {
// Remove leading whitespace
return line.replace(/^\s*[\r\n]/gm, '').replace(/^/gm, ' ');
}
}).join('\n');

releaseNotes.push(processedContent);
}
}

Expand Down

0 comments on commit 2f143f4

Please sign in to comment.