mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 12:15:00 +00:00
feature: merge multiple heads (#793)
* feature: allow merging multiple heads * feature: allow merging multiple branches from branch tree
This commit is contained in:
parent
c9c7fb5d5b
commit
dce33fdf60
11 changed files with 232 additions and 10 deletions
59
src/ViewModels/MergeMultiple.cs
Normal file
59
src/ViewModels/MergeMultiple.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using SourceGit.Models;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class MergeMultiple : Popup
|
||||
{
|
||||
public List<string> Strategies = ["octopus", "ours"];
|
||||
|
||||
public List<Commit> Targets
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool AutoCommit
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public MergeStrategy Strategy
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public MergeMultiple(Repository repo, List<Commit> targets)
|
||||
{
|
||||
_repo = repo;
|
||||
Targets = targets;
|
||||
AutoCommit = true;
|
||||
Strategy = MergeStrategy.ForMultiple.Find(s => s.Arg == null);
|
||||
View = new Views.MergeMultiple() { DataContext = this };
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = "Merge head(s) ...";
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.Merge(
|
||||
_repo.FullPath,
|
||||
string.Join(" ", Targets.ConvertAll(c => c.Decorators.Find(d => d.Type == DecoratorType.RemoteBranchHead || d.Type == DecoratorType.LocalBranchHead)?.Name ?? c.Decorators.Find(d => d.Type == DecoratorType.Tag)?.Name ?? c.SHA)),
|
||||
AutoCommit ? string.Empty : "--no-commit",
|
||||
Strategy?.Arg,
|
||||
SetProgressDescription).Exec();
|
||||
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue