Skip to content

Fix check-upstream-sync to resolve its own repo, not the caller's cwd - #21

Open
jnasbyupgrade wants to merge 2 commits into
Postgres-Extensions:mainfrom
jnasbyupgrade:fix-sync-script-cwd
Open

Fix check-upstream-sync to resolve its own repo, not the caller's cwd#21
jnasbyupgrade wants to merge 2 commits into
Postgres-Extensions:mainfrom
jnasbyupgrade:fix-sync-script-cwd

Conversation

@jnasbyupgrade

Copy link
Copy Markdown
Contributor

check-upstream-sync resolved its remotes via git remote -v in the caller's working directory, but CLAUDE.md's own documented invocation runs it as ../ai/bin/check-upstream-sync from a consuming repo's root, where none of that repo's remotes point at Postgres-Extensions/ai — so the documented usage always failed with "no remote points at Postgres-Extensions/ai". The script now derives its repo root from its own path and passes it to every git call via -C, so it works the same regardless of the caller's cwd.

Also gives the check its own distinct error exit status (2) separate from "new commits found" (1), since a caller automating this couldn't previously tell a broken check from a permanent stream of unread content. CLAUDE.md's summary of the exit-code contract is updated to match.

The script located remotes via `git remote -v` in the caller's cwd,
but CLAUDE.md documents invoking it as `../ai/bin/check-upstream-sync`
from a consuming repo's root -- where none of that repo's remotes
point at Postgres-Extensions/ai, so the script always aborted. Derive
the repo root from the script's own path instead and pass it to every
git call via `-C`.

Also split what was a single non-zero exit status into two: 1 for new
commits found (with the list on stdout), 2 for the check itself
failing (message on stderr) -- so a caller can't mistake a broken
check for a permanent stream of new content.
The fetch and ls-remote calls ran unguarded under set -e, so a
network/TLS failure propagated git's own exit status (e.g. 128)
instead of the documented 2 -- the most likely real-world failure
mode wasn't actually covered by the exit-code contract. Capture their
output and check the result explicitly, same as the git-log call
already did, so any failure of the check itself lands on 2 with the
message on stderr.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: bdb55a55-e2ba-4e85-82f7-0177af6fbfad

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant