Skip to content

Add upstream push protection to go-upgrade script - #4659

Open
aravindtga wants to merge 2 commits into
kptdev:mainfrom
Nordix:go-upgrade-upstream-push-protection
Open

Add upstream push protection to go-upgrade script#4659
aravindtga wants to merge 2 commits into
kptdev:mainfrom
Nordix:go-upgrade-upstream-push-protection

Conversation

@aravindtga

Copy link
Copy Markdown
Contributor

Description

  • What changed: Added a safety check in the go-upgrade push flow that blocks pushing branches when FORK_OWNER is set to kptdev (upstream org), preventing accidental modifications to upstream repositories.
  • Why it's needed: If someone configures 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.
  • How it works: Before git push in cmd_push(), the script checks if FORK_OWNER == "kptdev". If so, it refuses to push and records a failure unless --force is passed.

Changes

  • scripts/go-upgrade/lib/push.sh: Added upstream protection check before git push
  • scripts/go-upgrade/upgrade.sh: Added FORCE option variable, --force|-f arg parsing, usage text, and startup logging
  • scripts/go-upgrade/README.md: Updated Options table and Fork Owner section with protection docs and examples

AI Disclosure

  • I have used AI in the creation of this PR.

Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@aravindtga
aravindtga requested a review from Copilot July 23, 2026 11:11
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit cd3a84e
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a61fb9da126670008af0712
😎 Deploy Preview https://deploy-preview-4659--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/-f option parsing and logging in upgrade.sh.
  • Add an upstream push protection check in lib/push.sh before performing git 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.

Comment thread scripts/go-upgrade/lib/push.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sed extraction for the repo name assumes the remote URL ends with .git. If origin_url is configured without the suffix (common for HTTPS remotes), this will produce an invalid origin_repo and break PR creation/logging. Make the .git suffix optional when extracting the repo name.
    local origin_repo="${origin_owner}/$(echo "$origin_url" | sed -E 's|.*[:/][^/]+/([^/]+)\.git$|\1|')"

Comment thread scripts/go-upgrade/lib/push.sh Outdated
Signed-off-by: Aravindhan Ayyanathan <aravindhan.a@est.tech>
@aravindtga
aravindtga force-pushed the go-upgrade-upstream-push-protection branch from bc2ba58 to cd3a84e Compare July 23, 2026 11:31
@aravindtga
aravindtga requested a review from Copilot July 23, 2026 11:31
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@aravindtga
aravindtga marked this pull request as ready for review July 23, 2026 11:36
@aravindtga
aravindtga requested review from a team July 23, 2026 11:36
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area/devops labels Jul 23, 2026
@dosubot dosubot Bot added the lgtm label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/devops lgtm size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants