Skip to content

Commit 88b220d

Browse files
committed
refactor(github): simplify author login resolution logic and remove unused error logging
1 parent 5ffff24 commit 88b220d

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/git.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dayjs from 'dayjs';
22
import { ofetch } from 'ofetch';
3-
import { consola } from 'consola';
43
import semver from 'semver';
54
import { execCommand, notNullish } from './shared';
65
import { VERSION_REG } from './constant';
@@ -224,46 +223,40 @@ async function getResolvedAuthorLogin(github: GithubConfig, commitHashes: string
224223

225224
let login = '';
226225

227-
// token not provided, skip github resolving
228-
if (!token) {
229-
return login;
230-
}
231-
232226
try {
233227
const data = await ofetch(`https://api.github.com/search/users?q=${encodeURIComponent(email)}`, {
234228
headers: getHeaders(token)
235229
});
236230
login = data.items[0].login;
237-
} catch (e) {
238-
consola.log('e: ', e);
231+
} catch {}
232+
233+
if (login) {
234+
return login;
239235
}
240236

237+
try {
238+
const data = await ofetch(`https://ungh.cc/users/find/${email}`);
239+
login = data?.user?.username || '';
240+
} catch {}
241+
241242
if (login) {
242243
return login;
243244
}
244245

246+
// token not provided, skip github resolving
247+
if (!token) {
248+
return login;
249+
}
250+
245251
if (commitHashes.length) {
246252
try {
247253
const data = await ofetch(`https://api.github.com/repos/${repo}/commits/${commitHashes[0]}`, {
248254
headers: getHeaders(token)
249255
});
250256
login = data?.author?.login || '';
251-
} catch (e) {
252-
consola.log('e: ', e);
253-
}
257+
} catch {}
254258
}
255259

256-
// try {
257-
// const data = await ofetch(`https://ungh.cc/users/find/${email}`);
258-
// login = data?.user?.username || '';
259-
// } catch (e) {
260-
// consola.log('e: ', e);
261-
// }
262-
263-
// if (login) {
264-
// return login;
265-
// }
266-
267260
return login;
268261
}
269262

0 commit comments

Comments
 (0)