diff options
author | 2023-05-11 05:28:40 +0800 | |
---|---|---|
committer | 2023-05-10 21:28:40 +0000 | |
commit | 48658675d7bbb3ecd5e3a51df0447b65bb0b1219 (patch) | |
tree | d70832506df4326c612f721b1c6c496513db0eac /source/github-helpers/get-current-git-ref.ts | |
parent | 358edc207f72fb01a32c916c28b90839359c662a (diff) | |
download | refined-github-0b79211aa9a9c39b16526ab85bf6ab319f8ae5c1.tar.gz refined-github-0b79211aa9a9c39b16526ab85bf6ab319f8ae5c1.tar.zst refined-github-0b79211aa9a9c39b16526ab85bf6ab319f8ae5c1.zip |
Improve reliability of `list-prs-for-branch` (#6641)23.5.10
Diffstat (limited to 'source/github-helpers/get-current-git-ref.ts')
-rw-r--r-- | source/github-helpers/get-current-git-ref.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source/github-helpers/get-current-git-ref.ts b/source/github-helpers/get-current-git-ref.ts index 71b27222..74abb87a 100644 --- a/source/github-helpers/get-current-git-ref.ts +++ b/source/github-helpers/get-current-git-ref.ts @@ -1,6 +1,7 @@ import {isRepoCommitList} from 'github-url-detection'; import select from 'select-dom'; +import {extractCurrentBranchFromBranchPicker} from './index.js'; import {branchSelector} from './selectors.js'; const typesWithGitRef = new Set(['tree', 'blob', 'blame', 'edit', 'commit', 'commits', 'compare']); @@ -10,7 +11,8 @@ const titleWithGitRef = / at (?<branch>[.\w-/]+)( ยท [\w-]+\/[\w-]+)?$/i; export default function getCurrentGitRef(): string | undefined { // Note: This is not in the <head> so it's only available on AJAXed loads. // It appears on every Code page except `commits` on folders/files - const refViaPicker = select(branchSelector)?.textContent!.trim(); + const picker = select(branchSelector); + const refViaPicker = picker && extractCurrentBranchFromBranchPicker(picker); if (refViaPicker) { return refViaPicker; } |