66//! 3. Every release has name + version + last_sha
77
88use crate :: core:: config:: ReleaseConfig ;
9+ use crate :: core:: context:: WorkspaceContext ;
910use crate :: core:: error:: { RailError , RailResult } ;
1011use crate :: quality:: changelog:: { Changelog , ChangelogFormat , ConventionalCommit } ;
1112use crate :: release:: { ReleasePlan , ReleaseTracker , VersionBump } ;
12- use std:: env;
1313
1414/// Run the release plan command
15- pub fn run_release_plan ( name : Option < String > , all : bool , json : bool ) -> RailResult < ( ) > {
16- let workspace_root = env:: current_dir ( ) ?;
17-
15+ pub fn run_release_plan ( ctx : & WorkspaceContext , name : Option < String > , all : bool , json : bool ) -> RailResult < ( ) > {
1816 // Load release tracker
19- let tracker = ReleaseTracker :: load ( & workspace_root) ?;
17+ let tracker = ReleaseTracker :: load ( ctx . workspace_root ( ) ) ?;
2018
2119 // Determine which releases to plan
2220 let releases: Vec < _ > = if all {
@@ -47,7 +45,7 @@ pub fn run_release_plan(name: Option<String>, all: bool, json: bool) -> RailResu
4745 // Analyze each release
4846 let mut plans = Vec :: new ( ) ;
4947 for release in & releases {
50- let plan = ReleasePlan :: analyze ( & workspace_root, release) ?;
48+ let plan = ReleasePlan :: analyze ( ctx . workspace_root ( ) , release) ?;
5149 plans. push ( plan) ;
5250 }
5351
@@ -63,15 +61,14 @@ pub fn run_release_plan(name: Option<String>, all: bool, json: bool) -> RailResu
6361
6462/// Run the release apply command
6563pub fn run_release_apply (
64+ ctx : & WorkspaceContext ,
6665 name : String ,
6766 dry_run : bool ,
6867 // Skip syncing to split repos - deferred to post-v1 (see TODO.md Post-v1: Auto-sync to split repos)
6968 #[ allow( unused_variables) ] skip_sync : bool ,
7069) -> RailResult < ( ) > {
71- let workspace_root = env:: current_dir ( ) ?;
72-
7370 // Load release tracker
74- let mut tracker = ReleaseTracker :: load ( & workspace_root) ?;
71+ let mut tracker = ReleaseTracker :: load ( ctx . workspace_root ( ) ) ?;
7572
7673 // Find the release
7774 let release = tracker
@@ -80,7 +77,7 @@ pub fn run_release_apply(
8077 . clone ( ) ;
8178
8279 // Generate plan
83- let plan = ReleasePlan :: analyze ( & workspace_root, & release) ?;
80+ let plan = ReleasePlan :: analyze ( ctx . workspace_root ( ) , & release) ?;
8481
8582 if !plan. has_changes {
8683 println ! ( "⚠️ No changes detected for '{}'" , name) ;
@@ -125,25 +122,29 @@ pub fn run_release_apply(
125122 println ! ( "✅ Applying release..." ) ;
126123
127124 // 1. Update Cargo.toml version
128- update_crate_version ( & workspace_root, & release. crate_path , & plan. proposed_version . to_string ( ) ) ?;
125+ update_crate_version (
126+ ctx. workspace_root ( ) ,
127+ & release. crate_path ,
128+ & plan. proposed_version . to_string ( ) ,
129+ ) ?;
129130 println ! ( " Updated Cargo.toml version" ) ;
130131
131132 // 2. Generate and update changelog (if configured)
132133 if let Some ( changelog_path) = & release. changelog {
133- generate_changelog ( & workspace_root, & release, & plan, changelog_path) ?;
134+ generate_changelog ( ctx . workspace_root ( ) , & release, & plan, changelog_path) ?;
134135 println ! ( " Updated {}" , changelog_path. display( ) ) ;
135136 }
136137
137138 // 3. Get current HEAD SHA
138- let head_sha = get_head_sha ( & workspace_root) ?;
139+ let head_sha = get_head_sha ( ctx . workspace_root ( ) ) ?;
139140
140141 // 4. Update rail.toml metadata
141142 tracker. update_release ( & name, & plan. proposed_version . to_string ( ) , & head_sha) ?;
142143 tracker. save ( ) ?;
143144 println ! ( " Updated rail.toml metadata" ) ;
144145
145146 // 5. Create git tag
146- create_git_tag ( & workspace_root, & name, & plan. proposed_version . to_string ( ) ) ?;
147+ create_git_tag ( ctx . workspace_root ( ) , & name, & plan. proposed_version . to_string ( ) ) ?;
147148 println ! ( " Created tag: {}-v{}" , name, plan. proposed_version) ;
148149
149150 println ! ( ) ;
0 commit comments