Skip to content

Commit 0cb2ca7

Browse files
committed
code_review: PR #1180
- replace `SetNeedNavigateToUpstreamHead` with `NavigateToBranchDelayed` - navigate to current HEAD instead of original source HEAD after merge Signed-off-by: leo <[email protected]>
1 parent 17cf402 commit 0cb2ca7

File tree

5 files changed

+15
-30
lines changed

5 files changed

+15
-30
lines changed

src/ViewModels/Fetch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public override Task<bool> Sure()
8383

8484
CallUIThread(() =>
8585
{
86-
_repo.SetNeedNavigateToUpstreamHead();
86+
_repo.NavigateToBranchDelayed(_repo.CurrentBranch?.Upstream);
8787
_repo.MarkFetched();
8888
_repo.SetWatcherEnabled(true);
8989
});

src/ViewModels/FetchInto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override Task<bool> Sure()
3434
new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec();
3535
CallUIThread(() =>
3636
{
37-
_repo.SetNeedNavigateToUpstreamHead();
37+
_repo.NavigateToBranchDelayed(Upstream.FullName);
3838
_repo.SetWatcherEnabled(true);
3939
});
4040
return true;

src/ViewModels/Merge.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,7 @@ public override Task<bool> Sure()
6464
new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec();
6565
CallUIThread(() =>
6666
{
67-
switch (Source)
68-
{
69-
case Models.Branch branch:
70-
_repo.NavigateToCommit(branch.Head);
71-
break;
72-
case Models.Commit commit:
73-
_repo.NavigateToCommit(commit.SHA);
74-
break;
75-
case Models.Tag tag:
76-
_repo.NavigateToCommit(tag.SHA);
77-
break;
78-
}
67+
_repo.NavigateToBranchDelayed(_repo.CurrentBranch?.FullName);
7968
_repo.SetWatcherEnabled(true);
8069
});
8170
return true;

src/ViewModels/Pull.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public override Task<bool> Sure()
194194

195195
CallUIThread(() =>
196196
{
197-
_repo.SetNeedNavigateToUpstreamHead();
197+
_repo.NavigateToBranchDelayed(_repo.CurrentBranch?.FullName);
198198
_repo.SetWatcherEnabled(true);
199199
});
200200
return rs;

src/ViewModels/Repository.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,6 @@ public void SetWatcherEnabled(bool enabled)
717717
_watcher?.SetEnabled(enabled);
718718
}
719719

720-
public void SetNeedNavigateToUpstreamHead()
721-
{
722-
_needNavigateToUpstreamHead = true;
723-
}
724-
725720
public void MarkBranchesDirtyManually()
726721
{
727722
if (_watcher == null)
@@ -778,13 +773,9 @@ public void NavigateToCurrentHead()
778773
NavigateToCommit(_currentBranch.Head);
779774
}
780775

781-
public void NavigateToCurrentUpstreamHead()
776+
public void NavigateToBranchDelayed(string branch)
782777
{
783-
if (_currentBranch == null || string.IsNullOrEmpty(_currentBranch.Upstream))
784-
return;
785-
var branch = _branches.Find(x => x.FullName == _currentBranch.Upstream);
786-
if (branch != null)
787-
NavigateToCommit(branch.Head);
778+
_navigateToBranchDelayed = branch;
788779
}
789780

790781
public void ClearHistoriesFilter()
@@ -1005,12 +996,16 @@ public void RefreshCommits()
1005996
_histories.IsLoading = false;
1006997
_histories.Commits = commits;
1007998
_histories.Graph = graph;
1008-
if (_needNavigateToUpstreamHead)
999+
1000+
if (!string.IsNullOrEmpty(_navigateToBranchDelayed))
10091001
{
1010-
NavigateToCurrentUpstreamHead();
1011-
_needNavigateToUpstreamHead = false;
1002+
var branch = _branches.Find(x => x.FullName == _navigateToBranchDelayed);
1003+
if (branch != null)
1004+
NavigateToCommit(branch.Head);
10121005
}
10131006
}
1007+
1008+
_navigateToBranchDelayed = string.Empty;
10141009
});
10151010
}
10161011

@@ -2607,6 +2602,7 @@ private void AutoFetchImpl(object sender)
26072602
private bool _isAutoFetching = false;
26082603
private Timer _autoFetchTimer = null;
26092604
private DateTime _lastFetchTime = DateTime.MinValue;
2610-
private bool _needNavigateToUpstreamHead = false;
2605+
2606+
private string _navigateToBranchDelayed = string.Empty;
26112607
}
26122608
}

0 commit comments

Comments
 (0)