Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Commands/QueryBranches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public QueryBranches(string repo)
foreach (var b in branches)
{
if (b.IsLocal && !string.IsNullOrEmpty(b.Upstream))
b.IsUpsteamGone = !remoteBranches.Contains(b.Upstream);
b.IsUpstreamGone = !remoteBranches.Contains(b.Upstream);
}

return branches;
Expand Down Expand Up @@ -86,7 +86,7 @@ private Models.Branch ParseLine(string line)
branch.Head = parts[1];
branch.IsCurrent = parts[2] == "*";
branch.Upstream = parts[3];
branch.IsUpsteamGone = false;
branch.IsUpstreamGone = false;

if (branch.IsLocal && !string.IsNullOrEmpty(parts[4]) && !parts[4].Equals("=", StringComparison.Ordinal))
branch.TrackStatus = new QueryTrackStatus(WorkingDirectory, branch.Name, branch.Upstream).Result();
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Branch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Branch
public string Upstream { get; set; }
public BranchTrackStatus TrackStatus { get; set; }
public string Remote { get; set; }
public bool IsUpsteamGone { get; set; }
public bool IsUpstreamGone { get; set; }

public string FriendlyName => IsLocal ? Name : $"{Remote}/{Name}";
}
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/BranchTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public bool IsCurrent

public bool ShowUpstreamGoneTip
{
get => Backend is Models.Branch { IsUpsteamGone: true };
get => Backend is Models.Branch { IsUpstreamGone: true };
}

public string Tooltip
Expand Down
6 changes: 5 additions & 1 deletion src/ViewModels/FastForwardWithoutCheckout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public override Task<bool> Sure()
return Task.Run(() =>
{
new Commands.UpdateRef(_repo.FullPath, Local.FullName, To.FullName, SetProgressDescription).Exec();
CallUIThread(() => _repo.SetWatcherEnabled(true));
CallUIThread(() =>
{
_repo.NavigateToCommit(To.Head);
_repo.SetWatcherEnabled(true);
});
return true;
});
}
Expand Down
9 changes: 5 additions & 4 deletions src/ViewModels/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public bool Force
set => _repo.Settings.EnableForceOnFetch = value;
}

public Fetch(Repository repo, Models.Remote preferedRemote = null)
public Fetch(Repository repo, Models.Remote preferredRemote = null)
{
_repo = repo;
_fetchAllRemotes = preferedRemote == null;
_fetchAllRemotes = preferredRemote == null;

if (preferedRemote != null)
if (preferredRemote != null)
{
SelectedRemote = preferedRemote;
SelectedRemote = preferredRemote;
}
else if (!string.IsNullOrEmpty(_repo.Settings.DefaultRemote))
{
Expand Down Expand Up @@ -83,6 +83,7 @@ public override Task<bool> Sure()

CallUIThread(() =>
{
_repo.SetNeedNavigateToUpstreamHead();
_repo.MarkFetched();
_repo.SetWatcherEnabled(true);
});
Expand Down
6 changes: 5 additions & 1 deletion src/ViewModels/FetchInto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ public override Task<bool> Sure()
return Task.Run(() =>
{
new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec();
CallUIThread(() => _repo.SetWatcherEnabled(true));
CallUIThread(() =>
{
_repo.SetNeedNavigateToUpstreamHead();
_repo.SetWatcherEnabled(true);
});
return true;
});
}
Expand Down
17 changes: 16 additions & 1 deletion src/ViewModels/Merge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,22 @@ public override Task<bool> Sure()
return Task.Run(() =>
{
new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec();
CallUIThread(() => _repo.SetWatcherEnabled(true));
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.SetWatcherEnabled(true);
});
return true;
});
}
Expand Down
6 changes: 5 additions & 1 deletion src/ViewModels/Pull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ public override Task<bool> Sure()
rs = new Commands.Stash(_repo.FullPath).Pop("stash@{0}");
}

CallUIThread(() => _repo.SetWatcherEnabled(true));
CallUIThread(() =>
{
_repo.SetNeedNavigateToUpstreamHead();
_repo.SetWatcherEnabled(true);
});
return rs;
});
}
Expand Down
20 changes: 20 additions & 0 deletions src/ViewModels/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,11 @@ public void SetWatcherEnabled(bool enabled)
_watcher?.SetEnabled(enabled);
}

public void SetNeedNavigateToUpstreamHead()
{
_needNavigateToUpstreamHead = true;
}

public void MarkBranchesDirtyManually()
{
if (_watcher == null)
Expand Down Expand Up @@ -773,6 +778,15 @@ public void NavigateToCurrentHead()
NavigateToCommit(_currentBranch.Head);
}

public void NavigateToCurrentUpstreamHead()
{
if (_currentBranch == null || string.IsNullOrEmpty(_currentBranch.Upstream))
return;
var branch = _branches.Find(x => x.FullName == _currentBranch.Upstream);
if (branch != null)
NavigateToCommit(branch.Head);
}

public void ClearHistoriesFilter()
{
_settings.HistoriesFilters.Clear();
Expand Down Expand Up @@ -991,6 +1005,11 @@ public void RefreshCommits()
_histories.IsLoading = false;
_histories.Commits = commits;
_histories.Graph = graph;
if (_needNavigateToUpstreamHead)
{
NavigateToCurrentUpstreamHead();
_needNavigateToUpstreamHead = false;
}
}
});
}
Expand Down Expand Up @@ -2588,5 +2607,6 @@ private void AutoFetchImpl(object sender)
private bool _isAutoFetching = false;
private Timer _autoFetchTimer = null;
private DateTime _lastFetchTime = DateTime.MinValue;
private bool _needNavigateToUpstreamHead = false;
}
}