mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-20 11:44:59 +00:00
enhance: navigate to upstream head after fetch, pull, and merge (#1180)
This commit is contained in:
parent
245de9b458
commit
17cf402c78
9 changed files with 60 additions and 12 deletions
|
@ -40,7 +40,7 @@ namespace SourceGit.Commands
|
||||||
foreach (var b in branches)
|
foreach (var b in branches)
|
||||||
{
|
{
|
||||||
if (b.IsLocal && !string.IsNullOrEmpty(b.Upstream))
|
if (b.IsLocal && !string.IsNullOrEmpty(b.Upstream))
|
||||||
b.IsUpsteamGone = !remoteBranches.Contains(b.Upstream);
|
b.IsUpstreamGone = !remoteBranches.Contains(b.Upstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
return branches;
|
return branches;
|
||||||
|
@ -86,7 +86,7 @@ namespace SourceGit.Commands
|
||||||
branch.Head = parts[1];
|
branch.Head = parts[1];
|
||||||
branch.IsCurrent = parts[2] == "*";
|
branch.IsCurrent = parts[2] == "*";
|
||||||
branch.Upstream = parts[3];
|
branch.Upstream = parts[3];
|
||||||
branch.IsUpsteamGone = false;
|
branch.IsUpstreamGone = false;
|
||||||
|
|
||||||
if (branch.IsLocal && !string.IsNullOrEmpty(parts[4]) && !parts[4].Equals("=", StringComparison.Ordinal))
|
if (branch.IsLocal && !string.IsNullOrEmpty(parts[4]) && !parts[4].Equals("=", StringComparison.Ordinal))
|
||||||
branch.TrackStatus = new QueryTrackStatus(WorkingDirectory, branch.Name, branch.Upstream).Result();
|
branch.TrackStatus = new QueryTrackStatus(WorkingDirectory, branch.Name, branch.Upstream).Result();
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace SourceGit.Models
|
||||||
public string Upstream { get; set; }
|
public string Upstream { get; set; }
|
||||||
public BranchTrackStatus TrackStatus { get; set; }
|
public BranchTrackStatus TrackStatus { get; set; }
|
||||||
public string Remote { get; set; }
|
public string Remote { get; set; }
|
||||||
public bool IsUpsteamGone { get; set; }
|
public bool IsUpstreamGone { get; set; }
|
||||||
|
|
||||||
public string FriendlyName => IsLocal ? Name : $"{Remote}/{Name}";
|
public string FriendlyName => IsLocal ? Name : $"{Remote}/{Name}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public bool ShowUpstreamGoneTip
|
public bool ShowUpstreamGoneTip
|
||||||
{
|
{
|
||||||
get => Backend is Models.Branch { IsUpsteamGone: true };
|
get => Backend is Models.Branch { IsUpstreamGone: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Tooltip
|
public string Tooltip
|
||||||
|
|
|
@ -32,7 +32,11 @@ namespace SourceGit.ViewModels
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
new Commands.UpdateRef(_repo.FullPath, Local.FullName, To.FullName, SetProgressDescription).Exec();
|
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;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,14 @@ namespace SourceGit.ViewModels
|
||||||
set => _repo.Settings.EnableForceOnFetch = value;
|
set => _repo.Settings.EnableForceOnFetch = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fetch(Repository repo, Models.Remote preferedRemote = null)
|
public Fetch(Repository repo, Models.Remote preferredRemote = null)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_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))
|
else if (!string.IsNullOrEmpty(_repo.Settings.DefaultRemote))
|
||||||
{
|
{
|
||||||
|
@ -83,6 +83,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
{
|
{
|
||||||
|
_repo.SetNeedNavigateToUpstreamHead();
|
||||||
_repo.MarkFetched();
|
_repo.MarkFetched();
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,7 +32,11 @@ namespace SourceGit.ViewModels
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec();
|
new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec();
|
||||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
CallUIThread(() =>
|
||||||
|
{
|
||||||
|
_repo.SetNeedNavigateToUpstreamHead();
|
||||||
|
_repo.SetWatcherEnabled(true);
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,22 @@ namespace SourceGit.ViewModels
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
new Commands.Merge(_repo.FullPath, _sourceName, Mode.Arg, SetProgressDescription).Exec();
|
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;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,11 @@ namespace SourceGit.ViewModels
|
||||||
rs = new Commands.Stash(_repo.FullPath).Pop("stash@{0}");
|
rs = new Commands.Stash(_repo.FullPath).Pop("stash@{0}");
|
||||||
}
|
}
|
||||||
|
|
||||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
CallUIThread(() =>
|
||||||
|
{
|
||||||
|
_repo.SetNeedNavigateToUpstreamHead();
|
||||||
|
_repo.SetWatcherEnabled(true);
|
||||||
|
});
|
||||||
return rs;
|
return rs;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,6 +717,11 @@ namespace SourceGit.ViewModels
|
||||||
_watcher?.SetEnabled(enabled);
|
_watcher?.SetEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetNeedNavigateToUpstreamHead()
|
||||||
|
{
|
||||||
|
_needNavigateToUpstreamHead = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void MarkBranchesDirtyManually()
|
public void MarkBranchesDirtyManually()
|
||||||
{
|
{
|
||||||
if (_watcher == null)
|
if (_watcher == null)
|
||||||
|
@ -773,6 +778,15 @@ namespace SourceGit.ViewModels
|
||||||
NavigateToCommit(_currentBranch.Head);
|
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()
|
public void ClearHistoriesFilter()
|
||||||
{
|
{
|
||||||
_settings.HistoriesFilters.Clear();
|
_settings.HistoriesFilters.Clear();
|
||||||
|
@ -991,6 +1005,11 @@ namespace SourceGit.ViewModels
|
||||||
_histories.IsLoading = false;
|
_histories.IsLoading = false;
|
||||||
_histories.Commits = commits;
|
_histories.Commits = commits;
|
||||||
_histories.Graph = graph;
|
_histories.Graph = graph;
|
||||||
|
if (_needNavigateToUpstreamHead)
|
||||||
|
{
|
||||||
|
NavigateToCurrentUpstreamHead();
|
||||||
|
_needNavigateToUpstreamHead = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2588,5 +2607,6 @@ namespace SourceGit.ViewModels
|
||||||
private bool _isAutoFetching = false;
|
private bool _isAutoFetching = false;
|
||||||
private Timer _autoFetchTimer = null;
|
private Timer _autoFetchTimer = null;
|
||||||
private DateTime _lastFetchTime = DateTime.MinValue;
|
private DateTime _lastFetchTime = DateTime.MinValue;
|
||||||
|
private bool _needNavigateToUpstreamHead = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue