X Tutup
Skip to content

Commit 7748dec

Browse files
trop[bot]codebytere
authored andcommitted
chore: fix current branch fetch on master (electron#18862)
1 parent d75750a commit 7748dec

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

script/lib/utils.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ function getAbsoluteElectronExec () {
2727
async function handleGitCall (args, gitDir) {
2828
const details = await GitProcess.exec(args, gitDir)
2929
if (details.exitCode === 0) {
30-
return details.stdout.trim()
30+
const output = details.stdout.replace(/^\*|\s+|\s+$/, '')
31+
return output.trim()
3132
} else {
3233
const error = GitProcess.parseError(details.stderr)
3334
console.log(`${fail} couldn't parse git process call: `, error)
@@ -37,10 +38,14 @@ async function handleGitCall (args, gitDir) {
3738

3839
async function getCurrentBranch (gitDir) {
3940
let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir)
40-
if (!branch.match(/[0-9]+-[0-9]+-x/)) {
41+
if (branch !== 'master' && !branch.match(/[0-9]+-[0-9]+-x/)) {
4142
const lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir)
4243
const branches = (await handleGitCall(['branch', '--contains', lastCommit], gitDir)).split('\n')
43-
branch = branches.filter(b => b.match(/[0-9]+-[0-9]+-x/))[0].trim()
44+
branch = branches.filter(b => b === 'master' || b.match(/[0-9]+-[0-9]+-x/))[0]
45+
if (!branch) {
46+
console.log(`${fail} no release branch exists for this ref`)
47+
process.exit(1)
48+
}
4449
}
4550
return branch
4651
}

0 commit comments

Comments
 (0)
X Tutup