diff options
author | 2023-08-24 20:41:06 +0900 | |
---|---|---|
committer | 2023-08-24 18:41:06 +0700 | |
commit | c23f33b34159b91ab1ff3987515e03e9bac0948a (patch) | |
tree | d0f57736d24b11fd0eec606d4a83589fe1cdf14d /source/github-helpers | |
parent | a845070fdd9fbde4aa63ecce7882b33335423cc4 (diff) | |
download | refined-github-c23f33b34159b91ab1ff3987515e03e9bac0948a.tar.gz refined-github-c23f33b34159b91ab1ff3987515e03e9bac0948a.tar.zst refined-github-c23f33b34159b91ab1ff3987515e03e9bac0948a.zip |
Improve support of New Repository Overview (#6837)
Diffstat (limited to 'source/github-helpers')
-rw-r--r-- | source/github-helpers/get-default-branch.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/github-helpers/get-default-branch.ts b/source/github-helpers/get-default-branch.ts index f5e0c5db..5681325b 100644 --- a/source/github-helpers/get-default-branch.ts +++ b/source/github-helpers/get-default-branch.ts @@ -11,13 +11,19 @@ const isCurrentRepo = ({nameWithOwner}: RepositoryInfo): boolean => Boolean(getR // Do not make this function complicated. We're only optimizing for the repo root. async function fromDOM(): Promise<string | undefined> { if (!['', 'commits'].includes(getRepo()!.path)) { - return undefined; + return; } // We're on the default branch, so we can extract it from the current page. This exclusively happens on the exact pages: // /user/repo // /user/repo/commits (without further path) - return extractCurrentBranchFromBranchPicker((await elementReady(branchSelector))!); + const element = await elementReady(branchSelector); + + if (!element) { + return; + } + + return extractCurrentBranchFromBranchPicker(element); } async function fromAPI(repository: RepositoryInfo): Promise<string> { |