Introduce scripts to sync gitignore rules for .source files

pull/4811/head
Hanefi Onaldi 2021-03-11 13:27:05 +03:00
parent cbbd10b974
commit c96b439a48
No known key found for this signature in database
GPG Key ID: F18CDB10BA0DFDC7
4 changed files with 33 additions and 0 deletions

View File

@ -64,6 +64,12 @@ jobs:
- run:
name: 'Check if changed'
command: git diff --exit-code
- run:
name: 'Check for gitignore entries .for source files'
command: ci/fix_gitignore.sh
- run:
name: 'Check if changed'
command: git diff --exit-code
- run:
name: 'Check for lengths of changelog entries'
command: ci/disallow_long_changelog_entries.sh

View File

@ -346,3 +346,9 @@ foo = 2
#endif
```
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.

20
ci/fix_gitignore.sh Executable file
View File

@ -0,0 +1,20 @@
#! /bin/bash
# shellcheck disable=SC2012
set -euo pipefail
# shellcheck disable=SC1091
source ci/ci_helpers.sh
# We list all the .source files in alphabetical order, and do a substitution
# before writing the resulting file names that are created by those templates in
# relevant .gitignore files
#
# 1. Capture the file name without the .source extension
# 2. Add the desired extension at the end
# 3. Add a / character at the beginning of each line to conform to .gitignore file format
#
# e.g. multi_copy.source -> /multi_copy.sql
ls -1 src/test/regress/input | sed -E "s#(.*)\.source#/\1.sql#" > src/test/regress/sql/.gitignore
# 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

View File

@ -14,3 +14,4 @@ ci/remove_useless_declarations.sh
ci/disallow_c_comments_in_migrations.sh
ci/disallow_long_changelog_entries.sh
ci/normalize_expected.sh
ci/fix_gitignore.sh