chore: make release branch pattern more robust (#21568)
This commit is contained in:
parent
b6214fdddf
commit
5e244aa505
1 changed files with 4 additions and 2 deletions
|
@ -5,6 +5,8 @@ const path = require('path')
|
||||||
const ELECTRON_DIR = path.resolve(__dirname, '..', '..')
|
const ELECTRON_DIR = path.resolve(__dirname, '..', '..')
|
||||||
const SRC_DIR = path.resolve(ELECTRON_DIR, '..')
|
const SRC_DIR = path.resolve(ELECTRON_DIR, '..')
|
||||||
|
|
||||||
|
const RELEASE_BRANCH_PATTERN = /(\d)+-(?:(?:[0-9]+-x$)|(?:x+-y$))/
|
||||||
|
|
||||||
require('colors')
|
require('colors')
|
||||||
const pass = '✓'.green
|
const pass = '✓'.green
|
||||||
const fail = '✗'.red
|
const fail = '✗'.red
|
||||||
|
@ -66,7 +68,7 @@ async function handleGitCall (args, gitDir) {
|
||||||
|
|
||||||
async function getCurrentBranch (gitDir) {
|
async function getCurrentBranch (gitDir) {
|
||||||
let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], 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 lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir)
|
||||||
const branches = (await handleGitCall([
|
const branches = (await handleGitCall([
|
||||||
'branch',
|
'branch',
|
||||||
|
@ -75,7 +77,7 @@ async function getCurrentBranch (gitDir) {
|
||||||
'--remote'
|
'--remote'
|
||||||
], gitDir)).split('\n')
|
], 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) {
|
if (!branch) {
|
||||||
console.log(`${fail} no release branch exists for this ref`)
|
console.log(`${fail} no release branch exists for this ref`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue