Compare commits

..

7 commits

9 changed files with 90 additions and 51 deletions

View file

@ -206,6 +206,9 @@ dotnet_diagnostic.CA1854.severity = warning
#CA2211:Non-constant fields should not be visible #CA2211:Non-constant fields should not be visible
dotnet_diagnostic.CA2211.severity = error dotnet_diagnostic.CA2211.severity = error
# IDE0005: remove used namespace using
dotnet_diagnostic.IDE0005.severity = error
# Wrapping preferences # Wrapping preferences
csharp_wrap_before_ternary_opsigns = false csharp_wrap_before_ternary_opsigns = false

View file

@ -5,7 +5,7 @@
## How to build this project manually ## How to build this project manually
1. Make sure [.NET SDK 8](https://dotnet.microsoft.com/en-us/download) is installed on your machine. 1. Make sure [.NET SDK 9](https://dotnet.microsoft.com/en-us/download) is installed on your machine.
2. Clone this project 2. Clone this project
3. Run the follow command under the project root dir 3. Run the follow command under the project root dir
```sh ```sh

View file

@ -164,12 +164,7 @@ namespace SourceGit
var resDic = new ResourceDictionary(); var resDic = new ResourceDictionary();
var overrides = JsonSerializer.Deserialize(File.ReadAllText(themeOverridesFile), JsonCodeGen.Default.ThemeOverrides); var overrides = JsonSerializer.Deserialize(File.ReadAllText(themeOverridesFile), JsonCodeGen.Default.ThemeOverrides);
foreach (var kv in overrides.BasicColors) foreach (var kv in overrides.BasicColors)
{ resDic[$"Color.{kv.Key}"] = kv.Value;
if (kv.Key.Equals("SystemAccentColor", StringComparison.Ordinal))
resDic["SystemAccentColor"] = kv.Value;
else
resDic[$"Color.{kv.Key}"] = kv.Value;
}
if (overrides.GraphColors.Count > 0) if (overrides.GraphColors.Count > 0)
Models.CommitGraph.SetPens(overrides.GraphColors, overrides.GraphPenThickness); Models.CommitGraph.SetPens(overrides.GraphColors, overrides.GraphPenThickness);

View file

@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace SourceGit.Commands namespace SourceGit.Commands

View file

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SourceGit.ViewModels namespace SourceGit.ViewModels

View file

@ -795,6 +795,8 @@ namespace SourceGit.ViewModels
submenu.Icon = App.CreateMenuIcon("Icons.Branch"); submenu.Icon = App.CreateMenuIcon("Icons.Branch");
submenu.Header = current.Name; submenu.Header = current.Name;
FillBranchVisibilityMenu(submenu, current);
if (!string.IsNullOrEmpty(current.Upstream)) if (!string.IsNullOrEmpty(current.Upstream))
{ {
var upstream = current.Upstream.Substring(13); var upstream = current.Upstream.Substring(13);
@ -834,6 +836,17 @@ namespace SourceGit.ViewModels
e.Handled = true; e.Handled = true;
}; };
submenu.Items.Add(push); submenu.Items.Add(push);
var rename = new MenuItem();
rename.Header = new Views.NameHighlightedTextBlock("BranchCM.Rename", current.Name);
rename.Icon = App.CreateMenuIcon("Icons.Rename");
rename.Click += (_, e) =>
{
if (PopupHost.CanCreatePopup())
PopupHost.ShowPopup(new RenameBranch(_repo, current));
e.Handled = true;
};
submenu.Items.Add(rename);
submenu.Items.Add(new MenuItem() { Header = "-" }); submenu.Items.Add(new MenuItem() { Header = "-" });
var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, current.Name); var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, current.Name);
@ -852,18 +865,15 @@ namespace SourceGit.ViewModels
submenu.Items.Add(new MenuItem() { Header = "-" }); submenu.Items.Add(new MenuItem() { Header = "-" });
} }
FillBranchVisibilityMenu(submenu, current); var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
var rename = new MenuItem(); copy.Icon = App.CreateMenuIcon("Icons.Copy");
rename.Header = new Views.NameHighlightedTextBlock("BranchCM.Rename", current.Name); copy.Click += (_, e) =>
rename.Icon = App.CreateMenuIcon("Icons.Rename");
rename.Click += (_, e) =>
{ {
if (PopupHost.CanCreatePopup()) App.CopyText(current.Name);
PopupHost.ShowPopup(new RenameBranch(_repo, current));
e.Handled = true; e.Handled = true;
}; };
submenu.Items.Add(rename); submenu.Items.Add(copy);
menu.Items.Add(submenu); menu.Items.Add(submenu);
} }
@ -874,6 +884,8 @@ namespace SourceGit.ViewModels
submenu.Icon = App.CreateMenuIcon("Icons.Branch"); submenu.Icon = App.CreateMenuIcon("Icons.Branch");
submenu.Header = branch.Name; submenu.Header = branch.Name;
FillBranchVisibilityMenu(submenu, branch);
var checkout = new MenuItem(); var checkout = new MenuItem();
checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", branch.Name); checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", branch.Name);
checkout.Icon = App.CreateMenuIcon("Icons.Check"); checkout.Icon = App.CreateMenuIcon("Icons.Check");
@ -895,25 +907,6 @@ namespace SourceGit.ViewModels
e.Handled = true; e.Handled = true;
}; };
submenu.Items.Add(merge); submenu.Items.Add(merge);
submenu.Items.Add(new MenuItem() { Header = "-" });
var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, branch.Name);
if (detect.IsGitFlowBranch)
{
var finish = new MenuItem();
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", branch.Name);
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
finish.Click += (_, e) =>
{
if (PopupHost.CanCreatePopup())
PopupHost.ShowPopup(new GitFlowFinish(_repo, branch, detect.Type, detect.Prefix));
e.Handled = true;
};
submenu.Items.Add(finish);
submenu.Items.Add(new MenuItem() { Header = "-" });
}
FillBranchVisibilityMenu(submenu, branch);
var rename = new MenuItem(); var rename = new MenuItem();
rename.Header = new Views.NameHighlightedTextBlock("BranchCM.Rename", branch.Name); rename.Header = new Views.NameHighlightedTextBlock("BranchCM.Rename", branch.Name);
@ -936,6 +929,33 @@ namespace SourceGit.ViewModels
e.Handled = true; e.Handled = true;
}; };
submenu.Items.Add(delete); submenu.Items.Add(delete);
submenu.Items.Add(new MenuItem() { Header = "-" });
var detect = Commands.GitFlow.DetectType(_repo.FullPath, _repo.Branches, branch.Name);
if (detect.IsGitFlowBranch)
{
var finish = new MenuItem();
finish.Header = new Views.NameHighlightedTextBlock("BranchCM.Finish", branch.Name);
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
finish.Click += (_, e) =>
{
if (PopupHost.CanCreatePopup())
PopupHost.ShowPopup(new GitFlowFinish(_repo, branch, detect.Type, detect.Prefix));
e.Handled = true;
};
submenu.Items.Add(finish);
submenu.Items.Add(new MenuItem() { Header = "-" });
}
var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Click += (_, e) =>
{
App.CopyText(branch.Name);
e.Handled = true;
};
submenu.Items.Add(copy);
menu.Items.Add(submenu); menu.Items.Add(submenu);
} }
@ -948,6 +968,8 @@ namespace SourceGit.ViewModels
submenu.Icon = App.CreateMenuIcon("Icons.Branch"); submenu.Icon = App.CreateMenuIcon("Icons.Branch");
submenu.Header = name; submenu.Header = name;
FillBranchVisibilityMenu(submenu, branch);
var checkout = new MenuItem(); var checkout = new MenuItem();
checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", name); checkout.Header = new Views.NameHighlightedTextBlock("BranchCM.Checkout", name);
checkout.Icon = App.CreateMenuIcon("Icons.Check"); checkout.Icon = App.CreateMenuIcon("Icons.Check");
@ -970,9 +992,6 @@ namespace SourceGit.ViewModels
}; };
submenu.Items.Add(merge); submenu.Items.Add(merge);
submenu.Items.Add(new MenuItem() { Header = "-" });
FillBranchVisibilityMenu(submenu, branch);
var delete = new MenuItem(); var delete = new MenuItem();
delete.Header = new Views.NameHighlightedTextBlock("BranchCM.Delete", name); delete.Header = new Views.NameHighlightedTextBlock("BranchCM.Delete", name);
@ -984,6 +1003,17 @@ namespace SourceGit.ViewModels
e.Handled = true; e.Handled = true;
}; };
submenu.Items.Add(delete); submenu.Items.Add(delete);
submenu.Items.Add(new MenuItem() { Header = "-" });
var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Click += (_, e) =>
{
App.CopyText(name);
e.Handled = true;
};
submenu.Items.Add(copy);
menu.Items.Add(submenu); menu.Items.Add(submenu);
} }
@ -995,6 +1025,8 @@ namespace SourceGit.ViewModels
submenu.Icon = App.CreateMenuIcon("Icons.Tag"); submenu.Icon = App.CreateMenuIcon("Icons.Tag");
submenu.MinWidth = 200; submenu.MinWidth = 200;
FillTagVisibilityMenu(submenu, tag);
var push = new MenuItem(); var push = new MenuItem();
push.Header = new Views.NameHighlightedTextBlock("TagCM.Push", tag.Name); push.Header = new Views.NameHighlightedTextBlock("TagCM.Push", tag.Name);
push.Icon = App.CreateMenuIcon("Icons.Push"); push.Icon = App.CreateMenuIcon("Icons.Push");
@ -1018,9 +1050,6 @@ namespace SourceGit.ViewModels
e.Handled = true; e.Handled = true;
}; };
submenu.Items.Add(merge); submenu.Items.Add(merge);
submenu.Items.Add(new MenuItem() { Header = "-" });
FillTagVisibilityMenu(submenu, tag);
var delete = new MenuItem(); var delete = new MenuItem();
delete.Header = new Views.NameHighlightedTextBlock("TagCM.Delete", tag.Name); delete.Header = new Views.NameHighlightedTextBlock("TagCM.Delete", tag.Name);
@ -1032,6 +1061,17 @@ namespace SourceGit.ViewModels
e.Handled = true; e.Handled = true;
}; };
submenu.Items.Add(delete); submenu.Items.Add(delete);
submenu.Items.Add(new MenuItem() { Header = "-" });
var copy = new MenuItem();
copy.Header = App.Text("TagCM.Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Click += (_, e) =>
{
App.CopyText(tag.Name);
e.Handled = true;
};
submenu.Items.Add(copy);
menu.Items.Add(submenu); menu.Items.Add(submenu);
} }

