feature: git bisect support

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-22 15:45:15 +08:00
parent 9eae1eeb81
commit df5294bcb7
No known key found for this signature in database
16 changed files with 397 additions and 7 deletions

View file

@ -398,6 +398,18 @@ namespace SourceGit.ViewModels
get => _workingCopy?.InProgressContext;
}
public Models.BisectState BisectState
{
get => _bisectState;
private set => SetProperty(ref _bisectState, value);
}
public bool IsBisectCommandRunning
{
get => _isBisectCommandRunning;
private set => SetProperty(ref _isBisectCommandRunning, value);
}
public bool IsAutoFetching
{
get => _isAutoFetching;
@ -939,6 +951,31 @@ namespace SourceGit.ViewModels
return actions;
}
public void Bisect(string subcmd)
{
IsBisectCommandRunning = true;
SetWatcherEnabled(false);
var log = CreateLog($"Bisect({subcmd})");
Task.Run(() =>
{
var succ = new Commands.Bisect(_fullpath, subcmd).Use(log).Exec();
log.Complete();
Dispatcher.UIThread.Invoke(() =>
{
if (!succ)
App.RaiseException(_fullpath, log.Content);
else if (log.Content.Contains("is the first bad commit"))
App.SendNotification(_fullpath, log.Content);
MarkBranchesDirtyManually();
SetWatcherEnabled(true);
IsBisectCommandRunning = false;
});
});
}
public void RefreshBranches()
{
var branches = new Commands.QueryBranches(_fullpath).Result();
@ -1023,6 +1060,8 @@ namespace SourceGit.ViewModels
_histories.Commits = commits;
_histories.Graph = graph;
BisectState = _histories.UpdateBisectInfo();
if (!string.IsNullOrEmpty(_navigateToBranchDelayed))
{
var branch = _branches.Find(x => x.FullName == _navigateToBranchDelayed);
@ -2627,6 +2666,9 @@ namespace SourceGit.ViewModels
private Timer _autoFetchTimer = null;
private DateTime _lastFetchTime = DateTime.MinValue;
private Models.BisectState _bisectState = Models.BisectState.None;
private bool _isBisectCommandRunning = false;
private string _navigateToBranchDelayed = string.Empty;
}
}