11use regex:: Regex ;
22use rust_project_goals:: spanned:: { Error , Spanned } ;
33use rust_project_goals:: { spanned:: Context as _, spanned:: Result } ;
4+ use rust_project_goals:: util:: MILESTONE_REGEX ;
45use std:: fs:: { self , File } ;
56use std:: io:: Write ;
67use std:: path:: { Path , PathBuf } ;
@@ -9,6 +10,8 @@ use std::path::{Path, PathBuf};
910pub mod text_processing {
1011 use regex:: Regex ;
1112
13+ use super :: MILESTONE_REGEX ;
14+
1215 use crate :: cfp:: normalize_timeframe;
1316
1417 /// Process template content by replacing placeholders and removing notes
@@ -143,7 +146,7 @@ pub mod text_processing {
143146 // Find a good place to insert the new section
144147 // Look for the last timeframe section or insert after # Summary
145148 // Match both year-only (2027) and half-year (2026H1) formats
146- let re = Regex :: new ( r"# ⏳ \d{4}([hH][12])? goal process" ) . unwrap ( ) ;
149+ let re = Regex :: new ( & format ! ( r"# ⏳ {MILESTONE_REGEX} goal process" ) ) . unwrap ( ) ;
147150
148151 if let Some ( last_match) = re. find_iter ( & content) . last ( ) {
149152 // Find the end of this section (next section or end of file)
@@ -371,7 +374,7 @@ pub fn create_cfp(timeframe: &str, force: bool, dry_run: bool) -> Result<()> {
371374
372375/// Validates that the timeframe is in the correct format (e.g., "2025h1" or "2025H1" or '2026')
373376fn validate_timeframe ( timeframe : & str ) -> Result < ( ) > {
374- let re = Regex :: new ( r"^\d{4}([hH][12])?$" ) . unwrap ( ) ;
377+ let re = Regex :: new ( MILESTONE_REGEX ) . unwrap ( ) ;
375378 if !re. is_match ( timeframe) {
376379 return Err ( Error :: str ( "Invalid timeframe format. Expected format: YYYYhN or YYYYHN (e.g., 2025h1, 2025H1, 2025h2, or 2025H2" ) ) ;
377380 }
0 commit comments