Skip to content

Commit b99821e

Browse files
authored
Support tags and commits again (download-directory#136)
1 parent e934a28 commit b99821e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

authenticated-fetch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
export default async function authenticatedFetch(
22
url: string,
3-
{signal}: {signal?: AbortSignal} = {},
3+
{signal, method}: {signal?: AbortSignal; method?: 'HEAD'} = {},
44
): Promise<Response> {
55
const token = globalThis.localStorage?.getItem('token');
66

77
const response = await fetch(url, {
8+
method,
9+
signal,
810
...(token
911
? {
1012
headers: {
@@ -13,7 +15,6 @@ export default async function authenticatedFetch(
1315
},
1416
}
1517
: {}),
16-
signal,
1718
});
1819

1920
switch (response.status) {

repository-info.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default async function getRepositoryInfo(
100100
}
101101

102102
async function checkBranchExists(user: string, repo: string, gitReference: string): Promise<boolean> {
103-
const apiUrl = `https://api.github.com/repos/${user}/${repo}/branches/${gitReference}`;
104-
const response = await authenticatedFetch(apiUrl);
103+
const apiUrl = `https://api.github.com/repos/${user}/${repo}/commits/${gitReference}?per_page=1`;
104+
const response = await authenticatedFetch(apiUrl, {method: 'HEAD'});
105105
return response.ok;
106106
}

0 commit comments

Comments
 (0)