Remove ignored files from git tree

pull/4811/head
Hanefi Onaldi 2021-05-11 11:17:55 +03:00
parent 13808b60cf
commit 6b2c9d3567
No known key found for this signature in database
GPG Key ID: F18CDB10BA0DFDC7
2 changed files with 23 additions and 3 deletions

View File

@ -349,6 +349,12 @@ This was deemed to be error prone and not worth the effort.
## `fix_gitignore.sh`
This script makes sure that git ignores the sql files and expected output files
that are generated from `.source` template files. If you created or deleted a
`.source` file in a commit, git ignore rules should be updated.
This script checks and fixes issues with `.gitignore` rules:
1. Makes sure git ignores the `.sql` files and expected output files that are generated
from `.source` template files. If you created or deleted a `.source` file in a commit,
git ignore rules should be updated to reflect this change.
2. Makes sure we do not commit any generated files that should be ignored. If there is an
ignored file in the git tree, the user is expected to review the files that are removed
from the git tree and commit them.

View File

@ -18,3 +18,17 @@ ls -1 src/test/regress/input | sed -E "s#(.*)\.source#/\1.sql#" > src/test/regre
# e.g. multi_copy.source -> /multi_copy.out
ls -1 src/test/regress/output | sed -E "s#(.*)\.source#/\1.out#" > src/test/regress/expected/.gitignore
# Remove all the ignored files from git tree, and error out
# find all ignored files in git tree, and use quotation marks to prevent word splitting on filenames with spaces in them
ignored_lines_in_git_tree=$(git ls-files --ignored --exclude-standard | sed 's/.*/"&"/')
if [[ -n $ignored_lines_in_git_tree ]]
then
echo "Ignored files should not be in git tree!"
echo "${ignored_lines_in_git_tree}"
echo "Removing these files from git tree, please review and commit"
echo "$ignored_lines_in_git_tree" | xargs git rm -r --cached
exit 1
fi