Skip to content

Commit

Permalink
release: update changelog github user map
Browse files Browse the repository at this point in the history
  • Loading branch information
a-b-r-o-w-n committed Dec 14, 2020
1 parent dcdcd13 commit 442782e
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions scripts/generate-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,74 @@ const AUTHORS = {
"Carlos Castro": "srinaath",
"Chris Whitten": "cwhitten",
"Dong Lei": "boydc2014",
"Fei Chen": "feich-ms",
"Gary Pretty": "garypretty",
"Geoff Cox (Microsoft)": "GeoffCoxMSFT",
"Hongyang Du (hond)": "Danieladu",
"Kamran Iqbal": "Kaiqb",
"Long Alan": "alanlong9278",
LouisEugeneMSFT: "leugene-microsoft",
"Lu Han": "luhan2017",
"mareekuh": "mareekuh",
mareekuh: "mareekuh",
pavolum: "pavolum",
"Pooja Nagpal": "p-nagpal",
"Qi Kang": "zidaneymar",
"sangwoohaan": "srinaath",
sangwoohaan: "srinaath",
"Shuai Wang": "cosmicshuai",
Soroush: "hatpick",
"Srinaath Ravichandran": "srinaath",
taicchoumsft: "taicchoumsft",
"TJ Durnford": "tdurnford",
"Tony Anziano": "tonyanziano",
"Vishwac Sena Kannan": "vishwacsena",
"Weitian Li": "liweitian",
"Yan Liu": "zxyanliu",
"Zhixiang Zhan": "zhixzhan",
zxyanliu: "zxyanliu",
Corina: "corinagum",
leileizhang: "lei9444",
liweitian: "liweitian",
mewa1024: "mewa1024",
VanyLaw: "VanyLaw",
xieofxie: "xieofxie",
zeye: "yeze322",
zhixzhan: "zhixzhan",
"LouisEugeneMSFT": "leugene-microsoft"
};

const getLatestTag = () =>
execSync("git describe --tags $(git rev-list --tags --max-count=1)").toString().trim();
execSync("git describe --tags $(git rev-list --tags --max-count=1)")
.toString()
.trim();

const getLog = (tag) =>
execSync(`git log --pretty=format:'%s | %an' ${tag}..main`)
.toString()
.split("\n");

const getDate = () =>
execSync('date +"%m-%d-%Y"')
.toString()
.trim();
const getDate = () => execSync('date +"%m-%d-%Y"').toString().trim();

const SECTIONS = {
Added: ["feat"],
Fixed: ["fix", "a11y"],
Changed: ["refactor", "style"],
Other: []
Other: [],
};
const tagToSection = Object.keys(SECTIONS).reduce((acc, section) => {
const groupTags = SECTIONS[section].reduce(
(s, t) => ({
...s,
[t]: section
[t]: section,
}),
{}
);

return {
...acc,
...groupTags
...groupTags,
};
}, {});

const getCommitSection = commit => {
const getCommitSection = (commit) => {
for (const tag in tagToSection) {
if (commit.startsWith(tag)) {
return tagToSection[tag];
Expand All @@ -84,7 +89,7 @@ const getCommitSection = commit => {
return "Other";
};

const formatMessage = msg =>
const formatMessage = (msg) =>
msg.replace(/\(\#(\d+)\)/, `([#$1](${PULL_URL}/$1))`);

const logCache = new Set();
Expand All @@ -95,7 +100,7 @@ const logOnce = (key, message) => {
}
};

const formatAuthor = author => {
const formatAuthor = (author) => {
const username = AUTHORS[author];

if (!username) {
Expand All @@ -106,7 +111,7 @@ const formatAuthor = author => {
return `([@${username}](https://github.com/${username}))`;
};

const formatCommit = commit => {
const formatCommit = (commit) => {
const [message, author] = commit.split(" | ");

return [formatMessage(message), formatAuthor(author)];
Expand All @@ -127,22 +132,22 @@ function groupCommits(commits) {
}, {});
}

const formatChangeLog = 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");
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");
output += groups.Uncategorized.map((c) => `- ${c}`).join("\n");
}

return output;
Expand Down

0 comments on commit 442782e

Please sign in to comment.