diff options
Diffstat (limited to 'source/github-helpers/is-default-branch.ts')
| -rw-r--r-- | source/github-helpers/is-default-branch.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/github-helpers/is-default-branch.ts b/source/github-helpers/is-default-branch.ts new file mode 100644 index 00000000..82ef0be1 --- /dev/null +++ b/source/github-helpers/is-default-branch.ts @@ -0,0 +1,13 @@ +import getDefaultBranch from './get-default-branch.js'; +import getCurrentGitRef from './get-current-git-ref.js'; + +/** Detects if the current view is on the default branch. To be used on file/folder/commit lists */ +export default async function isDefaultBranch(): Promise<boolean> { + const currentBranch = getCurrentGitRef(); + if (!currentBranch) { + // This happens on the repo root OR on views that are not branch-specific (like isIssue) + return true; + } + + return currentBranch === await getDefaultBranch(); +} |
