From b29d77fb527d35271b6350ab638315bef85ad456 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Thu, 27 May 2021 11:33:00 -0700 Subject: [PATCH 1/2] refactor: getCurrentBranch respects main --- script/lib/utils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/lib/utils.js b/script/lib/utils.js index a0c869530d083..bea7acbdb208e 100644 --- a/script/lib/utils.js +++ b/script/lib/utils.js @@ -6,6 +6,8 @@ const ELECTRON_DIR = path.resolve(__dirname, '..', '..'); const SRC_DIR = path.resolve(ELECTRON_DIR, '..'); const RELEASE_BRANCH_PATTERN = /(\d)+-(?:(?:[0-9]+-x$)|(?:x+-y$))/; +const MAIN_BRANCH_PATTERN = /^(main|master)$/; +const ORIGIN_MAIN_BRANCH_PATTERN = /^origin\/(main|master)$/; require('colors'); const pass = '✓'.green; @@ -73,7 +75,7 @@ async function handleGitCall (args, gitDir) { async function getCurrentBranch (gitDir) { let branch = await handleGitCall(['rev-parse', '--abbrev-ref', 'HEAD'], gitDir); - if (branch !== 'master' && !RELEASE_BRANCH_PATTERN.test(branch)) { + if (!MAIN_BRANCH_PATTERN.test(branch) && !RELEASE_BRANCH_PATTERN.test(branch)) { const lastCommit = await handleGitCall(['rev-parse', 'HEAD'], gitDir); const branches = (await handleGitCall([ 'branch', @@ -82,7 +84,7 @@ async function getCurrentBranch (gitDir) { '--remote' ], gitDir)).split('\n'); - branch = branches.filter(b => b.trim() === 'master' || b.trim() === 'origin/master' || RELEASE_BRANCH_PATTERN.test(b.trim()))[0]; + branch = branches.find(b => MAIN_BRANCH_PATTERN.test(b.trim()) || ORIGIN_MAIN_BRANCH_PATTERN.test(b.trim()) || RELEASE_BRANCH_PATTERN.test(b.trim())); if (!branch) { console.log(`${fail} no release branch exists for this ref`); process.exit(1); From de5a85e47d4bb01bf9942cfdcaf65ab1409579f9 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Thu, 27 May 2021 11:46:17 -0700 Subject: [PATCH 2/2] add note about migration --- script/lib/utils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script/lib/utils.js b/script/lib/utils.js index bea7acbdb208e..55f678b43ed1c 100644 --- a/script/lib/utils.js +++ b/script/lib/utils.js @@ -6,6 +6,7 @@ const ELECTRON_DIR = path.resolve(__dirname, '..', '..'); const SRC_DIR = path.resolve(ELECTRON_DIR, '..'); const RELEASE_BRANCH_PATTERN = /(\d)+-(?:(?:[0-9]+-x$)|(?:x+-y$))/; +// TODO(main-migration): Simplify once main branch is renamed const MAIN_BRANCH_PATTERN = /^(main|master)$/; const ORIGIN_MAIN_BRANCH_PATTERN = /^origin\/(main|master)$/;