summaryrefslogtreecommitdiff
path: root/source/github-helpers/index.ts
diff options
context:
space:
mode:
authorGravatar Federico Brigante <me@fregante.com> 2023-05-11 05:28:40 +0800
committerGravatar GitHub <noreply@github.com> 2023-05-10 21:28:40 +0000
commit48658675d7bbb3ecd5e3a51df0447b65bb0b1219 (patch)
treed70832506df4326c612f721b1c6c496513db0eac /source/github-helpers/index.ts
parent358edc207f72fb01a32c916c28b90839359c662a (diff)
downloadrefined-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 'source/github-helpers/index.ts')
-rw-r--r--source/github-helpers/index.ts16
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);
+}