mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
feature: the default merge option supports reading branch.<name>.mergeoptions
configuration (#540)
This commit is contained in:
parent
7262437385
commit
029f56cb28
1 changed files with 18 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
|
@ -7,13 +8,11 @@ namespace SourceGit.ViewModels
|
|||
public string Source
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string Into
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Models.MergeMode SelectedMode
|
||||
|
@ -27,7 +26,7 @@ namespace SourceGit.ViewModels
|
|||
_repo = repo;
|
||||
Source = source;
|
||||
Into = into;
|
||||
SelectedMode = Models.MergeMode.Supported[0];
|
||||
SelectedMode = AutoSelectMergeMode();
|
||||
View = new Views.Merge() { DataContext = this };
|
||||
}
|
||||
|
||||
|
@ -44,6 +43,21 @@ namespace SourceGit.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
private Models.MergeMode AutoSelectMergeMode()
|
||||
{
|
||||
var config = new Commands.Config(_repo.FullPath).Get($"branch.{Into}.mergeoptions");
|
||||
if (string.IsNullOrEmpty(config))
|
||||
return Models.MergeMode.Supported[0];
|
||||
if (config.Equals("--no-ff", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[1];
|
||||
if (config.Equals("--squash", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[2];
|
||||
if (config.Equals("--no-commit", StringComparison.Ordinal) || config.Equals("--no-ff --no-commit", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[3];
|
||||
|
||||
return Models.MergeMode.Supported[0];
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue