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/index.ts | |
parent | 358edc207f72fb01a32c916c28b90839359c662a (diff) | |
download | refined-github-23.5.10.tar.gz refined-github-23.5.10.tar.zst refined-github-23.5.10.zip |
Improve reliability of `list-prs-for-branch` (#6641)23.5.10
Diffstat (limited to '')
-rw-r--r-- | source/github-helpers/index.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/github-helpers/index.ts b/source/github-helpers/index.ts index ed491a7b..979ffbcd 100644 --- a/source/github-helpers/index.ts +++ b/source/github-helpers/index.ts @@ -134,3 +134,19 @@ export async function isArchivedRepoAsync(): Promise<boolean> { export const userCanLikelyMergePR = (): boolean => select.exists('.discussion-sidebar-item .octicon-lock'); export const cacheByRepo = (): string => getRepo()!.nameWithOwner; + +// Commit lists for files and folders lack a branch selector +export const isRepoCommitListRoot = (): boolean => pageDetect.isRepoCommitList() && document.title.startsWith('Commits'); + +// Don't make the argument optional, sometimes we really expect it to exist and want to throw an error +export function extractCurrentBranchFromBranchPicker(branchPicker: HTMLElement): string { + return branchPicker.title === 'Switch branches or tags' + ? branchPicker.textContent!.trim() // Branch name is shown in full + : branchPicker.title; // Branch name was clipped, so they placed it in the title attribute +} + +export function addAfterBranchSelector(branchSelectorParent: HTMLDetailsElement, sibling: HTMLElement): void { + const row = branchSelectorParent.closest('.position-relative')!; + row.classList.add('d-flex', 'flex-shrink-0', 'gap-2'); + row.append(sibling); +} |