File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+ import re
3+
4+ # sort column lines in a psql schema dump alphabetically
5+ def sort_columns (match ):
6+ lines = [
7+ line .strip ().rstrip (',' )
8+ for line in match .group (1 ).split ('\n ' )
9+ if line .strip ()
10+ ]
11+ return '(\n ' + ',\n ' .join (sorted (lines )) + '\n )'
12+
13+ text = sys .stdin .read ()
14+ sys .stdout .write (re .sub (r'\(((?:\n [^\n]+)+)\n\)' , sort_columns , text ))
Original file line number Diff line number Diff line change @@ -175,8 +175,8 @@ jobs:
175175 run : |
176176 pg_dump -U dirigent -h localhost dirigent \
177177 --schema-only --no-comments --no-privileges --no-owner \
178- | grep -vE '^(SET |SELECT |GRANT |REVOKE |\\| $)' \
179- | sort \
178+ | grep -vE '^(SET |SELECT |$)' \
179+ | python3 .github/scripts/normalize-psql-schema.py \
180180 > /tmp/schema_baseline.sql
181181 pg_dump -U dirigent -h localhost dirigent \
182182 --data-only --no-comments --no-privileges --no-owner \
@@ -206,8 +206,8 @@ jobs:
206206 run : |
207207 pg_dump -U dirigent -h localhost dirigent \
208208 --schema-only --no-comments --no-privileges --no-owner \
209- | grep -vE '^(SET |SELECT |GRANT |REVOKE |\\| $)' \
210- | sort \
209+ | grep -vE '^(SET |SELECT |$)' \
210+ | python3 .github/scripts/normalize-psql-schema.py \
211211 > /tmp/schema_reverted.sql
212212 pg_dump -U dirigent -h localhost dirigent \
213213 --data-only --no-comments --no-privileges --no-owner \
You can’t perform that action at this time.
0 commit comments