-
Notifications
You must be signed in to change notification settings - Fork 61.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Massive DIFF_FILES crashes bash in repo-sync (#23326)
* Massive DIFF_FILES crashes bash in repo-sync Part of #1304 * gst * make exception
- Loading branch information
Showing
4 changed files
with
44 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import fs from 'fs' | ||
|
||
// The reason we're not manually doing a spawned subprocess | ||
// of `git diff --name-only ...` or something here is because that stuff | ||
// is unpredictable in GitHub Actions because of how it does `git clone`. | ||
// So we rely on environment variables instead. | ||
|
||
export function getDiffFiles() { | ||
// Instead of testing every single file possible, if there's | ||
// an environment variable called `DIFF_FILES` or one called | ||
// `DIFF_FILE` then use that. | ||
// If `DIFF_FILES` is set, it's expected to be a space separated | ||
// string. If `DIFF_FILE` is set, it's expected to be a text file | ||
// which contains a space separated string. | ||
const diffFiles = [] | ||
// Setting an environment varible called `DIFF_FILES` is optional. | ||
// But if and only if it's set, we will respect it. | ||
// And if it set, turn it into a cleaned up Set so it's made available | ||
// every time we use it. | ||
// Alternatively, you can put all the files change changed into a | ||
// text file and do `export DIFF_FILE=files-that-changed.txt` | ||
if (process.env.DIFF_FILES) { | ||
diffFiles.push(...process.env.DIFF_FILES.trim().split(/\s+/g)) | ||
} else if (process.env.DIFF_FILE) { | ||
diffFiles.push(...fs.readFileSync(process.env.DIFF_FILE, 'utf-8').trim().split(/\s+/g)) | ||
} | ||
|
||
return diffFiles | ||
} |