Skip to content

Commit 8a65c10

Browse files
committed
Documentation and cleanup
1 parent 5967795 commit 8a65c10

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ cd $(cargo patchable checkout druid 26.0.0)
7373
cargo patchable export druid 26.0.0
7474
```
7575

76+
### Initialize a new patch series
77+
78+
```sh
79+
cargo patchable init druid 28.0.0 --upstream https://github.com/apache/druid.git --base druid-28.0.0
80+
```
81+
7682
### Porting patch series to a new version
7783

7884
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: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,46 @@ impl ProductVersionContext<'_> {
5252
.context(ParseConfigSnafu { path })
5353
}
5454

55-
fn root(&self) -> PathBuf {
55+
/// The root directory for files related to the product (across all versions).
56+
fn product_dir(&self) -> PathBuf {
5657
self.images_repo_root.join(&self.pv.product)
5758
}
5859

60+
/// The directory containing patches for the product version.
5961
fn patch_dir(&self) -> PathBuf {
60-
self.root().join("stackable/patches").join(&self.pv.version)
62+
self.product_dir()
63+
.join("stackable/patches")
64+
.join(&self.pv.version)
6165
}
6266

67+
/// The patchable configuration file for the product version.
6368
fn config_path(&self) -> PathBuf {
6469
self.patch_dir().join("patchable.toml")
6570
}
6671

72+
/// The directory containing all ephemeral data used by patchable for the product (across all versions).
73+
///
74+
/// Should be gitignored, and can safely be deleted as long as all relevant versions have been `patchable export`ed.
6775
fn work_root(&self) -> PathBuf {
68-
self.root().join("patchable-work")
76+
self.product_dir().join("patchable-work")
6977
}
7078

71-
fn repo(&self) -> PathBuf {
79+
/// The repository for the product (across all versions).
80+
fn product_repo(&self) -> PathBuf {
7281
self.work_root().join("product-repo")
7382
}
7483

84+
/// The worktree root for the product version.
7585
fn worktree_root(&self) -> PathBuf {
7686
self.work_root().join("worktree").join(&self.pv.version)
7787
}
7888

89+
/// Branch pointing at the upstream base commit for the product version.
7990
fn base_branch(&self) -> String {
8091
format!("patchable/base/{}", self.pv.version)
8192
}
8293

94+
/// branch pointing at the last commit in the patch series for the product version.
8395
fn worktree_branch(&self) -> String {
8496
format!("patchable/{}", self.pv.version)
8597
}
@@ -235,13 +247,9 @@ fn main() -> Result<()> {
235247
images_repo_root,
236248
};
237249
let config = ctx.load_config()?;
238-
let product_repo_root = ctx.repo();
239-
let product_repo = tracing::info_span!(
240-
"finding product repository",
241-
product.repository = ?product_repo_root,
242-
)
243-
.in_scope(|| repo::ensure_bare_repo(&product_repo_root))
244-
.context(OpenProductRepoForCheckoutSnafu)?;
250+
let product_repo_root = ctx.product_repo();
251+
let product_repo = repo::ensure_bare_repo(&product_repo_root)
252+
.context(OpenProductRepoForCheckoutSnafu)?;
245253

246254
let base_commit = repo::resolve_and_fetch_commitish(
247255
&product_repo,
@@ -357,7 +365,7 @@ fn main() -> Result<()> {
357365
images_repo_root,
358366
};
359367

360-
let product_repo_root = ctx.repo();
368+
let product_repo_root = ctx.product_repo();
361369
let product_repo = tracing::info_span!(
362370
"finding product repository",
363371
product.repository = ?product_repo_root,

rust/patchable/src/patch.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ fn patch_files(patch_dir: &Path) -> Result<Vec<PathBuf>> {
171171
/// even if those files are modified by some of the patches)
172172
#[tracing::instrument(skip(repo))]
173173
pub fn apply_patches(repo: &Repository, patch_dir: &Path, base_commit: Oid) -> Result<Oid> {
174-
tracing::info!(
175-
patch.dir = %patch_dir.display(),
176-
"applying patches"
177-
);
174+
tracing::info!("applying patches");
178175
let mut last_commit_id = base_commit;
179176
for ref patch_file in patch_files(patch_dir)? {
180177
tracing::info!(

0 commit comments

Comments
 (0)