From c96b439a481dbc63eaf2caac790b5893668cc0b2 Mon Sep 17 00:00:00 2001 From: Hanefi Onaldi Date: Thu, 11 Mar 2021 13:27:05 +0300 Subject: [PATCH] Introduce scripts to sync gitignore rules for .source files --- .circleci/config.yml | 6 ++++++ ci/README.md | 6 ++++++ ci/fix_gitignore.sh | 20 ++++++++++++++++++++ ci/fix_style.sh | 1 + 4 files changed, 33 insertions(+) create mode 100755 ci/fix_gitignore.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index c6f2ee445..a286b7ba7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/ci/README.md b/ci/README.md index 0d1be65f2..73962f80a 100644 --- a/ci/README.md +++ b/ci/README.md @@ -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. diff --git a/ci/fix_gitignore.sh b/ci/fix_gitignore.sh new file mode 100755 index 000000000..c8d6b29ac --- /dev/null +++ b/ci/fix_gitignore.sh @@ -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 diff --git a/ci/fix_style.sh b/ci/fix_style.sh index 8846eda38..c15eb3def 100755 --- a/ci/fix_style.sh +++ b/ci/fix_style.sh @@ -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