mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2026 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
import { execSync } from 'node:child_process';
|
|
|
|
const EVALS_FILE_PREFIXES = [
|
|
'packages/core/src/prompts/',
|
|
'packages/core/src/tools/',
|
|
'evals/',
|
|
];
|
|
|
|
function main() {
|
|
const targetBranch = process.env.GITHUB_BASE_REF || 'main';
|
|
try {
|
|
// Fetch target branch from origin.
|
|
execSync(`git fetch origin ${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`, {
|
|
encoding: 'utf-8',
|
|
})
|
|
.split('\n')
|
|
.filter(Boolean);
|
|
|
|
const shouldRun = changedFiles.some((file) =>
|
|
EVALS_FILE_PREFIXES.some((prefix) => file.startsWith(prefix)),
|
|
);
|
|
|
|
console.log(shouldRun ? 'true' : 'false');
|
|
} catch (error) {
|
|
// If anything fails (e.g., no git history), run evals to be safe
|
|
console.warn(
|
|
'Warning: Failed to determine if evals should run. Defaulting to true.',
|
|
);
|
|
console.error(error);
|
|
console.log('true');
|
|
}
|
|
}
|
|
|
|
main();
|