VERSION file parsing
This commit is contained in:
parent
730de12a63
commit
ab775befb1
|
@ -6,6 +6,7 @@ use structopt::StructOpt;
|
||||||
mod changelog;
|
mod changelog;
|
||||||
mod cmd;
|
mod cmd;
|
||||||
mod gitea;
|
mod gitea;
|
||||||
|
mod version;
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(StructOpt, Debug)]
|
||||||
pub(crate) struct Common {
|
pub(crate) struct Common {
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
use anyhow::Result;
|
||||||
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
|
fn read_version(fname: PathBuf) -> Result<String> {
|
||||||
|
let version = fs::read_to_string(fname)?;
|
||||||
|
Ok(version.trim().into())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn read_version() {
|
||||||
|
let version = super::read_version("./testdata/VERSION".into()).unwrap();
|
||||||
|
assert_eq!(version, "0.1.0");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
0.1.0
|
Loading…
Reference in New Issue