mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
feature<Preference>: query git version after selecting git path
This commit is contained in:
parent
1a5fdc540c
commit
ebc2fc6b91
6 changed files with 70 additions and 33 deletions
18
src/Commands/Version.cs
Normal file
18
src/Commands/Version.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
|
||||
namespace SourceGit.Commands {
|
||||
/// <summary>
|
||||
/// 检测git是否可用,并获取git版本信息
|
||||
/// </summary>
|
||||
public class Version : Command {
|
||||
const string GitVersionPrefix = "git version ";
|
||||
public string Query() {
|
||||
Args = $"--version";
|
||||
var result = ReadToEnd();
|
||||
if (!result.IsSuccess || string.IsNullOrEmpty(result.Output)) return null;
|
||||
var version = result.Output.Trim();
|
||||
if (!version.StartsWith(GitVersionPrefix, StringComparison.Ordinal)) return null;
|
||||
return version.Substring(GitVersionPrefix.Length);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue