Skip to content

Commit

Permalink
chore(ci): fix automatic contributors resolving; (#5403)
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed Dec 23, 2022
1 parent 341f735 commit 8de391f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions bin/contributors.js
Expand Up @@ -19,7 +19,9 @@ const getUserInfo = ((userCache) => async (email) => {
return userCache[email];
}
try {
const {data: {items: [user]}} = await axios.get(`https://api.github.com/search/users?q=${email}`);
const tag = email.replace(/@users\.noreply\.github\.com/, '');

const {data: {items: [user]}} = await axios.get(`https://api.github.com/search/users?q=${tag}`);

return (userCache[email] = user ? {
...user,
Expand Down Expand Up @@ -52,14 +54,15 @@ const getReleaseInfo = async (version, useGithub) => {

for(const {author, email, insertions, deletions} of commits) {
const user = Object.assign({
name: author,
email
}, useGithub ? await getUserInfo(email) : null);

const entry = authors[author] = (authors[author] || {
const entry = authors[email] = (authors[email] || {
insertions: 0, deletions: 0, ...user
});

entry.displayName = entry.name || author || entry.login;

entry.github = entry.login ? `https://github.com/${encodeURIComponent(entry.login)}` : '';

entry.insertions += insertions;
Expand Down
2 changes: 1 addition & 1 deletion bin/injectContributorsList.js
Expand Up @@ -12,7 +12,7 @@ const injectContributors = async (infile, injector) => {
infile = path.resolve(__dirname, infile);

const content = String(await fs.readFile(infile));
const headerRE = /^##\s+\[([-_\d.\w]+)]\s+-.+/mig;
const headerRE = /^#+\s+\[([-_\d.\w]+)].+?$/mig;
const contributorsRE = /^\s*### Contributors/mi;

let tag;
Expand Down
4 changes: 2 additions & 2 deletions templates/contributors.hbs
Expand Up @@ -4,9 +4,9 @@

{{#each authors}}
{{#if github}}
- {{#if avatar_url}}![avatar]({{avatar_url_sm}}){{/if}} [{{name}}]({{github}}) ({{insertions}}++ / {{deletions}}--)
- {{#if avatar_url}}![avatar]({{avatar_url_sm}}){{/if}} [{{displayName}}]({{github}}) ({{insertions}}++ / {{deletions}}--)
{{else}}
- {{name}} ({{insertions}}++ / {{deletions}}--)
- {{displayName}} ({{insertions}}++ / {{deletions}}--)
{{/if}}
{{/each}}

Expand Down

0 comments on commit 8de391f

Please sign in to comment.