mirror of
https://github.com/jht5945/rust_util.git
synced 2025-12-27 07:30:05 +08:00
feat: add git_rev_parse_head
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rust_util"
|
||||
version = "0.6.28"
|
||||
version = "0.6.29"
|
||||
authors = ["Hatter Jiang <jht5945@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "Hatter's Rust Util"
|
||||
|
||||
@@ -25,6 +25,15 @@ pub fn git_status_change(working_dir: Option<&str>) -> XResult<GitStatusChange>
|
||||
parse_git_status_change(&git_status)
|
||||
}
|
||||
|
||||
pub fn git_rev_parse_head(working_dir: Option<&str>) -> XResult<String> {
|
||||
let mut cmd = new_git_command(working_dir);
|
||||
cmd.args(vec!["rev-parse", "HEAD"]);
|
||||
util_msg::print_info(&format!("Exec: {:?}", cmd));
|
||||
let output = cmd.output()?;
|
||||
let rev_parse_head = String::from_utf8(output.stdout)?;
|
||||
Ok(rev_parse_head.trim().to_string())
|
||||
}
|
||||
|
||||
pub fn git_fetch_dry_run(working_dir: Option<&str>) -> XResult<bool> {
|
||||
let mut cmd = new_git_command(working_dir);
|
||||
cmd.args(vec!["fetch", "--dry-run"]);
|
||||
|
||||
Reference in New Issue
Block a user