Skip to content

Commit 15a577c

Browse files
Add cherry-picker documentation (#44118)
--------- Co-authored-by: GPK <[email protected]>
1 parent abc97ed commit 15a577c

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

dev/README_AIRFLOW3_DEV.md

+82
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
- [Committers / PMCs](#committers--pmcs)
3131
- [Merging PRs for providers and Helm chart](#merging-prs-for-providers-and-helm-chart)
3232
- [Merging PR for Airflow 3 and 2.10.x / 2.11.x](#merging-pr-for-airflow-3-and-210x--211x)
33+
- [How to backport PR with GitHub Actions](#how-to-backport-pr-with-github-actions)
34+
- [How to backport PR with `cherry-picker` CLI](#how-to-backport-pr-with-cherry-picker-cli)
3335
- [Merging PRs 2.10.x](#merging-prs-210x)
3436
- [Merging PRs for Airflow 3](#merging-prs-for-airflow-3)
3537
- [Merging PRs for Airflow 2.11](#merging-prs-for-airflow-211)
@@ -122,6 +124,86 @@ Mistakes happen, and such backport PR work might fall through cracks. Therefore,
122124

123125
This way release manager can verify (as usual) if all the "expected" PRs have been backported and cherry-pick remaining PRS.
124126

127+
128+
We are using `cherry-picker` - a [tool](https://github.com/python/cherry-picker) that has been developed by
129+
Python developers. It allows to easily cherry-pick PRs from one branch to another. It works both - via
130+
command line and via GitHub Actions interface.
131+
132+
## How to backport PR with GitHub Actions
133+
134+
When you want to backport commit via GitHub actions (you need to be a committer), you
135+
should use "Backport commit" action. You need to know the commit hash of the commit you want to backport.
136+
You can pin the workflow from the list of workflows for easy access to it.
137+
138+
[!NOTE]
139+
It should be the commit hash of the commit in the `main` branch, not in the original PR - you can find it
140+
via `git log` or looking up main History.
141+
142+
![Backport commit](images/backport_commit_action.png)
143+
144+
Use `main` as source of the workflow and copy the commit hash and enter the target branch name
145+
(e.g. `v2-10-test`).
146+
147+
The action should create a new PR with the cherry-picked commit and add a comment in the PR when it is
148+
successful (or when it fails). If automatic backporting fails because of conflicts, you have to revert to
149+
manual backporting using `cherry-picker` CLI.
150+
151+
## How to backport PR with `cherry-picker` CLI
152+
153+
Backporting via CLI might be more convenient for some users. Also it is necessary if you want to backport
154+
PR that has conflicts. It also allows to backport commit to multiple branches in the same command.
155+
156+
To backport PRs to any branch (for example v2-10-test), you can use the following command:
157+
158+
It's easiest to install it (and keep cherry-picker up-to-date) using `uv tool`:
159+
160+
```bash
161+
uv tool install cherry-picker
162+
````
163+
164+
And upgrade it with:
165+
166+
```bash
167+
uv tool upgrade cherry-picker
168+
```
169+
170+
Then, in order to backport a commit to a branch, you can use the following command:
171+
172+
```bash
173+
cherry-picker COMMIT_SHA BRANCH_NAME1 [BRANCH_NAME2 ...]
174+
```
175+
176+
This will create a new branch with the cherry-picked commit and open a PR against the target branch in
177+
your browser.
178+
179+
If the GH_AUTH environment variable is set in your command line, the cherry-picker automatically creates a new pull request when there are no conflicts. To set GH_AUTH, use the token from your GitHub repository.
180+
181+
To set GH_AUTH run this:
182+
183+
```bash
184+
export GH_AUTH={token}
185+
Sometimes it might result with conflict. In such case, you should manually resolve the conflicts.
186+
Some IDEs like IntelliJ has a fantastic conflict resolution tool - just follow `Git -> Resolve conflicts`
187+
menu after you get the conflict. But you can also resolve the conflicts manually (git adds `<<<<<<<`, `=======` and
188+
`>>>>>>>` markers to the files with conflicts).
189+
190+
```bash
191+
cherry_picker --status # Should show if all conflicts are resolved
192+
cherry_picker --continue # Should continue cherry-picking process
193+
```
194+
195+
> [!WARNING]
196+
> Sometimes, when you stop cherry-picking process in the middle, you might end up with your repo in a bad
197+
> state and cherry-picker might print this message:
198+
>
199+
> > 🐍 🍒 ⛏
200+
> >
201+
> > You're not inside a cpython repo right now! 🙅
202+
>
203+
> You should then run `cherry-picker --abort` to clean up the mess and start over. If that does not work
204+
> you might need to run `git config --local --remove-section cherry-picker` to clean up the configuration
205+
> stored in `.git/config`.
206+
125207
## Merging PRs 2.10.x
126208
127209
Make sure PR targets `v2-10-test` branch and merge it when ready.

dev/images/backport_commit_action.png

289 KB
Loading

0 commit comments

Comments
 (0)