From 5ffa4025fb64da0e25a6fb40aeec28c6533ecfae Mon Sep 17 00:00:00 2001 From: lindexi Date: Tue, 12 Nov 2024 09:04:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E4=B8=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=96=87=E4=BB=B6=E5=8D=B3=E5=8F=AF=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E5=88=B0=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/GitCommand/GitCommand/Git.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/package/GitCommand/GitCommand/Git.cs b/package/GitCommand/GitCommand/Git.cs index 57d8a02..2191897 100644 --- a/package/GitCommand/GitCommand/Git.cs +++ b/package/GitCommand/GitCommand/Git.cs @@ -52,17 +52,12 @@ public string[] GetLogCommit() public string GetCurrentCommit() { - var file = Path.GetTempFileName(); - RunGitCommand($"rev-parse HEAD > \"{file}\""); - var commit = File.ReadAllText(file).Trim(); - try - { - File.Delete(file); - } - catch (Exception) + var (success, output) = RunGitCommand($"rev-parse HEAD"); + if (!success) { + return string.Empty; } - + var commit = output.Trim(); return commit; }