build(vim-patch.sh): checkout files with path for uncrustify (#20863)

This commit is contained in:
zeertzjq
2022-10-30 08:05:50 +08:00
committed by GitHub
parent 2817411b7d
commit 8d38e1ad34

View File

@ -280,49 +280,32 @@ preprocess_patch() {
"$file" > "$file".tmp && mv "$file".tmp "$file"
# Rename test_urls.vim to check_urls.vim
LC_ALL=C sed -e 's@\( [ab]\)/runtime/doc/test\(_urls\.vim\)@\1/scripts/check\2@g' \
"$file" > "$file".tmp && mv "$file".tmp "$file"
LC_ALL=C sed -e 's@\( [ab]\)/runtime/doc/test\(_urls\.vim\)@\1/scripts/check\2@g' \
"$file" > "$file".tmp && mv "$file".tmp "$file"
# Rename path to check_colors.vim
LC_ALL=C sed -e 's@\( [ab]/runtime\)/colors/\(tools/check_colors\.vim\)@\1/\2@g' \
"$file" > "$file".tmp && mv "$file".tmp "$file"
}
}
uncrustify_patch() {
uncrustify_patch() {
local commit="$1"
local changed_files=()
while IFS='' read -r file; do changed_files+=("$file"); done < <(git diff-tree --name-only --no-commit-id -r "${commit}")
git diff --quiet || {
>&2 echo 'Vim source working tree dirty, aborting.'
exit 1
}
rm -rf "$patch_path"
mkdir -p "$patch_path"/{before,after,patch}
git checkout --quiet "$commit"~
for file in "${changed_files[@]}"; do
if [[ -e $file ]]; then
local patch_path=$NVIM_SOURCE_DIR/build/vim_patch
rm -rf "$patch_path"
mkdir -p "$patch_path"/{a,b}
local commit="$1"
for file in $(git diff-tree --name-only --no-commit-id -r --diff-filter=a "$commit"); do
git --work-tree="$patch_path"/a checkout --quiet "$commit"~ -- "$file"
done
if [[ -e $file ]]; then
for file in $(git diff-tree --name-only --no-commit-id -r --diff-filter=d "$commit"); do
git --work-tree="$patch_path"/b checkout --quiet "$commit" -- "$file"
done
done
# If the difference are drastic enough uncrustify may need to be used more
# than once. This is obviously a bug that needs to be fixed on uncrustify's
# end, but in the meantime this workaround is sufficient.
for _ in {1..2}; do
uncrustify -c "$NVIM_SOURCE_DIR"/src/uncrustify.cfg -q --replace --no-backup "$patch_path"/{before,after}/*.[ch]
done
for file in "${changed_files[@]}"; do
local basename
basename=$(basename "$file")
local before=$patch_path/before/$basename
local after=$patch_path/after/$basename
git reset --quiet --hard HEAD
# If the difference are drastic enough uncrustify may need to be used more
# than once. This is obviously a bug that needs to be fixed on uncrustify's
@ -335,7 +318,6 @@ get_vimpatch() {
}
get_vimpatch() {
get_vim_sources
get_vim_sources
assign_commit_details "${1}"