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:
生于生时 亡于亡刻
2025-10-12 15:48:24 +08:00
committed by GitHub
parent 4c512dc7ff
commit 0a804ba170
15 changed files with 232 additions and 221 deletions

View File

@@ -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))
}