mirror of
				https://github.com/0glabs/0g-storage-node.git
				synced 2025-11-04 00:27:39 +00:00 
			
		
		
		
	opt zgs version (#211)
This commit is contained in:
		
							parent
							
								
									9cde84ae15
								
							
						
					
					
						commit
						84c415e959
					
				@ -7,41 +7,42 @@ use target_info::Target;
 | 
			
		||||
///
 | 
			
		||||
/// ## Example
 | 
			
		||||
///
 | 
			
		||||
/// `Lighthouse/v1.5.1-67da032+`
 | 
			
		||||
/// `v0.5.2` or `v0.5.2-1-67da032+`
 | 
			
		||||
pub const VERSION: &str = git_version!(
 | 
			
		||||
    args = [
 | 
			
		||||
        "--always",
 | 
			
		||||
        "--dirty=+",
 | 
			
		||||
        "--abbrev=7",
 | 
			
		||||
        // NOTE: using --match instead of --exclude for compatibility with old Git
 | 
			
		||||
        "--match=thiswillnevermatchlol"
 | 
			
		||||
        // "--match=thiswillnevermatchlol"
 | 
			
		||||
        "--tags",
 | 
			
		||||
    ],
 | 
			
		||||
    prefix = "zgs/v0.0.1-",
 | 
			
		||||
    // prefix = "zgs/v0.0.1-",
 | 
			
		||||
    fallback = "unknown"
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
/// Returns `VERSION`, but with platform information appended to the end.
 | 
			
		||||
/// Returns `VERSION`, but with `zgs` prefix and platform information appended to the end.
 | 
			
		||||
///
 | 
			
		||||
/// ## Example
 | 
			
		||||
///
 | 
			
		||||
/// `zgs/v0.0.1-67da032+/x86_64-linux`
 | 
			
		||||
/// `zgs/v0.5.2/x86_64-linux`
 | 
			
		||||
pub fn version_with_platform() -> String {
 | 
			
		||||
    format!("{}/{}-{}", VERSION, Target::arch(), Target::os())
 | 
			
		||||
    format!("zgs/{}/{}-{}", VERSION, Target::arch(), Target::os())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
mod test {
 | 
			
		||||
    use super::*;
 | 
			
		||||
    use regex::Regex;
 | 
			
		||||
// #[cfg(test)]
 | 
			
		||||
// mod test {
 | 
			
		||||
//     use super::*;
 | 
			
		||||
//     use regex::Regex;
 | 
			
		||||
 | 
			
		||||
    #[test]
 | 
			
		||||
    fn version_formatting() {
 | 
			
		||||
        let re =
 | 
			
		||||
            Regex::new(r"^zgs/v[0-9]+\.[0-9]+\.[0-9]+(-rc.[0-9])?-[[:xdigit:]]{7}\+?$").unwrap();
 | 
			
		||||
        assert!(
 | 
			
		||||
            re.is_match(VERSION),
 | 
			
		||||
            "version doesn't match regex: {}",
 | 
			
		||||
            VERSION
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
//     #[test]
 | 
			
		||||
//     fn version_formatting() {
 | 
			
		||||
//         let re =
 | 
			
		||||
//             Regex::new(r"^v[0-9]+\.[0-9]+\.[0-9]+(-rc.[0-9])?-[[:xdigit:]]{7}\+?$").unwrap();
 | 
			
		||||
//         assert!(
 | 
			
		||||
//             re.is_match(VERSION),
 | 
			
		||||
//             "version doesn't match regex: {}",
 | 
			
		||||
//             VERSION
 | 
			
		||||
//         );
 | 
			
		||||
//     }
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@ edition = "2021"
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
anyhow = { version = "1.0.58", features = ["backtrace"] }
 | 
			
		||||
clap = { version = "4.5.17", features = ["cargo"] }
 | 
			
		||||
clap = { version = "4.5.17", features = ["cargo", "string"] }
 | 
			
		||||
ctrlc = "3.2.2"
 | 
			
		||||
error-chain = "0.12.4"
 | 
			
		||||
ethereum-types = "0.14"
 | 
			
		||||
 | 
			
		||||
@ -10,4 +10,5 @@ pub fn cli_app() -> Command {
 | 
			
		||||
        )
 | 
			
		||||
        .arg(arg!(--"db-max-num-chunks" [NUM] "Sets the max number of chunks to store in db (Default: None)"))
 | 
			
		||||
        .allow_external_subcommands(true)
 | 
			
		||||
        .version(zgs_version::VERSION)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user