mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
feature: add Preferred Merge Mode
in repository configure (#1156)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
ad9021e892
commit
3049730dd5
7 changed files with 73 additions and 10 deletions
|
@ -224,6 +224,12 @@ namespace SourceGit.Models
|
|||
set;
|
||||
} = [];
|
||||
|
||||
public int PreferredMergeMode
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 0;
|
||||
|
||||
public Dictionary<string, FilterMode> CollectHistoriesFilters()
|
||||
{
|
||||
var map = new Dictionary<string, FilterMode>();
|
||||
|
|
|
@ -153,6 +153,7 @@
|
|||
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Fetch remotes automatically</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minute(s)</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.DefaultRemote" xml:space="preserve">Default Remote</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.PreferredMergeMode" xml:space="preserve">Preferred Merge Mode</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE TRACKER</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteeIssue" xml:space="preserve">Add Sample Gitee Issue Rule</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteePullRequest" xml:space="preserve">Add Sample Gitee Pull Request Rule</x:String>
|
||||
|
|
|
@ -156,6 +156,7 @@
|
|||
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">启用定时自动拉取远程更新</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">分钟</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.DefaultRemote" xml:space="preserve">默认远程</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.PreferredMergeMode" xml:space="preserve">默认合并方式</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE追踪</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleAzure" xml:space="preserve">新增匹配Azure DevOps规则</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteeIssue" xml:space="preserve">新增匹配Gitee议题规则</x:String>
|
||||
|
|
|
@ -156,6 +156,7 @@
|
|||
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">啟用定時自動提取 (fetch) 遠端更新</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">分鐘</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.DefaultRemote" xml:space="preserve">預設遠端存放庫</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.PreferredMergeMode" xml:space="preserve">首選合併模式</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">Issue 追蹤</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleAzure" xml:space="preserve">新增符合 Azure DevOps 規則</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteeIssue" xml:space="preserve">新增符合 Gitee 議題規則</x:String>
|
||||
|
|
|
@ -69,9 +69,14 @@ namespace SourceGit.ViewModels
|
|||
|
||||
private Models.MergeMode AutoSelectMergeMode()
|
||||
{
|
||||
var preferredMergeModeIdx = _repo.Settings.PreferredMergeMode;
|
||||
if (preferredMergeModeIdx < 0 || preferredMergeModeIdx > Models.MergeMode.Supported.Length)
|
||||
preferredMergeModeIdx = 0;
|
||||
|
||||
var defaultMergeMode = Models.MergeMode.Supported[preferredMergeModeIdx];
|
||||
var config = new Commands.Config(_repo.FullPath).Get($"branch.{Into}.mergeoptions");
|
||||
if (string.IsNullOrEmpty(config))
|
||||
return Models.MergeMode.Supported[0];
|
||||
return defaultMergeMode;
|
||||
if (config.Equals("--ff-only", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[1];
|
||||
if (config.Equals("--no-ff", StringComparison.Ordinal))
|
||||
|
@ -81,7 +86,7 @@ namespace SourceGit.ViewModels
|
|||
if (config.Equals("--no-commit", StringComparison.Ordinal) || config.Equals("--no-ff --no-commit", StringComparison.Ordinal))
|
||||
return Models.MergeMode.Supported[4];
|
||||
|
||||
return Models.MergeMode.Supported[0];
|
||||
return defaultMergeMode;
|
||||
}
|
||||
|
||||
private readonly Repository _repo = null;
|
||||
|
|
|
@ -36,6 +36,19 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public int PreferredMergeMode
|
||||
{
|
||||
get => _repo.Settings.PreferredMergeMode;
|
||||
set
|
||||
{
|
||||
if (_repo.Settings.PreferredMergeMode != value)
|
||||
{
|
||||
_repo.Settings.PreferredMergeMode = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool GPGCommitSigningEnabled
|
||||
{
|
||||
get;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.Git}"/>
|
||||
</TabItem.Header>
|
||||
|
||||
<Grid Margin="16,4,16,8" RowDefinitions="32,32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<Grid Margin="16,4,16,8" RowDefinitions="32,32,32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
|
@ -86,10 +86,46 @@
|
|||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Configure.Git.PreferredMergeMode}"/>
|
||||
<ComboBox Grid.Row="3" Grid.Column="1"
|
||||
Height="28" Padding="8,0"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding Source={x:Static m:MergeMode.Supported}}"
|
||||
SelectedIndex="{Binding PreferredMergeMode, Mode=TwoWay}"
|
||||
Grid.IsSharedSizeScope="True">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="m:MergeMode">
|
||||
<Grid Height="20">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeNameColumn"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeDescriptionColumn"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="MergeModeOptionColumn"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Desc}" Margin="8,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding Arg}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
|
||||
<ComboBox.SelectionBoxItemTemplate>
|
||||
<DataTemplate DataType="m:MergeMode">
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Column="0" Text="{Binding Name}" Margin="0,0,8,0"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Desc}" HorizontalAlignment="Right" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ComboBox.SelectionBoxItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Configure.Proxy}"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1"
|
||||
<TextBox Grid.Row="4" Grid.Column="1"
|
||||
Height="28"
|
||||
CornerRadius="3"
|
||||
Watermark="{DynamicResource Text.Configure.Proxy.Placeholder}"
|
||||
|
@ -101,29 +137,29 @@
|
|||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
|
||||
<TextBlock Grid.Row="4" Grid.Column="0"
|
||||
<TextBlock Grid.Row="5" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Preferences.GPG.UserKey}"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1"
|
||||
<TextBox Grid.Row="5" Grid.Column="1"
|
||||
Height="28"
|
||||
CornerRadius="3"
|
||||
Watermark="{DynamicResource Text.Preferences.GPG.UserKey.Placeholder}"
|
||||
Text="{Binding GPGUserSigningKey, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preferences.GPG.CommitEnabled}"
|
||||
IsChecked="{Binding GPGCommitSigningEnabled, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="6" Grid.Column="1"
|
||||
<CheckBox Grid.Row="7" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preferences.GPG.TagEnabled}"
|
||||
IsChecked="{Binding GPGTagSigningEnabled, Mode=TwoWay}"/>
|
||||
|
||||
<CheckBox Grid.Row="7" Grid.Column="1"
|
||||
<CheckBox Grid.Row="8" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preferences.Git.EnablePruneOnFetch}"
|
||||
IsChecked="{Binding EnablePruneOnFetch, Mode=TwoWay}"/>
|
||||
|
||||
<StackPanel Grid.Row="8" Grid.Column="1" Orientation="Horizontal">
|
||||
<StackPanel Grid.Row="9" Grid.Column="1" Orientation="Horizontal">
|
||||
<CheckBox x:Name="AutoFetchCheckBox"
|
||||
Content="{DynamicResource Text.Configure.Git.AutoFetch}"
|
||||
IsChecked="{Binding EnableAutoFetch, Mode=TwoWay}"/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue