build(ci): fix false positive evals trigger on merge commits (#22237)

This commit is contained in:
Christian Gunderman
2026-03-13 00:38:54 +00:00
committed by GitHub
parent 3038fdce2e
commit 97bc3f28c5

View File

@@ -14,18 +14,17 @@ const EVALS_FILE_PREFIXES = [
function main() {
const targetBranch = process.env.GITHUB_BASE_REF || 'main';
try {
// Fetch target branch from origin.
execSync(`git fetch origin ${targetBranch}`, {
const remoteUrl = process.env.GITHUB_REPOSITORY
? `https://github.com/${process.env.GITHUB_REPOSITORY}.git`
: 'origin';
// Fetch target branch from the remote.
execSync(`git fetch ${remoteUrl} ${targetBranch}`, {
stdio: 'ignore',
});
// Find the merge base with the target branch.
const mergeBase = execSync('git merge-base HEAD FETCH_HEAD', {
encoding: 'utf-8',
}).trim();
// Get changed files
const changedFiles = execSync(`git diff --name-only ${mergeBase} HEAD`, {
// Get changed files using the triple-dot syntax which correctly handles merge commits
const changedFiles = execSync(`git diff --name-only FETCH_HEAD...HEAD`, {
encoding: 'utf-8',
})
.split('\n')