Skip to content

Commit 5dfb933

Browse files
committed
Document how to import invalid patch series into patchable
1 parent d63f73d commit 5dfb933

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ cargo patchable export druid 26.0.0
7979
cargo patchable init druid 28.0.0 --upstream https://github.com/apache/druid.git --base druid-28.0.0
8080
```
8181

82+
### Importing patch series into Patchable
83+
84+
Patchable is stricter about applying invalid patches (both metadata and patches themselves) than Git is.
85+
86+
If an initial `cargo patchable checkout` fails then `git am` can be useful for the initial migration:
87+
88+
```sh
89+
# Create Patchable configuration for the new version, if it doesn't already exist
90+
cargo patchable init druid 30.0.0 --upstream https://github.com/apache/druid.git --base druid-30.0.0
91+
# Check out the upstream base commit, without trying to apply the patches
92+
pushd $(cargo patchable checkout druid 30.0.0 --base-only)
93+
94+
# Apply the patch series
95+
git am ../../../stackable/patches/30.0.0/*.patch
96+
# Resolve any conflicts that arise, and `git am --continue` until done
97+
98+
# Leave and export the new patch series!
99+
popd
100+
cargo patchable export druid 30.0.0
101+
```
102+
82103
### Porting patch series to a new version
83104

84105
Patchable doesn't support restoring a patch series that doesn't apply cleanly. Instead, use `git cherry-pick` to rebase the patch series.

rust/patchable/src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ enum Cmd {
118118
Checkout {
119119
#[clap(flatten)]
120120
pv: ProductVersion,
121+
122+
/// Check out the base commit, without applying patches
123+
#[clap(long)]
124+
base_only: bool,
121125
},
122126

123127
/// Export the patches from the source tree at docker-images/<PRODUCT>/patchable-work/worktree/<VERSION>
@@ -241,7 +245,7 @@ fn main() -> Result<()> {
241245
let images_repo = Repository::discover(".").context(FindImagesRepoSnafu)?;
242246
let images_repo_root = images_repo.workdir().context(NoImagesRepoWorkdirSnafu)?;
243247
match opts.cmd {
244-
Cmd::Checkout { pv } => {
248+
Cmd::Checkout { pv, base_only } => {
245249
let ctx = ProductVersionContext {
246250
pv,
247251
images_repo_root,
@@ -280,8 +284,13 @@ fn main() -> Result<()> {
280284
None
281285
}
282286
};
283-
let patched_commit = patch::apply_patches(&product_repo, &ctx.patch_dir(), base_commit)
284-
.context(ApplyPatchesSnafu)?;
287+
let patched_commit = if !base_only {
288+
patch::apply_patches(&product_repo, &ctx.patch_dir(), base_commit)
289+
.context(ApplyPatchesSnafu)?
290+
} else {
291+
tracing::warn!("--base-only specified, skipping patches");
292+
base_commit
293+
};
285294

286295
let product_worktree_root = ctx.worktree_root();
287296
let worktree_branch = ctx.worktree_branch();

0 commit comments

Comments
 (0)