feat: Optimize some codes (ksud) (#465)
* chore: make cargo clippy happy Signed-off-by: Tools-app <localhost.hutao@gmail.com> * chore: Optimize import - Format as a standard import Signed-off-by: Tools-app <localhost.hutao@gmail.com> --------- Signed-off-by: Tools-app <localhost.hutao@gmail.com>
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
use std::{env, fs::File, io::Write, path::Path, process::Command};
|
||||
|
||||
fn get_git_version() -> Result<(u32, String), std::io::Error> {
|
||||
let output = Command::new("git")
|
||||
@@ -14,7 +10,7 @@ fn get_git_version() -> Result<(u32, String), std::io::Error> {
|
||||
let version_code: u32 = version_code
|
||||
.trim()
|
||||
.parse()
|
||||
.map_err(|_| std::io::Error::new(std::io::ErrorKind::Other, "Failed to parse git count"))?;
|
||||
.map_err(|_| std::io::Error::other("Failed to parse git count"))?;
|
||||
let version_code = 10000 + 700 + version_code; // For historical reasons
|
||||
|
||||
let version_name = String::from_utf8(
|
||||
@@ -23,7 +19,7 @@ fn get_git_version() -> Result<(u32, String), std::io::Error> {
|
||||
.output()?
|
||||
.stdout,
|
||||
)
|
||||
.map_err(|_| std::io::Error::other("Failed to read git describe stdout"))?;
|
||||
.map_err(|_| std::io::Error::other("Failed to parse git count"))?;
|
||||
let version_name = version_name.trim_start_matches('v').to_string();
|
||||
Ok((version_code, version_name))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user