This commit is contained in:
Simon Knott 2024-07-17 12:10:04 +02:00
parent 72d7c86290
commit bed44661e1
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -82,10 +82,15 @@ export type TestFileFilter = {
}; };
export async function detectChangedFiles(baseCommit: string): Promise<string[]> { export async function detectChangedFiles(baseCommit: string): Promise<string[]> {
const untrackedFiles = childProcess.execSync('git ls-files --others --exclude-standard', { encoding: 'utf-8' }).split('\n').filter(Boolean); const gitFileList = (command: string) => childProcess.execSync(`git ${command}`, { encoding: 'utf-8' }).split('\n').filter(Boolean).map(file => path.resolve(file));
const changedFiles = childProcess.execSync(`git diff ${baseCommit} --name-only`, { encoding: 'utf-8' }).split('\n').filter(Boolean); const untrackedFiles = gitFileList(`ls-files --others --exclude-standard`);
const trackedFilesWithChanges = gitFileList(`diff ${baseCommit} --name-only`);
return [...untrackedFiles, ...changedFiles, ...affectedTestFiles([...untrackedFiles, ...changedFiles].map(file => path.resolve(file)))]; const filesWithChanges = [...untrackedFiles, ...trackedFilesWithChanges];
return [
...filesWithChanges,
...affectedTestFiles(filesWithChanges),
];
} }
export async function createFileFiltersFromArguments(args: string[], onlyChanged: string | undefined): Promise<TestFileFilter[]> { export async function createFileFiltersFromArguments(args: string[], onlyChanged: string | undefined): Promise<TestFileFilter[]> {