mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-26 21:17:20 -08:00
Compare commits
3 commits
9d3a87469f
...
3dcb32aec9
Author | SHA1 | Date | |
---|---|---|---|
|
3dcb32aec9 | ||
|
029f56cb28 | ||
|
7262437385 |
4 changed files with 50 additions and 38 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace SourceGit.ViewModels
|
|||
public List<Models.Branch> LocalBranches
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public List<Models.Remote> Remotes
|
||||
|
@ -157,7 +156,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
|
||||
var remoteBranchName = _selectedRemoteBranch.Name.Replace(" (new)", "");
|
||||
var remoteBranchName = _selectedRemoteBranch.Name;
|
||||
ProgressDescription = $"Push {_selectedLocalBranch.Name} -> {_selectedRemote.Name}/{remoteBranchName} ...";
|
||||
|
||||
return Task.Run(() =>
|
||||
|
@ -187,7 +186,7 @@ namespace SourceGit.ViewModels
|
|||
branches.Add(branch);
|
||||
}
|
||||
|
||||
// If selected local branch has upstream branch. Try to find it in current remote branches.
|
||||
// If selected local branch has upstream. Try to find it in current remote branches.
|
||||
if (!string.IsNullOrEmpty(_selectedLocalBranch.Upstream))
|
||||
{
|
||||
foreach (var branch in branches)
|
||||
|
@ -201,7 +200,7 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
// Find best remote branch by name.
|
||||
// Try to find a remote branch with the same name of selected local branch.
|
||||
foreach (var branch in branches)
|
||||
{
|
||||
if (_selectedLocalBranch.Name == branch.Name)
|
||||
|
@ -215,7 +214,7 @@ namespace SourceGit.ViewModels
|
|||
// Add a fake new branch.
|
||||
var fake = new Models.Branch()
|
||||
{
|
||||
Name = $"{_selectedLocalBranch.Name} (new)",
|
||||
Name = _selectedLocalBranch.Name,
|
||||
Remote = _selectedRemote.Name,
|
||||
};
|
||||
branches.Add(fake);
|
||||
|
@ -226,7 +225,7 @@ namespace SourceGit.ViewModels
|
|||
private readonly Repository _repo = null;
|
||||
private Models.Branch _selectedLocalBranch = null;
|
||||
private Models.Remote _selectedRemote = null;
|
||||
private List<Models.Branch> _remoteBranches = new List<Models.Branch>();
|
||||
private List<Models.Branch> _remoteBranches = [];
|
||||
private Models.Branch _selectedRemoteBranch = null;
|
||||
private bool _isSetTrackOptionVisible = false;
|
||||
}
|
||||
|
|
|
@ -12,10 +12,19 @@
|
|||
Classes="bold"
|
||||
Text="{DynamicResource Text.Discard}"/>
|
||||
|
||||
<StackPanel Margin="0,6,0,0" Orientation="Horizontal">
|
||||
<Path Width="14" Height="14"
|
||||
Data="{StaticResource Icons.Error}"
|
||||
Fill="DarkOrange"/>
|
||||
<TextBlock Margin="4,0,0,0"
|
||||
Text="{DynamicResource Text.Discard.Warning}"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
|
||||
<ContentControl Margin="0,16,0,8" Content="{Binding Mode}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:DiscardAllMode">
|
||||
<Grid RowDefinitions="Auto,Auto,36" ColumnDefinitions="120,*">
|
||||
<Grid RowDefinitions="32,32" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Right"
|
||||
|
@ -26,51 +35,33 @@
|
|||
<CheckBox Grid.Row="1" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Discard.IncludeIgnored}"
|
||||
IsChecked="{Binding IncludeIgnored, Mode=TwoWay}"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="14" Height="14"
|
||||
Data="{StaticResource Icons.Error}"
|
||||
Fill="DarkOrange"/>
|
||||
<TextBlock Margin="4,0,0,0"
|
||||
Text="{DynamicResource Text.Discard.Warning}"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:DiscardSingleFile">
|
||||
<Grid RowDefinitions="32,32" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
<Grid Height="32" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{DynamicResource Text.Discard.Changes}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
|
||||
<TextBlock Text="{Binding Path}" Margin="4,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Discard.Warning}"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="vm:DiscardMultipleFiles">
|
||||
<Grid RowDefinitions="32,32" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
<Grid Height="32" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
HorizontalAlignment="Right"
|
||||
Text="{DynamicResource Text.Discard.Changes}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.File}"/>
|
||||
<TextBlock Text="{Binding Count, Converter={x:Static c:StringConverters.FormatByResourceKey}, ConverterParameter='Discard.Total'}" Margin="4,0,0,0"/>
|
||||
<TextBlock Text="{Binding Count, Converter={x:Static c:StringConverters.FormatByResourceKey}, ConverterParameter='Discard.Total'}"
|
||||
Margin="4,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Discard.Warning}"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
|
|
|
@ -65,7 +65,15 @@
|
|||
<DataTemplate x:DataType="{x:Type m:Branch}">
|
||||
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center">
|
||||
<Path Margin="0,0,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Branch}"/>
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
<TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
|
||||
<Border Height="14"
|
||||
CornerRadius="7"
|
||||
Margin="4,0,0,0" Padding="6,0"
|
||||
VerticalAlignment="Center"
|
||||
Background="Green"
|
||||
IsVisible="{Binding Head, Converter={x:Static StringConverters.IsNullOrEmpty}}">
|
||||
<TextBlock Text="NEW" FontSize="9" FontFamily="{DynamicResource Fonts.Monospace}" Foreground="White" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
|
|
Loading…
Reference in a new issue