66///
77/// Handles version string generation based on build type:
88/// - Release builds: nebula-X.Y.Z
9- /// - Debug/Snapshot builds: nebula-X.Y.Z-pulsar.YYMMDD
9+ /// - Debug builds: nebula-X.Y.Z-pulsar.YYMMDD
10+ /// - Snapshot builds: nebula-X.Y.Z-pulsar.YYMMDD.BUILD
1011
1112/// Get the current version string for Noviq
1213pub fn get_version ( ) -> String {
@@ -17,8 +18,13 @@ pub fn get_version() -> String {
1718 // Check if SNAPSHOT environment variable is set during build
1819 let is_snapshot = option_env ! ( "SNAPSHOT" ) . is_some ( ) ;
1920
20- if is_snapshot || cfg ! ( debug_assertions) {
21- // Snapshot or Debug build - use snapshot format
21+ if is_snapshot {
22+ // Snapshot build - include date and build number
23+ let date = chrono:: Local :: now ( ) . format ( "%y%m%d" ) . to_string ( ) ;
24+ let build_number = get_build_number ( ) ;
25+ format ! ( "{}-pulsar.{}.{}" , base_version, date, build_number)
26+ } else if cfg ! ( debug_assertions) {
27+ // Debug build - use snapshot format without build number
2228 let date = chrono:: Local :: now ( ) . format ( "%y%m%d" ) . to_string ( ) ;
2329 format ! ( "{}-pulsar.{}" , base_version, date)
2430 } else {
@@ -27,6 +33,18 @@ pub fn get_version() -> String {
2733 }
2834}
2935
36+ /// Get build number based on git commit hash
37+ /// Returns the short git hash if available, otherwise "dev"
38+ fn get_build_number ( ) -> String {
39+ // Try to get git commit hash at compile time
40+ if let Some ( git_hash) = option_env ! ( "GIT_HASH" ) {
41+ git_hash. to_string ( )
42+ } else {
43+ // Fallback to "dev" if git hash not available
44+ "dev" . to_string ( )
45+ }
46+ }
47+
3048/// Get package name
3149pub fn get_package_name ( ) -> & ' static str {
3250 env ! ( "CARGO_PKG_NAME" )
0 commit comments