Skip to content

Commit e4e8378

Browse files
committed
we should try to read head-ref first
1 parent 8f05e64 commit e4e8378

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

content/utils/githubInfo.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ export function getRepositoryInfo() {
2626
prNumber = pathParts[prIndex + 1];
2727
}
2828

29+
// First try head-ref
30+
if (!prBranch) {
31+
const branchSpan = document.querySelector('span.head-ref');
32+
if (branchSpan) {
33+
prBranch = branchSpan.textContent.trim();
34+
}
35+
}
36+
2937
// Try to find the branch name from the page using multiple selectors
3038
// First try the commit-ref selector (older GitHub UI)
3139
const branchElements = document.querySelectorAll('.commit-ref');
@@ -43,15 +51,7 @@ export function getRepositoryInfo() {
4351
prBranch = headRefElement.textContent.trim();
4452
}
4553
}
46-
47-
// If still not found, try another selector pattern
48-
if (!prBranch) {
49-
const branchSpan = document.querySelector('span.head-ref');
50-
if (branchSpan) {
51-
prBranch = branchSpan.textContent.trim();
52-
}
53-
}
54-
54+
5555
// Clean up the branch name if it has any extra characters
5656
if (prBranch) {
5757
// Remove any emoji or special characters that might be in the branch name display
@@ -102,4 +102,4 @@ export function getPRForkInfo() {
102102
}
103103

104104
return null;
105-
}
105+
}

0 commit comments

Comments
 (0)