Skip to content

Commit

Permalink
chore: make release branch pattern more robust (#21568)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Dec 18, 2019
1 parent b6214fd commit 5e244aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions script/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const path = require('path')
const ELECTRON_DIR = path.resolve(__dirname, '..', '..')
const SRC_DIR = path.resolve(ELECTRON_DIR, '..')

const RELEASE_BRANCH_PATTERN = /(\d)+-(?:(?:[0-9]+-x$)|(?:x+-y$))/

require('colors')
const pass = '✓'.green
const fail = '✗'.red
Expand Down Expand Up @@ -66,7 +68,7 @@ async function handleGitCall (args, gitDir) {

async function getCurrentBranch (gitDir) {
let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir)
if (branch !== 'master' && !branch.match(/[0-9]+-[0-9]+-x$/) && !branch.match(/[0-9]+-x-y$/)) {
if (branch !== 'master' && !RELEASE_BRANCH_PATTERN.test(branch)) {
const lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir)
const branches = (await handleGitCall([
'branch',
Expand All @@ -75,7 +77,7 @@ async function getCurrentBranch (gitDir) {
'--remote'
], gitDir)).split('\n')

branch = branches.filter(b => b.trim() === 'master' || b.trim().match(/^[0-9]+-[0-9]+-x$/) || b.trim().match(/^[0-9]+-x-y$/))[0]
branch = branches.filter(b => b.trim() === 'master' || RELEASE_BRANCH_PATTERN.test(b.trim()))[0]
if (!branch) {
console.log(`${fail} no release branch exists for this ref`)
process.exit(1)
Expand Down

0 comments on commit 5e244aa

Please sign in to comment.