-
Notifications
You must be signed in to change notification settings - Fork 4k
[No QA] Make -changed scripts check the working tree, not just committed changes
#99764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
670f5e2
b71be98
2b4d390
a0447f3
85ea9aa
86eb399
412511b
77e9e47
8abbc61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Spell-checks files that have changed in this branch. If file paths are | ||
| # passed as arguments (e.g. by CI, which gets its file list from the PR | ||
| # API), those are checked instead and no change discovery happens. | ||
|
|
||
| set -eu | ||
|
|
||
| TOP="$(realpath "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)/..")" | ||
| readonly TOP | ||
| source "${TOP}/scripts/shellUtils.sh" | ||
|
|
||
| if [[ "$#" -gt 0 ]]; then | ||
| exec "${TOP}/node_modules/.bin/cspell" --color --no-must-find-files "$@" | ||
| fi | ||
|
|
||
| info "Fetching origin/main" | ||
| MERGE_BASE_SHA_HASH="$(get_merge_base_with_main)" | ||
| readonly MERGE_BASE_SHA_HASH | ||
|
|
||
| # Excludes common binary/media file types since spell-checking them is pointless and wasteful | ||
| CHANGED_FILES_OUTPUT="$(get_changed_files "$MERGE_BASE_SHA_HASH" ':!*.png' ':!*.jpg' ':!*.jpeg' ':!*.gif' ':!*.webp' ':!*.ico' ':!*.mp4' ':!*.mov' ':!*.zip' ':!*.tar.gz' ':!*.heapsnapshot' ':!*.pdf')" | ||
| declare -a ALL_CHANGED_FILES=() | ||
| if [[ -n "$CHANGED_FILES_OUTPUT" ]]; then | ||
| # Excludes any path starting with "." (dotfiles and top-level dot-directories like .github/), matching CI's filter. A nested dot-directory, e.g. docs/.hidden/config.ts, is still checked. | ||
| while IFS= read -r file; do | ||
| if [[ "$file" != .* ]]; then | ||
| ALL_CHANGED_FILES+=("$file") | ||
| fi | ||
| done <<< "$CHANGED_FILES_OUTPUT" | ||
| fi | ||
| readonly -a ALL_CHANGED_FILES | ||
|
|
||
| if [[ "${#ALL_CHANGED_FILES[@]}" -gt 0 ]]; then | ||
| exec "${TOP}/node_modules/.bin/cspell" --color --no-must-find-files "${ALL_CHANGED_FILES[@]}" | ||
| else | ||
| info "No changed files to spell check" | ||
| fi | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code has the same structure with lintChanged.sh:11-26.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got your point but leaving duplicated - the two tails exec different tools with different args, a shared helper would just be an if/else around two one-liners |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The merge-base validation checks the output instead of the exit status
The
-zarm is dead: the empty string already fails the 40-hex regex, and both arms produce the same message.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dropped the dead -z arm