Skip to content

Commit

Permalink
Adding pretified Release data in the Releases (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
danitseitlin authored Apr 9, 2022
1 parent dd29e35 commit 03838ab
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function configureGitHub(pkgName) {
*/
export async function releaseGitHubVersion(data) {
const tagName = `v${data.version}`;
let body = `${tagName} Release\n`;
let body = '';
if(data.commits && data.commits.length > 0) {
const commitsByAuthor = getCommitsByAuthor(data.commits)
body+= buildBodyCommitMessage(commitsByAuthor)
Expand All @@ -36,26 +36,24 @@ export async function releaseGitHubVersion(data) {
}
}
function getCommitsByAuthor(commits) {
const commitsByAuthor = {}
const commitsByAuthor = []
for(const commit of commits) {
const author = commit.commit.author.name;
const message = commit.commit.message;
//If any commits for the author we're already added, it would be an array and we would push into it
if(commitsByAuthor[author]) {
commitsByAuthor[author].push(message)
}
else {
commitsByAuthor[author] = [message]
let message = commit.commit.message;
if(message.indexOf('\n') != -1){
message = message.split('\n')[0]
}
commitsByAuthor.push({
author: author,
message: message
})
}
return commitsByAuthor
}
function buildBodyCommitMessage(commitsByAuthor) {
let body = "Commits:\n";
for(const author in commitsByAuthor) {
const commitList = `${commitsByAuthor[author]}`.split(',').join(`\n`)
body += `Commited by ${author}:\n`
body += `${commitList}\n`
let body = "<h2>Commits:</h2>\n";
for(const commit of commitsByAuthor) {
body += `${commit.message} by @${commit.author}\n`
}
return body
}
Expand Down

0 comments on commit 03838ab

Please sign in to comment.