Implementation:Apache Kafka Cherry Pick
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Development_Workflow, Version_Control |
| Last Updated | 2026-02-09 12:00 GMT |
Overview
Concrete tool for cherry-picking merge commits to release branches provided by the kafka-merge-pr script.
Description
The cherry_pick function takes a merge hash and applies it to a specified release branch. It fetches the remote branch, checks it out, performs git cherry-pick -sx with sign-off, and pushes the result. It prompts the user for the target branch and handles conflicts by pausing for manual resolution.
Usage
Called interactively after the squash merge step. The committer is prompted for each release branch to backport to.
Code Reference
Source Location
- Repository: Apache Kafka
- File: committer-tools/kafka-merge-pr.py
- Lines: L213-245
Signature
def cherry_pick(pr_num, merge_hash, default_branch):
"""
Cherry-picks the merge commit to a release branch.
Args:
pr_num: PR number
merge_hash: Hash from the squash merge
default_branch: Suggested target branch
Returns:
pick_ref: Reference string for the cherry-pick result
"""
Import
# Internal function in kafka-merge-pr.py
import subprocess
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| pr_num | str | Yes | PR number for reference |
| merge_hash | str | Yes | Merge commit hash to cherry-pick |
| default_branch | str | Yes | Suggested release branch |
Outputs
| Name | Type | Description |
|---|---|---|
| pick_ref | str | Reference string for the cherry-picked commit |
| Cherry-picked commit | git commit | Created on release branch with sign-off |
Usage Examples
# Called after merge_pr returns
pick_ref = cherry_pick(
pr_num="12345",
merge_hash="a1b2c3d4",
default_branch="3.7"
)
Related Pages
Implements Principle
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment