mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
feature<Fast-Forward>: allow fast-forward on local branch that not checked out.
This commit is contained in:
parent
12511007e3
commit
9d6ac9c449
4 changed files with 88 additions and 1 deletions
46
src/Views/Popups/FastForwardWithoutCheckout.xaml.cs
Normal file
46
src/Views/Popups/FastForwardWithoutCheckout.xaml.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
/// <summary>
|
||||
/// 对于不是当前分支的本地分支,Fast-Forward
|
||||
/// </summary>
|
||||
public partial class FastForwardWithoutCheckout : Controls.PopupWidget {
|
||||
private string repo = null;
|
||||
private string remote = null;
|
||||
private string localBranch = null;
|
||||
private string remoteBranch = null;
|
||||
private bool isValid = false;
|
||||
|
||||
public FastForwardWithoutCheckout(string repo, string branch, string upstream) {
|
||||
int idx = upstream.IndexOf('/');
|
||||
if (idx < 0 || idx == upstream.Length - 1) {
|
||||
Models.Exception.Raise($"Invalid upstream: {upstream}");
|
||||
return;
|
||||
}
|
||||
|
||||
this.repo = repo;
|
||||
this.remote = upstream.Substring(0, idx);
|
||||
this.localBranch = branch;
|
||||
this.remoteBranch = upstream.Substring(idx+1);
|
||||
this.isValid = true;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("Fetch.Title");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
return Task.Run(() => {
|
||||
if (isValid) {
|
||||
Models.Watcher.SetEnabled(repo, false);
|
||||
new Commands.Fetch(repo, remote, localBranch, remoteBranch, UpdateProgress).Exec();
|
||||
Models.Watcher.SetEnabled(repo, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue