932c41d369
- reduce github calls - latest_tag returns full tag - rev_to_int default to 0 on strip_prefix - lint
21 lines
482 B
Rust
21 lines
482 B
Rust
use std::{fs, path::PathBuf};
|
|
|
|
pub fn get_file_sha1(path: &PathBuf) -> String {
|
|
let mut sha1 = sha1_smol::Sha1::new();
|
|
sha1.update(&fs::read(path).unwrap());
|
|
sha1.digest().to_string()
|
|
}
|
|
|
|
pub fn stdin() -> String {
|
|
let mut input = String::new();
|
|
std::io::stdin().read_line(&mut input).unwrap();
|
|
input.trim().to_string()
|
|
}
|
|
|
|
pub fn rev_to_int(rev: &str) -> u16 {
|
|
rev.strip_prefix('r')
|
|
.unwrap_or("0")
|
|
.parse::<u16>()
|
|
.unwrap_or(0)
|
|
}
|