@@ -76,6 +76,10 @@ impl ProductVersionContext<'_> {
7676 self . work_root ( ) . join ( "worktree" ) . join ( & self . pv . version )
7777 }
7878
79+ fn base_branch ( & self ) -> String {
80+ format ! ( "patchable/base/{}" , self . pv. version)
81+ }
82+
7983 fn worktree_branch ( & self ) -> String {
8084 format ! ( "patchable/{}" , self . pv. version)
8185 }
@@ -245,21 +249,47 @@ fn main() -> Result<()> {
245249 & config. upstream ,
246250 )
247251 . context ( FetchBaseCommitSnafu ) ?;
252+ let base_branch = ctx. base_branch ( ) ;
253+ let base_branch = match product_repo
254+ . find_commit ( base_commit)
255+ . and_then ( |base| product_repo. branch ( & base_branch, & base, true ) )
256+ {
257+ Ok ( _) => {
258+ tracing:: info!(
259+ branch. base = base_branch,
260+ branch. base. commit = %base_commit,
261+ "updated base branch"
262+ ) ;
263+ Some ( base_branch)
264+ }
265+ Err ( err) => {
266+ tracing:: warn!(
267+ error = & err as & dyn std:: error:: Error ,
268+ branch. base = base_branch,
269+ branch. base. commit = %base_commit,
270+ "failed to update base branch reference, ignoring..."
271+ ) ;
272+ None
273+ }
274+ } ;
248275 let patched_commit = patch:: apply_patches ( & product_repo, & ctx. patch_dir ( ) , base_commit)
249276 . context ( ApplyPatchesSnafu ) ?;
250277
251278 let product_worktree_root = ctx. worktree_root ( ) ;
279+ let worktree_branch = ctx. worktree_branch ( ) ;
252280 repo:: ensure_worktree_is_at (
253281 & product_repo,
254282 & ctx. pv . version ,
255283 & product_worktree_root,
256- & ctx . worktree_branch ( ) ,
284+ & worktree_branch,
257285 patched_commit,
258286 )
259287 . context ( CheckoutProductWorktreeSnafu ) ?;
260288
261289 tracing:: info!(
262290 worktree. root = ?product_worktree_root,
291+ branch. worktree = worktree_branch,
292+ branch. base = base_branch,
263293 "worktree is ready!"
264294 ) ;
265295
0 commit comments