ux: new style for pushing a new branch to remote

This commit is contained in:
leo 2024-10-06 21:48:26 +08:00
parent 9d3a87469f
commit 7262437385
No known key found for this signature in database
2 changed files with 14 additions and 7 deletions

View file

@ -26,7 +26,6 @@ namespace SourceGit.ViewModels
public List<Models.Branch> LocalBranches public List<Models.Branch> LocalBranches
{ {
get; get;
private set;
} }
public List<Models.Remote> Remotes public List<Models.Remote> Remotes
@ -157,7 +156,7 @@ namespace SourceGit.ViewModels
{ {
_repo.SetWatcherEnabled(false); _repo.SetWatcherEnabled(false);
var remoteBranchName = _selectedRemoteBranch.Name.Replace(" (new)", ""); var remoteBranchName = _selectedRemoteBranch.Name;
ProgressDescription = $"Push {_selectedLocalBranch.Name} -> {_selectedRemote.Name}/{remoteBranchName} ..."; ProgressDescription = $"Push {_selectedLocalBranch.Name} -> {_selectedRemote.Name}/{remoteBranchName} ...";
return Task.Run(() => return Task.Run(() =>
@ -187,7 +186,7 @@ namespace SourceGit.ViewModels
branches.Add(branch); 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)) if (!string.IsNullOrEmpty(_selectedLocalBranch.Upstream))
{ {
foreach (var branch in branches) 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) foreach (var branch in branches)
{ {
if (_selectedLocalBranch.Name == branch.Name) if (_selectedLocalBranch.Name == branch.Name)
@ -215,7 +214,7 @@ namespace SourceGit.ViewModels
// Add a fake new branch. // Add a fake new branch.
var fake = new Models.Branch() var fake = new Models.Branch()
{ {
Name = $"{_selectedLocalBranch.Name} (new)", Name = _selectedLocalBranch.Name,
Remote = _selectedRemote.Name, Remote = _selectedRemote.Name,
}; };
branches.Add(fake); branches.Add(fake);
@ -226,7 +225,7 @@ namespace SourceGit.ViewModels
private readonly Repository _repo = null; private readonly Repository _repo = null;
private Models.Branch _selectedLocalBranch = null; private Models.Branch _selectedLocalBranch = null;
private Models.Remote _selectedRemote = 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 Models.Branch _selectedRemoteBranch = null;
private bool _isSetTrackOptionVisible = false; private bool _isSetTrackOptionVisible = false;
} }

View file

@ -65,7 +65,15 @@
<DataTemplate x:DataType="{x:Type m:Branch}"> <DataTemplate x:DataType="{x:Type m:Branch}">
<StackPanel Orientation="Horizontal" Height="20" VerticalAlignment="Center"> <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}"/> <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> </StackPanel>
</DataTemplate> </DataTemplate>
</ComboBox.ItemTemplate> </ComboBox.ItemTemplate>