-
Notifications
You must be signed in to change notification settings - Fork 45
Task/code indent #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Task/code indent #344
Conversation
The gen-typedefs.sh script accumulated duplicates on each run because it only appended to typedefs.list. Fixed by: - Uncommenting curl to fetch fresh PostgreSQL typedefs (overwrites file) - Adding sort/uniq to remove any internal duplicates - Cleaning up typedefs.list Sorting allow us to stabilise the content in case a struct or enum has been displaced. This ensures repeated script runs produce consistent, deduplicated output.
Automatically validates code formatting on PRs to main branch using pgindent. Builds pg_bsd_indent from PostgreSQL source, runs gen-typedefs.sh, and fails if formatting issues are detected.
Better name reflects the script's actual purpose: running pgindent on all source files. Updated README and GitHub workflow accordingly.
- Run pgindent to standardize code formatting
📝 WalkthroughWalkthroughThe PR introduces a GitHub Actions pgindent workflow, updates the pgindent automation tooling, refactors header files to use named typedefs, expands the try_resolve_conflict function signature with additional parameters, and applies comprehensive whitespace and formatting adjustments throughout the codebase. Changes
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
🤖 Fix all issues with AI agents
In @.github/workflows/pgindent-check.yml:
- Around line 47-53: The CI step named "Check for formatting changes" currently
echoes "Please run gen-typedefs.sh locally" when git diff shows changes; update
that message to reference the correct script name `run-pgindent.sh` so
developers run the right formatter. Locate the block containing the name "Check
for formatting changes" and the `if ! git diff --quiet; then` check and replace
the echo text to "Please run run-pgindent.sh locally" (or include both commands
if applicable) to avoid confusion.
- Around line 30-39: Remove the dead PATH entry and pin the cloned PostgreSQL
ref: stop appending "$GITHUB_WORKSPACE/pg-install/bin" to GITHUB_PATH (it's
never created), and either change that echo to point to the actual install
prefix (/tmp/pg-build/bin) *or* run `make install` into /tmp/pg-build so the
directory exists; additionally replace the git clone --branch master with a
specific stable tag (for example REL_17_STABLE) to ensure reproducible builds
and stable pg_bsd_indent behavior.
In `@include/spock_conflict.h`:
- Line 85: The function declaration ending with "RepOriginId * local_origin,
TimestampTz *local_ts" uses incorrect spacing for the pointer parameter; change
it to "RepOriginId *local_origin" to match pgindent standard and the typedefs
list in src/spock_conflict.c, and update any other matching declarations in
include/spock_conflict.h to remove the space between '*' and the parameter name
(e.g., for local_origin) so the header matches the .c file style.
- Around line 79-81: Duplicate extern declarations of spock_conflict_resolver,
spock_conflict_log_level, and spock_save_resolutions exist; remove the redundant
declarations and keep the original ones. Locate the repeated extern declarations
for the symbols spock_conflict_resolver, spock_conflict_log_level, and
spock_save_resolutions (the duplicates around lines 79–81) and delete them so
only the original declarations (the ones around lines 42–44) remain.
In `@src/spock_conflict.c`:
- Line 182: The pgindent run is treating "RepOriginId" as a non-typedef
(producing pointer spacing "RepOriginId * local_origin"); add RepOriginId to the
typedefs list used by pgindent so it is recognized as a core typedef. Modify
utils/pgindent/run-pgindent.sh to include RepOriginId when fetching/combining
core typedefs from the buildfarm (or add it explicitly to the extraction list),
ensuring the combined typedefs file used by pgindent contains "RepOriginId" so
functions like the one declaring RepOriginId * local_origin are formatted
correctly.
In `@utils/pgindent/README.md`:
- Around line 10-12: The fenced code block containing "make install
prefix=/usr/local" is missing a language specifier (MD040); update that fenced
block by adding a shell language identifier (e.g., ```sh or ```bash) immediately
after the opening triple backticks so the block becomes a shell code block and
satisfies markdownlint.
In `@utils/pgindent/run-pgindent.sh`:
- Around line 1-16: Add strict error handling and make the remote fetch
fail-safe: at script start enable safe-fail flags (e.g., set -euo pipefail or at
minimum set -e) so any failing command (grep/awk/sort/xargs) aborts; change the
curl invocation to use fail-and-quiet flags and write to the file atomically
(e.g., curl -fsS -o typedefs.list <URL>) and immediately check its exit status
and/or that typedefs.list is non-empty and exit with a clear error if the fetch
failed; ensure the pipeline commands (grep/awk/sort/xargs) run under the same
failure semantics so a failed grep/awk or xargs won’t silently produce a bad
typedefs.list.
🧹 Nitpick comments (6)
src/spock_functions.c (3)
2236-2264: Consider usingcastNode()for consistency with the rest of the switch.Other cases in this switch (e.g.,
AlterOwnerStmt,RenameStmt,CreateTableAsStmt) usecastNode(), which provides a runtime assertion in debug builds. The C-style cast(ClusterStmt *) stmton Line 2238 works but is inconsistent. Same applies to(ReindexStmt *)on Line 2292.♻️ Suggested change
- ClusterStmt *cstmt = (ClusterStmt *) stmt; + ClusterStmt *cstmt = castNode(ClusterStmt, stmt);
2290-2307: SamecastNodeinconsistency as above.♻️ Suggested change
- ReindexStmt *rstmt = (ReindexStmt *) stmt; + ReindexStmt *rstmt = castNode(ReindexStmt, stmt);
3499-3500:valuesarray is not zero-initialized whilenullsis.This is fine here since every index in
_GP_LAST_is explicitly assigned in the code below (either invalues[...]or guarded bynulls[...] = true), andtuplestore_putvaluesignores values for null columns. Just flagging for awareness — if a newGP_*enum member is added later without a corresponding assignment,valueswould contain garbage for that column.src/spock_autoddl.c (1)
225-232: Blank line betweenifand its body harms readability.The blank line at Line 227 between
if (targetrel == NULL)and the comment+returnmakes it visually ambiguous whether thereturnis controlled by theif. Without braces, a reader may think theifbody is empty and thereturnis unconditional.Consider wrapping in braces to make the intent clear:
Suggested fix
- targetrel = table_openrv_extended(relation, AccessShareLock, missing_ok); - if (targetrel == NULL) - - /* - * If relation doesn't exist - quietly exit. It is assumed that - * the core already produced an INFO message. - */ - return; + targetrel = table_openrv_extended(relation, AccessShareLock, missing_ok); + if (targetrel == NULL) + { + /* + * If relation doesn't exist - quietly exit. It is assumed that + * the core already produced an INFO message. + */ + return; + }src/spock_group.c (1)
423-429: Same blank-line-before-body pattern as inspock_autoddl.c.Line 424 has a blank line between
elseand its controlled statement (theelog(ERROR, ...)), with a comment block in between. This is syntactically valid but visually suggests theelsebody is empty. Consider adding braces for clarity, consistent with the suggestion inspock_autoddl.c..github/workflows/pgindent-check.yml (1)
31-39: Quote shell variables to prevent globbing and word splitting.Per static analysis (shellcheck SC2086),
$GITHUB_WORKSPACEand$GITHUB_PATHshould be double-quoted on Lines 37–39.Suggested fix
- echo "$GITHUB_WORKSPACE/pg-install/bin" >> $GITHUB_PATH - echo "/tmp/postgresql/src/tools/pgindent" >> $GITHUB_PATH - echo "/tmp/postgresql/src/tools/pg_bsd_indent" >> $GITHUB_PATH + echo "$GITHUB_WORKSPACE/pg-install/bin" >> "$GITHUB_PATH" + echo "/tmp/postgresql/src/tools/pgindent" >> "$GITHUB_PATH" + echo "/tmp/postgresql/src/tools/pg_bsd_indent" >> "$GITHUB_PATH"
| - name: Clone and build pg_bsd_indent | ||
| run: | | ||
| git clone https://git.postgresql.org/git/postgresql.git --depth 1 --branch master /tmp/postgresql | ||
| cd /tmp/postgresql | ||
| ./configure --prefix=/tmp/pg-build > /dev/null | ||
| cd src/tools/pg_bsd_indent | ||
| make > /dev/null | ||
| echo "$GITHUB_WORKSPACE/pg-install/bin" >> $GITHUB_PATH | ||
| echo "/tmp/postgresql/src/tools/pgindent" >> $GITHUB_PATH | ||
| echo "/tmp/postgresql/src/tools/pg_bsd_indent" >> $GITHUB_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused PATH entry and reproducibility concern.
-
Line 37 adds
$GITHUB_WORKSPACE/pg-install/bintoPATH, but this directory is never created — the./configure --prefixon Line 34 uses/tmp/pg-buildand nomake installis run. This line is dead configuration. -
Cloning PostgreSQL
master(Line 32) meanspg_bsd_indentbehavior and the buildfarm typedef list can change between runs, making builds non-reproducible. Consider pinning to a specific PostgreSQL release tag (e.g.,REL_17_STABLE).
Suggested fix
- git clone https://git.postgresql.org/git/postgresql.git --depth 1 --branch master /tmp/postgresql
+ git clone https://git.postgresql.org/git/postgresql.git --depth 1 --branch REL_17_STABLE /tmp/postgresql
cd /tmp/postgresql
./configure --prefix=/tmp/pg-build > /dev/null
cd src/tools/pg_bsd_indent
make > /dev/null
- echo "$GITHUB_WORKSPACE/pg-install/bin" >> $GITHUB_PATH
echo "/tmp/postgresql/src/tools/pgindent" >> $GITHUB_PATH
echo "/tmp/postgresql/src/tools/pg_bsd_indent" >> $GITHUB_PATH🧰 Tools
🪛 actionlint (1.7.10)
[error] 31-31: shellcheck reported issue in this script: SC2086:info:6:44: Double quote to prevent globbing and word splitting
(shellcheck)
[error] 31-31: shellcheck reported issue in this script: SC2086:info:7:46: Double quote to prevent globbing and word splitting
(shellcheck)
[error] 31-31: shellcheck reported issue in this script: SC2086:info:8:51: Double quote to prevent globbing and word splitting
(shellcheck)
[error] 31-31: shellcheck reported issue in this script: SC2129:style:6:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects
(shellcheck)
🤖 Prompt for AI Agents
In @.github/workflows/pgindent-check.yml around lines 30 - 39, Remove the dead
PATH entry and pin the cloned PostgreSQL ref: stop appending
"$GITHUB_WORKSPACE/pg-install/bin" to GITHUB_PATH (it's never created), and
either change that echo to point to the actual install prefix
(/tmp/pg-build/bin) *or* run `make install` into /tmp/pg-build so the directory
exists; additionally replace the git clone --branch master with a specific
stable tag (for example REL_17_STABLE) to ensure reproducible builds and stable
pg_bsd_indent behavior.
| - name: Check for formatting changes | ||
| run: | | ||
| if ! git diff --quiet; then | ||
| echo "::error::Code formatting issues detected. Please run gen-typedefs.sh locally." | ||
| git diff | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message references wrong script name.
Line 50 tells developers to "run gen-typedefs.sh locally" but the formatting script is run-pgindent.sh. This will confuse developers who try to fix formatting issues.
Suggested fix
- echo "::error::Code formatting issues detected. Please run gen-typedefs.sh locally."
+ echo "::error::Code formatting issues detected. Please run utils/pgindent/run-pgindent.sh locally."📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - name: Check for formatting changes | |
| run: | | |
| if ! git diff --quiet; then | |
| echo "::error::Code formatting issues detected. Please run gen-typedefs.sh locally." | |
| git diff | |
| exit 1 | |
| fi | |
| - name: Check for formatting changes | |
| run: | | |
| if ! git diff --quiet; then | |
| echo "::error::Code formatting issues detected. Please run utils/pgindent/run-pgindent.sh locally." | |
| git diff | |
| exit 1 | |
| fi |
🤖 Prompt for AI Agents
In @.github/workflows/pgindent-check.yml around lines 47 - 53, The CI step named
"Check for formatting changes" currently echoes "Please run gen-typedefs.sh
locally" when git diff shows changes; update that message to reference the
correct script name `run-pgindent.sh` so developers run the right formatter.
Locate the block containing the name "Check for formatting changes" and the `if
! git diff --quiet; then` check and replace the echo text to "Please run
run-pgindent.sh locally" (or include both commands if applicable) to avoid
confusion.
| extern int spock_conflict_resolver; | ||
| extern int spock_conflict_log_level; | ||
| extern bool spock_save_resolutions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate extern declarations — these are already declared on lines 42–44.
Lines 79–81 re-declare spock_conflict_resolver, spock_conflict_log_level, and spock_save_resolutions, which are already declared identically on lines 42–44. While C permits duplicate compatible extern declarations, this is clearly unintentional duplication and should be removed.
Proposed fix — remove the duplicates
-extern int spock_conflict_resolver;
-extern int spock_conflict_log_level;
-extern bool spock_save_resolutions;
-
extern bool get_tuple_origin(SpockRelation *rel, HeapTuple local_tuple,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| extern int spock_conflict_resolver; | |
| extern int spock_conflict_log_level; | |
| extern bool spock_save_resolutions; |
🤖 Prompt for AI Agents
In `@include/spock_conflict.h` around lines 79 - 81, Duplicate extern declarations
of spock_conflict_resolver, spock_conflict_log_level, and spock_save_resolutions
exist; remove the redundant declarations and keep the original ones. Locate the
repeated extern declarations for the symbols spock_conflict_resolver,
spock_conflict_log_level, and spock_save_resolutions (the duplicates around
lines 79–81) and delete them so only the original declarations (the ones around
lines 42–44) remain.
| extern bool get_tuple_origin(SpockRelation *rel, HeapTuple local_tuple, | ||
| ItemPointer tid, TransactionId *xmin, | ||
| RepOriginId *local_origin, TimestampTz *local_ts); | ||
| RepOriginId * local_origin, TimestampTz *local_ts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same RepOriginId * local_origin pointer spacing issue as in the .c file.
This should match the pgindent-standard RepOriginId *local_origin (no space between * and parameter name). See my comment on src/spock_conflict.c line 182 regarding the typedefs list.
🤖 Prompt for AI Agents
In `@include/spock_conflict.h` at line 85, The function declaration ending with
"RepOriginId * local_origin, TimestampTz *local_ts" uses incorrect spacing for
the pointer parameter; change it to "RepOriginId *local_origin" to match
pgindent standard and the typedefs list in src/spock_conflict.c, and update any
other matching declarations in include/spock_conflict.h to remove the space
between '*' and the parameter name (e.g., for local_origin) so the header
matches the .c file style.
| get_tuple_origin(SpockRelation *rel, HeapTuple local_tuple, ItemPointer tid, | ||
| TransactionId *xmin, | ||
| RepOriginId *local_origin, TimestampTz *local_ts) | ||
| RepOriginId * local_origin, TimestampTz *local_ts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Check the actual line 182 in src/spock_conflict.c
head -185 src/spock_conflict.c | tail -10Repository: pgEdge/spock
Length of output: 372
🏁 Script executed:
# Search for typedefs files in pgindent utilities
find . -name "*typedefs*" -o -name "run-pgindent*" | head -20Repository: pgEdge/spock
Length of output: 119
🏁 Script executed:
# Check if RepOriginId exists in the codebase and see its definition
rg "typedef.*RepOriginId" --type cRepository: pgEdge/spock
Length of output: 38
🏁 Script executed:
# Check if RepOriginId is in the typedefs list
grep -n "RepOriginId" ./utils/pgindent/typedefs.listRepository: pgEdge/spock
Length of output: 38
🏁 Script executed:
# Read the run-pgindent.sh script to understand how it works
cat ./utils/pgindent/run-pgindent.shRepository: pgEdge/spock
Length of output: 830
🏁 Script executed:
# Search for RepOriginId definition in the codebase (broader search)
rg "RepOriginId" -B 2 -A 2 | head -50Repository: pgEdge/spock
Length of output: 2354
🏁 Script executed:
# Search for RepOriginId definition in header files
rg "typedef.*RepOriginId|#define.*RepOriginId" -t c -t hRepository: pgEdge/spock
Length of output: 38
🏁 Script executed:
# Search for RepOriginId in include files
find . -name "*.h" -type f -exec grep -l "RepOriginId" {} \;Repository: pgEdge/spock
Length of output: 203
🏁 Script executed:
# Check if RepOriginId comes from PostgreSQL server includes
rg "RepOriginId" -t h | grep -i include | head -10Repository: pgEdge/spock
Length of output: 751
🏁 Script executed:
# Search for includes of PostgreSQL replication headers
rg "#include" -t c -t h | grep -i "origin\|replication" | head -20Repository: pgEdge/spock
Length of output: 1221
🏁 Script executed:
# Check if there are any comments or notes about RepOriginId in the spock code
rg "RepOriginId" -B 3 -A 1 | grep -i "from pg\|postgresql\|core\|origin" | head -20Repository: pgEdge/spock
Length of output: 1272
🏁 Script executed:
# Look at the actual include directives in spock_conflict.h
head -50 ./include/spock_conflict.hRepository: pgEdge/spock
Length of output: 1372
🏁 Script executed:
# Verify the actual current typedefs.list content to confirm RepOriginId absence
wc -l ./utils/pgindent/typedefs.list && echo "---" && head -20 ./utils/pgindent/typedefs.list && echo "---" && grep -c "^" ./utils/pgindent/typedefs.listRepository: pgEdge/spock
Length of output: 288
🏁 Script executed:
# Check if there are any comments in run-pgindent.sh about known issues or PG version specifics
cat ./utils/pgindent/run-pgindent.sh | grep -i "version\|todo\|fixme\|note"Repository: pgEdge/spock
Length of output: 38
🏁 Script executed:
# Double-check by searching for RepOriginId in the typedefs.list one more time to be absolutely certain
grep "RepOriginId" ./utils/pgindent/typedefs.listRepository: pgEdge/spock
Length of output: 38
RepOriginId missing from pgindent typedefs list
The pointer spacing RepOriginId * local_origin indicates that RepOriginId is not recognized as a typedef by pgindent. This type is a PostgreSQL core type from replication/origin.h and should appear in the combined typedefs list used by pgindent.
Update utils/pgindent/run-pgindent.sh to ensure RepOriginId is included when fetching core typedefs from the PostgreSQL buildfarm, or explicitly add it to the typedefs extraction if it's not being pulled automatically.
🤖 Prompt for AI Agents
In `@src/spock_conflict.c` at line 182, The pgindent run is treating "RepOriginId"
as a non-typedef (producing pointer spacing "RepOriginId * local_origin"); add
RepOriginId to the typedefs list used by pgindent so it is recognized as a core
typedef. Modify utils/pgindent/run-pgindent.sh to include RepOriginId when
fetching/combining core typedefs from the buildfarm (or add it explicitly to the
extraction list), ensuring the combined typedefs file used by pgindent contains
"RepOriginId" so functions like the one declaring RepOriginId * local_origin are
formatted correctly.
| ``` | ||
| make install prefix=/usr/local | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a language specifier to the fenced code block.
The fenced code block lacks a language identifier, which is flagged by markdownlint (MD040). Since this is a shell command, use sh or bash.
Proposed fix
- ```
+ ```sh
make install prefix=/usr/local
```📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ``` | |
| make install prefix=/usr/local | |
| ``` |
🧰 Tools
🪛 markdownlint-cli2 (0.20.0)
[warning] 10-10: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
In `@utils/pgindent/README.md` around lines 10 - 12, The fenced code block
containing "make install prefix=/usr/local" is missing a language specifier
(MD040); update that fenced block by adding a shell language identifier (e.g.,
```sh or ```bash) immediately after the opening triple backticks so the block
becomes a shell code block and satisfies markdownlint.
| #!/bin/bash | ||
|
|
||
| #curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list | ||
| # Fetch PostgreSQL core typedefs from buildfarm | ||
| curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list | ||
|
|
||
| # Extract Spock-specific typedefs from source code and append them | ||
| grep -nri "typedef struct" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | ||
| grep -nri "typedef enum" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | ||
| grep -nri "typedef union" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | ||
|
|
||
| # Remove duplicates and sort | ||
| sort typedefs.list | uniq > typedefs.list.tmp && mv typedefs.list.tmp typedefs.list | ||
|
|
||
| find ../../ -type f \( -name "*.c" -o -name "*.h" \) -print0 \ | ||
| | xargs -0 pgindent --typedefs typedefs.list | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling to the script.
- The
curlon Line 4 lacks-f(fail on HTTP error) and-sSflags. If the buildfarm is unreachable or returns an error page, the HTML will be written totypedefs.list, corrupting pgindent's input silently. - No
set -emeans grep/awk failures are silently ignored.
Suggested fix
#!/bin/bash
+set -euo pipefail
# Fetch PostgreSQL core typedefs from buildfarm
-curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list
+curl -fsSL https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #!/bin/bash | |
| #curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list | |
| # Fetch PostgreSQL core typedefs from buildfarm | |
| curl https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list | |
| # Extract Spock-specific typedefs from source code and append them | |
| grep -nri "typedef struct" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | |
| grep -nri "typedef enum" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | |
| grep -nri "typedef union" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | |
| # Remove duplicates and sort | |
| sort typedefs.list | uniq > typedefs.list.tmp && mv typedefs.list.tmp typedefs.list | |
| find ../../ -type f \( -name "*.c" -o -name "*.h" \) -print0 \ | |
| | xargs -0 pgindent --typedefs typedefs.list | |
| #!/bin/bash | |
| set -euo pipefail | |
| # Fetch PostgreSQL core typedefs from buildfarm | |
| curl -fsSL https://buildfarm.postgresql.org/cgi-bin/typedefs.pl > typedefs.list | |
| # Extract Spock-specific typedefs from source code and append them | |
| grep -nri "typedef struct" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | |
| grep -nri "typedef enum" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | |
| grep -nri "typedef union" ../../ --include="*.c" --include="*.h" | grep -v "{" | awk '{print $3}' >> typedefs.list | |
| # Remove duplicates and sort | |
| sort typedefs.list | uniq > typedefs.list.tmp && mv typedefs.list.tmp typedefs.list | |
| find ../../ -type f \( -name "*.c" -o -name "*.h" \) -print0 \ | |
| | xargs -0 pgindent --typedefs typedefs.list | |
🤖 Prompt for AI Agents
In `@utils/pgindent/run-pgindent.sh` around lines 1 - 16, Add strict error
handling and make the remote fetch fail-safe: at script start enable safe-fail
flags (e.g., set -euo pipefail or at minimum set -e) so any failing command
(grep/awk/sort/xargs) aborts; change the curl invocation to use fail-and-quiet
flags and write to the file atomically (e.g., curl -fsS -o typedefs.list <URL>)
and immediately check its exit status and/or that typedefs.list is non-empty and
exit with a clear error if the fetch failed; ensure the pipeline commands
(grep/awk/sort/xargs) run under the same failure semantics so a failed grep/awk
or xargs won’t silently produce a bad typedefs.list.
No description provided.