[英]How to know in C# process response if git rebase resulted conflict or successful
我正在使用cmd.exe
Process
運行 git 命令,一切正常,現在我正在嘗試重新設置分支並想知道重新設置是否成功然后想運行git push
命令作為下一步。
有沒有辦法知道 git rebase 是否成功而不會與Process
的響應消息發生沖突?
因為當它成功時,它會給出這個響應Successfully rebased and updated refs/heads/qa.
我檢查了這個問題是否有某種“git rebase --dry-run”,它會提前通知我沖突?
答案說如果它是一個非零響應,這意味着它不成功,但 rebase 沒有以 0/1 格式給出響應,它返回文本。
我的代碼是這樣的
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c git rebase master");
procStartInfo.FileName = "cmd.exe";
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit();
// What should I check here to make sure rebase happened without conflicts
var response = await proc.StandardOutput.ReadToEndAsync();
我認為您需要檢查 Process.ExitCode 屬性。 在大多數情況下,如果出現錯誤,代碼將為非零。 我認為 git 也不例外。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.