summaryrefslogtreecommitdiff
path: root/source/features/add-co-authored-by.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <github@bfred.it> 2019-04-24 11:34:49 +0800
committerGravatar Federico Brigante <github@bfred.it> 2019-04-24 11:34:49 +0800
commit2190e1a6f68e483f43bfda3a03d82542cda6f05f (patch)
tree3c2f8aa13e11676fc1a662e261869fa778f0165c /source/features/add-co-authored-by.tsx
parentb3a1b2702482b4de868d681aa1bf511ce3e49079 (diff)
downloadrefined-github-2190e1a6f68e483f43bfda3a03d82542cda6f05f.tar.gz
refined-github-2190e1a6f68e483f43bfda3a03d82542cda6f05f.tar.zst
refined-github-2190e1a6f68e483f43bfda3a03d82542cda6f05f.zip
Add support for user-less commits in 2 features
- `show-names` - `add-co-authored-by` Context: https://github.com/sindresorhus/refined-github/pull/1924#issuecomment-485340003
Diffstat (limited to 'source/features/add-co-authored-by.tsx')
-rw-r--r--source/features/add-co-authored-by.tsx10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/features/add-co-authored-by.tsx b/source/features/add-co-authored-by.tsx
index fbc7f90e..3c011ec8 100644
--- a/source/features/add-co-authored-by.tsx
+++ b/source/features/add-co-authored-by.tsx
@@ -6,6 +6,7 @@ import {getOwnerAndRepo, getDiscussionNumber, getOP} from '../libs/utils';
interface Author {
email: string;
+ name: string; // Used when the commit isn't linked to a GitHub user
user: {
name: string;
login: string;
@@ -27,6 +28,7 @@ async function fetchCoAuthoredData(): Promise<Author[]> {
commit {
author {
email
+ name
user {
login
name
@@ -51,8 +53,12 @@ function addCoAuthors(): void {
}
const addendum = new Map();
- for (const {email, user} of coAuthors) {
- addendum.set(user.login, `Co-authored-by: ${user.name} <${email}>`);
+ for (const {email, user, name} of coAuthors) {
+ if (user) {
+ addendum.set(user.login, `Co-authored-by: ${user.name} <${email}>`);
+ } else {
+ addendum.set(name, `Co-authored-by: ${name} <${email}>`);
+ }
}
addendum.delete(getOP());