Add upstream push protection to go-upgrade script - #4659
Conversation
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Adds a guardrail to the scripts/go-upgrade push flow to prevent accidental pushes to upstream (kptdev) repositories, with an explicit --force/-f override for intentional upstream pushes.
Changes:
- Introduce
--force/-foption parsing and logging inupgrade.sh. - Add an upstream push protection check in
lib/push.shbefore performinggit push. - Document the new option and behavior in
scripts/go-upgrade/README.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| scripts/go-upgrade/upgrade.sh | Adds FORCE flag, parses --force/-f, and logs when force mode is enabled. |
| scripts/go-upgrade/lib/push.sh | Blocks pushes when configured for upstream, unless force override is provided. |
| scripts/go-upgrade/README.md | Documents upstream push protection and --force/-f usage with examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
scripts/go-upgrade/lib/push.sh:164
- The
sedextraction for the repo name assumes the remote URL ends with.git. Iforigin_urlis configured without the suffix (common for HTTPS remotes), this will produce an invalidorigin_repoand break PR creation/logging. Make the.gitsuffix optional when extracting the repo name.
local origin_repo="${origin_owner}/$(echo "$origin_url" | sed -E 's|.*[:/][^/]+/([^/]+)\.git$|\1|')"
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
bc2ba58 to
cd3a84e
Compare
|



Description
go-upgradepush flow that blocks pushing branches whenFORK_OWNERis set tokptdev(upstream org), preventing accidental modifications to upstream repositories.FORK_OWNER=kptdev(intentionally or accidentally), the script would push branches directly to the upstream repos. This adds a guardrail with a--force(or-f) flag to override when intentional.git pushincmd_push(), the script checks ifFORK_OWNER == "kptdev". If so, it refuses to push and records a failure unless--forceis passed.Changes
scripts/go-upgrade/lib/push.sh: Added upstream protection check beforegit pushscripts/go-upgrade/upgrade.sh: AddedFORCEoption variable,--force|-farg parsing, usage text, and startup loggingscripts/go-upgrade/README.md: Updated Options table and Fork Owner section with protection docs and examplesAI Disclosure