-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Expand file tree
/
Copy pathchanged_prompt.js
More file actions
48 lines (41 loc) · 1.17 KB
/
changed_prompt.js
File metadata and controls
48 lines (41 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @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/',
];
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 main
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();