forked from microsoft/BotFramework-Composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update changelog (microsoft#1750)
* add script to generate changelog entry * update change log for R7 release * remove documentation section * only output section if there are commits
- Loading branch information
1 parent
978e8a9
commit 99e87dc
Showing
2 changed files
with
207 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
const fs = require("fs"); | ||
const { execSync } = require("child_process"); | ||
|
||
const PULL_URL = "https://github.com/microsoft/BotFramework-Composer/pull"; | ||
|
||
const AUTHORS = { | ||
"Andy Brown": "a-b-r-o-w-n", | ||
"Chris Whitten": "cwhitten", | ||
"Kamran Iqbal": "Kaiqb", | ||
"Dong Lei": "boydc2014", | ||
"Long Alan": "alanlong9278", | ||
"TJ Durnford": "tdurnford", | ||
leileizhang: "lei9444", | ||
zeye: "yeze322", | ||
"Zhixiang Zhan": "zhixzhan", | ||
"Shuai Wang": "cosmicshuai", | ||
liweitian: "liweitian", | ||
"Ben Brown": "benbrown", | ||
"Pooja Nagpal": "p-nagpal", | ||
xieofxie: "xieofxie", | ||
"Lu Han": "luhan2017" | ||
}; | ||
|
||
const getLog = () => | ||
execSync("git log --pretty=format:'%s | %an' stable..master") | ||
.toString() | ||
.split("\n"); | ||
|
||
const getDate = () => | ||
execSync('date +"%m-%d-%Y"') | ||
.toString() | ||
.trim(); | ||
|
||
const SECTIONS = { | ||
Added: ["feat"], | ||
Fixed: ["fix"], | ||
Changed: ["refactor", "style"], | ||
Other: [] | ||
}; | ||
const tagToSection = Object.keys(SECTIONS).reduce((acc, section) => { | ||
const groupTags = SECTIONS[section].reduce( | ||
(s, t) => ({ | ||
...s, | ||
[t]: section | ||
}), | ||
{} | ||
); | ||
|
||
return { | ||
...acc, | ||
...groupTags | ||
}; | ||
}, {}); | ||
|
||
const getCommitSection = commit => { | ||
for (const tag in tagToSection) { | ||
if (commit.startsWith(tag)) { | ||
return tagToSection[tag]; | ||
} else if (!/^\w+:/.test(commit)) { | ||
return "Uncategorized"; | ||
} | ||
} | ||
|
||
return "Other"; | ||
}; | ||
|
||
const formatMessage = msg => | ||
msg.replace(/\(\#(\d+)\)/, `([#$1](${PULL_URL}/$1))`); | ||
|
||
const logCache = new Set(); | ||
const logOnce = (key, message) => { | ||
if (!logCache.has(key)) { | ||
process.stderr.write(message + "\n"); | ||
logCache.add(key); | ||
} | ||
}; | ||
|
||
const formatAuthor = author => { | ||
const username = AUTHORS[author]; | ||
|
||
if (!username) { | ||
logOnce(author, `${author} missing from username map`); | ||
return `${author}`; | ||
} | ||
|
||
return `([@${username}](https://github.com/${username}))`; | ||
}; | ||
|
||
const formatCommit = commit => { | ||
const [message, author] = commit.split(" | "); | ||
|
||
return [formatMessage(message), formatAuthor(author)]; | ||
}; | ||
|
||
function groupCommits(commits) { | ||
return commits.reduce((groups, commit) => { | ||
const section = getCommitSection(commit); | ||
const [message, author] = formatCommit(commit); | ||
|
||
if (!groups[section]) { | ||
groups[section] = []; | ||
} | ||
|
||
groups[section].push(`${message} ${author}`); | ||
|
||
return groups; | ||
}, {}); | ||
} | ||
|
||
const formatChangeLog = groups => { | ||
const date = getDate(); | ||
let output = `### ${date}`; | ||
|
||
for (const section in SECTIONS) { | ||
if (groups[section] && groups[section].length > 0) { | ||
output += `\n\n#### ${section}\n\n`; | ||
|
||
output += groups[section].map(c => `- ${c}`).join("\n"); | ||
} | ||
} | ||
|
||
// Uncategorized | ||
if (groups.Uncategorized) { | ||
output += "\n\n Uncategorized\n\n"; | ||
output += groups.Uncategorized.map(c => `- ${c}`).join("\n"); | ||
} | ||
|
||
return output; | ||
}; | ||
|
||
function run() { | ||
const commits = getLog(); | ||
const groups = groupCommits(commits); | ||
const output = formatChangeLog(groups); | ||
console.log(output); | ||
} | ||
|
||
run(); |