mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
feature: cherry-pick multiple commits (#418)
This commit is contained in:
parent
b2bbbb191c
commit
ce2340456e
11 changed files with 138 additions and 39 deletions
|
@ -1,10 +1,12 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class CherryPick : Popup
|
||||
{
|
||||
public Models.Commit Target
|
||||
public List<Models.Commit> Targets
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
|
@ -16,10 +18,10 @@ namespace SourceGit.ViewModels
|
|||
set;
|
||||
}
|
||||
|
||||
public CherryPick(Repository repo, Models.Commit target)
|
||||
public CherryPick(Repository repo, List<Models.Commit> targets)
|
||||
{
|
||||
_repo = repo;
|
||||
Target = target;
|
||||
Targets = targets;
|
||||
AutoCommit = true;
|
||||
View = new Views.CherryPick() { DataContext = this };
|
||||
}
|
||||
|
@ -27,11 +29,16 @@ namespace SourceGit.ViewModels
|
|||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = $"Cherry-Pick commit '{Target.SHA}' ...";
|
||||
ProgressDescription = $"Cherry-Pick commit(s) ...";
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.CherryPick(_repo.FullPath, Target.SHA, !AutoCommit).Exec();
|
||||
// Get commit SHAs reverted
|
||||
var builder = new StringBuilder();
|
||||
for (int i = Targets.Count - 1; i >= 0; i--)
|
||||
builder.Append($"{Targets[i].SHA} ");
|
||||
|
||||
var succ = new Commands.CherryPick(_repo.FullPath, builder.ToString(), !AutoCommit).Exec();
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return succ;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue