Browse Source

fix: trim branch name before comparing to master (#19853) (#20922)

(cherry picked from commit f10f44acf5e070faf06eb43f6a9d00a7fe73f977)
John Kleinschmidt 5 years ago
parent
commit
e991681277
1 changed files with 8 additions and 2 deletions
  1. 8 2
      script/lib/utils.js

+ 8 - 2
script/lib/utils.js

@@ -38,8 +38,14 @@ async function getCurrentBranch (gitDir) {
   let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir)
   if (branch !== 'master' && !branch.match(/[0-9]+-[0-9]+-x/)) {
     const lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir)
-    const branches = (await handleGitCall(['branch', '--contains', lastCommit, '--remote'], gitDir)).split('\n')
-    branch = branches.filter(b => b === 'master' || b.match(/[0-9]+-[0-9]+-x/))[0]
+    const branches = (await handleGitCall([
+      'branch',
+      '--contains',
+      lastCommit,
+      '--remote'
+    ], gitDir)).split('\n')
+
+    branch = branches.filter(b => b.trim() === 'master' || b.match(/[0-9]+-[0-9]+-x/))[0]
     if (!branch) {
       console.log(`${fail} no release branch exists for this ref`)
       process.exit(1)