mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
build: fix roller branch detection in CI (#49920)
This commit is contained in:
@@ -14,6 +14,23 @@ const DEPS_REGEX = /chromium_version':\n +'(.+?)',/m;
|
|||||||
const CL_REGEX = /https:\/\/chromium-review\.googlesource\.com\/c\/(?:chromium\/src|v8\/v8)\/\+\/(\d+)(#\S+)?/g;
|
const CL_REGEX = /https:\/\/chromium-review\.googlesource\.com\/c\/(?:chromium\/src|v8\/v8)\/\+\/(\d+)(#\S+)?/g;
|
||||||
const ROLLER_BRANCH_PATTERN = /^roller\/chromium\/(.+)$/;
|
const ROLLER_BRANCH_PATTERN = /^roller\/chromium\/(.+)$/;
|
||||||
|
|
||||||
|
function getCurrentBranch () {
|
||||||
|
// In CI, use `GITHUB_HEAD_REF` since we checkout the PR branch in detached HEAD state
|
||||||
|
if (process.env.GITHUB_HEAD_REF) {
|
||||||
|
return process.env.GITHUB_HEAD_REF;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return execSync('git rev-parse --abbrev-ref HEAD', {
|
||||||
|
cwd: ELECTRON_DIR,
|
||||||
|
encoding: 'utf8'
|
||||||
|
}).trim();
|
||||||
|
} catch {
|
||||||
|
console.error('Could not determine current git branch');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getCommitsSinceMergeBase (mergeBase) {
|
function getCommitsSinceMergeBase (mergeBase) {
|
||||||
try {
|
try {
|
||||||
const output = execSync(`git log --format=%H%n%B%n---COMMIT_END--- ${mergeBase}..HEAD`, {
|
const output = execSync(`git log --format=%H%n%B%n---COMMIT_END--- ${mergeBase}..HEAD`, {
|
||||||
@@ -92,17 +109,7 @@ async function getGerritPatchDetails (clUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main () {
|
async function main () {
|
||||||
let currentBranch;
|
const currentBranch = getCurrentBranch();
|
||||||
|
|
||||||
try {
|
|
||||||
currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
|
|
||||||
cwd: ELECTRON_DIR,
|
|
||||||
encoding: 'utf8'
|
|
||||||
}).trim();
|
|
||||||
} catch {
|
|
||||||
console.error('Could not determine current git branch');
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we're on a roller/chromium/* branch
|
// Check if we're on a roller/chromium/* branch
|
||||||
const branchMatch = ROLLER_BRANCH_PATTERN.exec(currentBranch);
|
const branchMatch = ROLLER_BRANCH_PATTERN.exec(currentBranch);
|
||||||
|
|||||||
Reference in New Issue
Block a user