mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 11:44:59 +00:00
code_review: PR #1180
- replace `SetNeedNavigateToUpstreamHead` with `NavigateToBranchDelayed` - navigate to current HEAD instead of original source HEAD after merge Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
17cf402c78
commit
0cb2ca78fe
5 changed files with 15 additions and 30 deletions
|
@ -83,7 +83,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
CallUIThread(() =>
|
||||
{
|
||||
_repo.SetNeedNavigateToUpstreamHead();
|
||||
_repo.NavigateToBranchDelayed(_repo.CurrentBranch?.Upstream);
|
||||
_repo.MarkFetched();
|
||||
_repo.SetWatcherEnabled(true);
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace SourceGit.ViewModels
|
|||
new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec();
|
||||
CallUIThread(() =>
|
||||
{
|
||||
_repo.SetNeedNavigateToUpstreamHead();
|
||||
_repo.NavigateToBranchDelayed(Upstream.FullName);
|
||||
_repo.SetWatcherEnabled(true);
|
||||
});
|
||||
return true;
|
||||
|
|
|
@ -64,18 +64,7 @@ namespace SourceGit.ViewModels
|
|||
new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec();
|
||||
CallUIThread(() =>
|
||||
{
|
||||
switch (Source)
|
||||
{
|
||||
case Models.Branch branch:
|
||||
_repo.NavigateToCommit(branch.Head);
|
||||
break;
|
||||
case Models.Commit commit:
|
||||
_repo.NavigateToCommit(commit.SHA);
|
||||
break;
|
||||
case Models.Tag tag:
|
||||
_repo.NavigateToCommit(tag.SHA);
|
||||
break;
|
||||
}
|
||||
_repo.NavigateToBranchDelayed(_repo.CurrentBranch?.FullName);
|
||||
_repo.SetWatcherEnabled(true);
|
||||
});
|
||||
return true;
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
CallUIThread(() =>
|
||||
{
|
||||
_repo.SetNeedNavigateToUpstreamHead();
|
||||
_repo.NavigateToBranchDelayed(_repo.CurrentBranch?.FullName);
|
||||
_repo.SetWatcherEnabled(true);
|
||||
});
|
||||
return rs;
|
||||
|
|
|
@ -717,11 +717,6 @@ namespace SourceGit.ViewModels
|
|||
_watcher?.SetEnabled(enabled);
|
||||
}
|
||||
|
||||
public void SetNeedNavigateToUpstreamHead()
|
||||
{
|
||||
_needNavigateToUpstreamHead = true;
|
||||
}
|
||||
|
||||
public void MarkBranchesDirtyManually()
|
||||
{
|
||||
if (_watcher == null)
|
||||
|
@ -778,13 +773,9 @@ namespace SourceGit.ViewModels
|
|||
NavigateToCommit(_currentBranch.Head);
|
||||
}
|
||||
|
||||
public void NavigateToCurrentUpstreamHead()
|
||||
public void NavigateToBranchDelayed(string branch)
|
||||
{
|
||||
if (_currentBranch == null || string.IsNullOrEmpty(_currentBranch.Upstream))
|
||||
return;
|
||||
var branch = _branches.Find(x => x.FullName == _currentBranch.Upstream);
|
||||
if (branch != null)
|
||||
NavigateToCommit(branch.Head);
|
||||
_navigateToBranchDelayed = branch;
|
||||
}
|
||||
|
||||
public void ClearHistoriesFilter()
|
||||
|
@ -1005,12 +996,16 @@ namespace SourceGit.ViewModels
|
|||
_histories.IsLoading = false;
|
||||
_histories.Commits = commits;
|
||||
_histories.Graph = graph;
|
||||
if (_needNavigateToUpstreamHead)
|
||||
|
||||
if (!string.IsNullOrEmpty(_navigateToBranchDelayed))
|
||||
{
|
||||
NavigateToCurrentUpstreamHead();
|
||||
_needNavigateToUpstreamHead = false;
|
||||
var branch = _branches.Find(x => x.FullName == _navigateToBranchDelayed);
|
||||
if (branch != null)
|
||||
NavigateToCommit(branch.Head);
|
||||
}
|
||||
}
|
||||
|
||||
_navigateToBranchDelayed = string.Empty;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2607,6 +2602,7 @@ namespace SourceGit.ViewModels
|
|||
private bool _isAutoFetching = false;
|
||||
private Timer _autoFetchTimer = null;
|
||||
private DateTime _lastFetchTime = DateTime.MinValue;
|
||||
private bool _needNavigateToUpstreamHead = false;
|
||||
|
||||
private string _navigateToBranchDelayed = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue