We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09431f7 commit e0a33feCopy full SHA for e0a33fe
src/Functions/getBranch.ts
@@ -9,13 +9,15 @@ const exec = promisify(require('child_process').exec)
9
* @return the branch HEAD name or not a repository
10
*/
11
export async function getBranch(): Promise<string> {
12
- let commit: string
+ let branch: string
13
14
try {
15
- commit = (await exec('git branch --show-current')).stdout.replace('\n', '')
+ branch = (await exec('git branch --show-current')).stdout.replace('\n', '')
16
+
17
+ if (!branch || branch === '') branch = 'Not a repository'
18
} catch (error) {
- commit = 'Not a repository'
19
+ branch = 'Not a repository'
20
}
21
- return commit
22
+ return branch
23
0 commit comments