mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-30 22:01:10 +08:00
feature: allow fetch the latest remote changes into local branch which is not current branch (#617)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
42
src/ViewModels/FetchInto.cs
Normal file
42
src/ViewModels/FetchInto.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class FetchInto : Popup
|
||||
{
|
||||
public Models.Branch Local
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Models.Branch Upstream
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public FetchInto(Repository repo, Models.Branch local, Models.Branch upstream)
|
||||
{
|
||||
_repo = repo;
|
||||
Local = local;
|
||||
Upstream = upstream;
|
||||
View = new Views.FetchInto() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = "Fast-Forward ...";
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
new Commands.Fetch(_repo.FullPath, Local, Upstream, SetProgressDescription).Exec();
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
}
|
||||
}
|
||||
@@ -1354,6 +1354,7 @@ namespace SourceGit.ViewModels
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(checkout);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
|
||||
var worktree = _worktrees.Find(x => x.Branch == branch.FullName);
|
||||
var upstream = _branches.Find(x => x.FullName == branch.Upstream);
|
||||
@@ -1370,11 +1371,22 @@ namespace SourceGit.ViewModels
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
var fetchInto = new MenuItem();
|
||||
fetchInto.Header = new Views.NameHighlightedTextBlock("BranchCM.FetchInto", upstream.FriendlyName, branch.Name);
|
||||
fetchInto.Icon = App.CreateMenuIcon("Icons.Fetch");
|
||||
fetchInto.IsEnabled = branch.TrackStatus.Ahead.Count == 0;
|
||||
fetchInto.Click += (_, e) =>
|
||||
{
|
||||
if (PopupHost.CanCreatePopup())
|
||||
PopupHost.ShowAndStartPopup(new FetchInto(this, branch, upstream));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(fastForward);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(fetchInto);
|
||||
}
|
||||
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(push);
|
||||
|
||||
var merge = new MenuItem();
|
||||
|
||||
Reference in New Issue
Block a user