View file

@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using Avalonia.Collections; using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;

View file

@ -296,7 +296,8 @@ namespace SourceGit.Views
if (currentParent is { DataContext: ViewModels.CommitDetail currentDetail } && if (currentParent is { DataContext: ViewModels.CommitDetail currentDetail } &&
currentDetail.Commit.SHA == lastDetailCommit) currentDetail.Commit.SHA == lastDetailCommit)
{ {
_inlineCommits.Add(sha, c); if (!_inlineCommits.ContainsKey(sha))
_inlineCommits.Add(sha, c);
// Make sure user still hovers the target SHA. // Make sure user still hovers the target SHA.
if (_lastHover == link && c != null) if (_lastHover == link && c != null)

View file

@ -79,10 +79,13 @@
<Grid ColumnDefinitions="16,110,*,140,96,156,32,32"> <Grid ColumnDefinitions="16,110,*,140,96,156,32,32">
<!-- Drag & Drop Anchor --> <!-- Drag & Drop Anchor -->
<Border Grid.Column="0" Background="Transparent" <Border Grid.Column="0" Background="Transparent"
Margin="4,0,0,0"
Loaded="OnSetupRowHeaderDragDrop" Loaded="OnSetupRowHeaderDragDrop"
PointerPressed="OnRowHeaderPointerPressed"> PointerPressed="OnRowHeaderPointerPressed">
<Path Width="14" Height="14" Data="{StaticResource Icons.Move}" Fill="{DynamicResource Brush.FG2}"/> <Path Width="14" Height="14"
Data="{StaticResource Icons.Move}"
Fill="{DynamicResource Brush.FG2}"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border> </Border>
<!-- Action --> <!-- Action -->
@ -171,7 +174,7 @@
<!-- Subject --> <!-- Subject -->
<Grid Grid.Column="2" ColumnDefinitions="Auto,*" ClipToBounds="True"> <Grid Grid.Column="2" ColumnDefinitions="Auto,*" ClipToBounds="True">
<Button Grid.Column="0" Classes="icon_button" IsVisible="{Binding Action, Converter={x:Static c:InteractiveRebaseActionConverters.CanEditMessage}}"> <Button Grid.Column="0" Classes="icon_button" Margin="0,0,8,0" IsVisible="{Binding Action, Converter={x:Static c:InteractiveRebaseActionConverters.CanEditMessage}}">
<Button.Flyout> <Button.Flyout>
<Flyout Placement="BottomEdgeAlignedLeft"> <Flyout Placement="BottomEdgeAlignedLeft">
<Panel Width="600" Height="120"> <Panel Width="600" Height="120">
@ -181,7 +184,7 @@
</Button.Flyout> </Button.Flyout>
<Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Edit}"/> <Path Width="14" Height="14" Margin="0,4,0,0" Data="{StaticResource Icons.Edit}"/>
</Button> </Button>
<TextBlock Grid.Column="1" Classes="primary" Text="{Binding Subject}" Margin="8,0,0,0"/> <TextBlock Grid.Column="1" Classes="primary" Margin="0,0,4,0" Text="{Binding Subject}"/>
</Grid> </Grid>
<!-- Author --> <!-- Author -->