You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✨ (alpha update): easier commits, safer defaults, more control (#5013)
chore: improve alpha update with clearer commits, safer defaults, and more control
- clearer commit messages (e.g. "(chore) scaffold from release vX.Y.Z")
- better error reporting with actionable context
- automatic cleanup of temporary branches
- predictable output always on the output branch
- simpler history by default (squash), with --show-commits for full history
- explicit push control (nothing pushed unless --push)
- refactored code for maintainability and updated docs
Assisted-by: ChatGPT (OpenAI)
Co-authored-by: Vitor Floriano <[email protected]>
Copy file name to clipboardExpand all lines: docs/book/src/reference/commands/alpha_update.md
+93-94Lines changed: 93 additions & 94 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,25 +2,12 @@
2
2
3
3
## Overview
4
4
5
-
`kubebuilder alpha update` upgrades your project’s scaffold to a newer scaffold version.
5
+
`kubebuilder alpha update` upgrades your project’s scaffold to a newer Kubebuilder release using a **3-way Git merge**. It rebuilds clean scaffolds for the old and new versions, merges your current code into the new scaffold, and gives you a reviewable output branch.
6
+
It takes care of the heavy lifting so you can focus on reviewing and resolving conflicts,
7
+
not re-applying your code.
6
8
7
-
It uses a **3-way merge** so you do less manual work. The command creates these branches:
8
-
9
-
-**Ancestor**: clean scaffold from the **old** version
10
-
-**Original**: your current project (from your base branch)
11
-
-**Upgrade**: clean scaffold from the **new** version
12
-
-**Merge**: result of merging **Original** into **Upgrade** (this is where conflicts appear)
13
-
14
-
You can review and test the merge result before applying it to your main branch.
15
-
Optionally, use **`--squash`** to put the merge result into **one commit** on a stable output branch (great for PRs).
16
-
17
-
<asideclass="note warning">
18
-
<h1>Creates branches and deletes files</h1>
19
-
20
-
This command creates branches like `tmp-kb-update-*` and removes files during the process.
21
-
Make sure your work is committed before you run it.
22
-
23
-
</aside>
9
+
By default, the final result is **squashed into a single commit** on a dedicated output branch.
10
+
If you prefer to keep the full history (no squash), use `--show-commits`.
24
11
25
12
## When to Use It
26
13
@@ -33,26 +20,45 @@ Use this command when you:
33
20
34
21
## How It Works
35
22
36
-
1.**Detect versions**
37
-
Reads `--from-version` (or the `PROJECT` file) and `--to-version` (or uses the latest).
38
-
39
-
2.**Create branches & re-scaffold**
40
-
-`tmp-ancestor-*`: clean scaffold from **from-version**
41
-
-`tmp-original-*`: snapshot of your **from-branch** (e.g., `main`)
42
-
-`tmp-upgrade-*`: clean scaffold from **to-version**
43
-
44
-
3.**3-way merge**
45
-
Creates `tmp-merge-*` from **Upgrade** and merges **Original** into it.
46
-
Runs `make manifests generate fmt vet lint-fix` to normalise outputs.
47
-
Runs `make manifests generate fmt vet lint-fix` to normalize outputs.
48
-
49
-
4.**(Optional) Squash**
50
-
With `--squash`, copies the merge result to a stable output branch and commits **once**:
|`--from-version`| Kubebuilder release to update **from** (e.g., `v4.6.0`). If unset, read from the `PROJECT` file when possible. |
140
+
|`--to-version`| Kubebuilder release to update **to** (e.g., `v4.7.0`). If unset, defaults to the latest available release. |
141
+
|`--from-branch`| Git branch that holds your current project code. Defaults to `main`. |
142
+
|`--force`| Continue even if merge conflicts happen. Conflicted files are committed with conflict markers (CI/cron friendly). |
143
+
|`--show-commits`| Keep full history (do not squash). **Not compatible** with `--preserve-path`. |
144
+
|`--preserve-path`| Repeatable. **Squash mode only.** After copying the merge tree to the output branch, restore these paths from the base branch (e.g., `.github/workflows`). |
145
+
|`--output-branch`| Name of the output branch. Default: `kubebuilder-update-from-<from-version>-to-<to-version>`. |
146
+
|`--push`| Push the output branch to the `origin` remote after the update completes. |
147
+
|`-h, --help`| Show help for this command. |
117
148
118
149
<asideclass="note warning">
119
150
<h1>You might need to upgrade your project first</h1>
@@ -133,51 +164,19 @@ We use that value to pick the correct CLI for re-scaffolding.
133
164
134
165
</aside>
135
166
136
-
<asideclass="note warning">
137
-
You must resolve these conflicts before merging into `main` (or your base branch).
0 commit comments