Disallow C-style comments in migration files

pull/3829/head
Hanefi Önaldı 2020-06-18 16:58:16 +03:00
parent 56285e6470
commit 618453a2ba
No known key found for this signature in database
GPG Key ID: 45A2ACB84E394FBA
6 changed files with 44 additions and 11 deletions

View File

@ -41,6 +41,12 @@ jobs:
- run: - run:
name: 'Check if changed' name: 'Check if changed'
command: git diff --exit-code command: git diff --exit-code
- run:
name: 'Check for C-style comments in migration files'
command: ci/disallow_c_comments_in_migrations.sh
- run:
name: 'Check if changed'
command: git diff --exit-code
- run: - run:
name: 'Check for banned C API usage' name: 'Check for banned C API usage'
command: ci/banned.h.sh command: ci/banned.h.sh

View File

@ -0,0 +1,26 @@
#! /bin/bash
set -euo pipefail
# We do not use c-style comments in migration files as the stripped
# zero-length migration files cause warning during packaging
# See #3115 for more info
# In this file, we aim to keep the indentation intact by capturing whitespaces,
# and reusing them if needed. GNU sed unfortunately does not support lookaround assertions.
# /* -> --
find src/backend/distributed/sql/*.sql -print0 | xargs -0 sed -i 's#/\*#--#g'
# */ -> `` (empty string)
# remove all whitespaces immediately before the match
find src/backend/distributed/sql/*.sql -print0 | xargs -0 sed -i 's#\s*\*/\s*##g'
# * -> --
# keep the indentation
# allow only whitespaces before the match
find src/backend/distributed/sql/*.sql -print0 | xargs -0 sed -i 's#^\(\s*\) \*#\1--#g'
# // -> --
# do not touch http:// or similar by allowing only whitespaces before //
find src/backend/distributed/sql/*.sql -print0 | xargs -0 sed -i 's#^\(\s*\)//#\1--#g'

View File

@ -10,5 +10,6 @@ cd ${cidir}/..
ci/editorconfig.sh ci/editorconfig.sh
ci/remove_useless_declarations.sh ci/remove_useless_declarations.sh
ci/disallow_c_comments_in_migrations.sh
citus_indent . --quiet citus_indent . --quiet

View File

@ -1,2 +1,2 @@
/* we've some issues with versioning, and we're fixing it by bumping version */ -- we've some issues with versioning, and we're fixing it by bumping version
/* from 9.2-2 to 9.2-4 see #3673 for details */ -- from 9.2-2 to 9.2-4 see #3673 for details

View File

@ -1,6 +1,6 @@
/* citus--9.2-4--9.3-2 */ -- citus--9.2-4--9.3-2
/* bump version to 9.3-2 */ -- bump version to 9.3-2
#include "udfs/citus_extradata_container/9.3-2.sql" #include "udfs/citus_extradata_container/9.3-2.sql"
#include "udfs/update_distributed_table_colocation/9.3-2.sql" #include "udfs/update_distributed_table_colocation/9.3-2.sql"

View File

@ -1,10 +1,10 @@
/* citus--9.3-1--9.2-4 */ -- citus--9.3-1--9.2-4
/* this is an unusual upgrade path, we are doing it because */ -- this is an unusual upgrade path, we are doing it because
/* we have accidentally tagged master branch with v9.2-3 */ -- we have accidentally tagged master branch with v9.2-3
/* however master branch was already bumped to v9.3-1 */ -- however master branch was already bumped to v9.3-1
/* with this file, we are undoing the catalog changes that */ -- with this file, we are undoing the catalog changes that
/* have happened between 9.2-2 to 9.3-1, and making 9.2-4 */ -- have happened between 9.2-2 to 9.3-1, and making 9.2-4
/* as the release that we can */ -- as the release that we can
-- undo the changes for citus_extradata_container that happened on citus 9.3 -- undo the changes for citus_extradata_container that happened on citus 9.3
DROP FUNCTION IF EXISTS pg_catalog.citus_extradata_container(INTERNAL); DROP FUNCTION IF EXISTS pg_catalog.citus_extradata_container(INTERNAL);