Skip to content

Commit e0a33fe

Browse files
committed
feat: Adjust getBranch function for CI
1 parent 09431f7 commit e0a33fe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Functions/getBranch.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ const exec = promisify(require('child_process').exec)
99
* @return the branch HEAD name or not a repository
1010
*/
1111
export async function getBranch(): Promise<string> {
12-
let commit: string
12+
let branch: string
1313

1414
try {
15-
commit = (await exec('git branch --show-current')).stdout.replace('\n', '')
15+
branch = (await exec('git branch --show-current')).stdout.replace('\n', '')
16+
17+
if (!branch || branch === '') branch = 'Not a repository'
1618
} catch (error) {
17-
commit = 'Not a repository'
19+
branch = 'Not a repository'
1820
}
1921

20-
return commit
22+
return branch
2123
}

0 commit comments

Comments
 (0)