Skip to content

✨ alpha(update): add --squash, --preserve-path, --output-branch for PR-friendly upgrades #5002

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Aug 9, 2025

This change makes kubebuilder alpha update produce a PR-ready branch and a single squashed commit when requested, improving automation and review UX.

Key changes

• New --squash flag:

  • Snapshots the exact tree of the temporary merge branch into ONE commit on a stable branch: kubebuilder-alpha-update-to-<to-version>.
  • Intended for opening/refreshing idempotent PRs.
  • Gracefully handles "no changes" (git commit exits 1 → treated as no-op).

• New --preserve-path (repeatable):

  • When squashing, restore given paths from the base branch (e.g. .github/workflows) so CI/config files are kept as-is on the PR branch.

• New --output-branch:

  • Overrides the default PR branch name created by --squash.

• Commit message used by --squash:

  • [kubebuilder-automated-update]: update scaffold from <from> to <to>; (squashed 3-way merge)

• Behavior/ergonomics:

  • Without --force: stops on conflicts on the temporary merge branch.
  • With --force: commits conflict markers on the merge branch (automation-friendly).
  • After merge, still best-effort run: make manifests generate fmt vet lint-fix.

Defaults / Compatibility

  • --squash is off by default (no behavior change unless opted-in).
  • --from-branch defaults to main.
  • --preserve-path is empty by default (no restores).
  • Safe to run on projects scaffolded with v4.5.0+ (uses alpha generate).

Motivation

Make upgrades PR-centric and automation-ready by producing a deterministic, reviewable branch and a single squashed commit that mirrors the merge result.

Assisted-by: ChatGPT (OpenAI)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 9, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 9, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-more-options-alpha branch 2 times, most recently from 5e5b396 to e647ab5 Compare August 10, 2025 00:00
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 10, 2025
@camilamacedo86 camilamacedo86 force-pushed the add-more-options-alpha branch 2 times, most recently from 88cb831 to d986484 Compare August 10, 2025 01:13
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 10, 2025
…friendly upgrades

This change makes `kubebuilder alpha update` produce a PR-ready branch and a
single squashed commit when requested, improving automation and review UX.

Key changes
-----------
• New `--squash` flag:
  - Snapshots the exact tree of the temporary merge branch into ONE commit on a
    stable branch: `kubebuilder-alpha-update-to-<to-version>`.
  - Intended for opening/refreshing idempotent PRs.
  - Gracefully handles "no changes" (git commit exits 1 → treated as no-op).

• New `--preserve-path` (repeatable):
  - When squashing, restore given paths from the base branch (e.g.
    `.github/workflows`) so CI/config files are kept as-is on the PR branch.

• New `--output-branch`:
  - Overrides the default PR branch name created by `--squash`.

• Commit message used by `--squash`:
  - `[kubebuilder-automated-update]: update scaffold from <from> to <to>; (squashed 3-way merge)`

• Behavior/ergonomics:
  - Without `--force`: stops on conflicts on the temporary merge branch.
  - With `--force`: commits conflict markers on the merge branch (automation-friendly).
  - After merge, still best-effort run: `make manifests generate fmt vet lint-fix`.

Defaults / Compatibility
------------------------
  - `--squash` is off by default (no behavior change unless opted-in).
  - `--from-branch` defaults to `main`.
  - `--preserve-path` is empty by default (no restores).
  - Safe to run on projects scaffolded with v4.5.0+ (uses `alpha generate`).

Motivation
----------
Make upgrades PR-centric and automation-ready by producing a deterministic,
reviewable branch and a single squashed commit that mirrors the merge result.

Assisted-by: ChatGPT (OpenAI)

Co-authored-by: Vitor Floriano <[email protected]>
@camilamacedo86 camilamacedo86 force-pushed the add-more-options-alpha branch from d986484 to 0d40b9c Compare August 10, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants