summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/features/add-co-authored-by.tsx10
-rw-r--r--source/features/show-names.tsx3
-rw-r--r--source/libs/api.ts2
3 files changed, 11 insertions, 4 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());
diff --git a/source/features/show-names.tsx b/source/features/show-names.tsx
index 6255ffb5..1067e255 100644
--- a/source/features/show-names.tsx
+++ b/source/features/show-names.tsx
@@ -5,7 +5,8 @@ import features from '../libs/features';
import {getUsername} from '../libs/utils';
async function init(): Promise<false | void> {
- const usernameElements = select.all('.js-discussion .author:not(.rgh-fullname):not([href*="/apps/"])');
+ // `a` selector needed to skip commits by non-GitHub users
+ const usernameElements = select.all('.js-discussion a.author:not(.rgh-fullname):not([href*="/apps/"])');
const usernames = new Set();
const myUsername = getUsername();
diff --git a/source/libs/api.ts b/source/libs/api.ts
index be6f84ec..21d4944e 100644
--- a/source/libs/api.ts
+++ b/source/libs/api.ts
@@ -45,7 +45,7 @@ export interface GHRestApiOptions {
accept404: boolean;
}
-export const escapeKey = (value: string): string => '_' + value.replace(/[./-]/g, '_');
+export const escapeKey = (value: string): string => '_' + value.replace(/[ ./-]/g, '_');
export class RefinedGitHubAPIError extends Error {
constructor(...messages: string[]) {