Skip to content

Commit cac4b7e

Browse files
committed
enhance: conventional commit message helper (#1200)
- add `build`, `ci`, `pref` - re-design helper dialog Signed-off-by: leo <longshuang@msn.cn>
1 parent fa44fa7 commit cac4b7e

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

src/Models/ConventionalCommitType.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,29 @@ namespace SourceGit.Models
44
{
55
public class ConventionalCommitType
66
{
7+
public string Name { get; set; } = string.Empty;
78
public string Type { get; set; } = string.Empty;
89
public string Description { get; set; } = string.Empty;
910

1011
public static readonly List<ConventionalCommitType> Supported = new List<ConventionalCommitType>()
1112
{
12-
new ConventionalCommitType("feat", "Adding a new feature"),
13-
new ConventionalCommitType("fix", "Fixing a bug"),
14-
new ConventionalCommitType("docs", "Updating documentation"),
15-
new ConventionalCommitType("style", "Elements or code styles without changing the code logic"),
16-
new ConventionalCommitType("test", "Adding or updating tests"),
17-
new ConventionalCommitType("chore", "Making changes to the build process or auxiliary tools and libraries"),
18-
new ConventionalCommitType("revert", "Undoing a previous commit"),
19-
new ConventionalCommitType("refactor", "Restructuring code without changing its external behavior")
13+
new ConventionalCommitType("Features", "feat", "Adding a new feature"),
14+
new ConventionalCommitType("Bug Fixes", "fix", "Fixing a bug"),
15+
new ConventionalCommitType("Reverts", "revert", "Undoing a previous commit"),
16+
new ConventionalCommitType("Code Refactoring", "refactor", "Restructuring code without changing its external behavior"),
17+
new ConventionalCommitType("Performance Improvements", "pref", "Improves performance"),
18+
new ConventionalCommitType("Builds", "build", "Changes that affect the build system or external dependencies"),
19+
new ConventionalCommitType("Continuous Integrations", "ci", "Changes to CI configuration files and scripts"),
20+
new ConventionalCommitType("Documentations", "docs", "Updating documentation"),
21+
new ConventionalCommitType("Styles", "style", "Elements or code styles without changing the code logic"),
22+
new ConventionalCommitType("Tests", "test", "Adding or updating tests"),
23+
new ConventionalCommitType("Chores", "chore", "Other changes that don't modify src or test files"),
24+
2025
};
2126

22-
public ConventionalCommitType(string type, string description)
27+
public ConventionalCommitType(string name, string type, string description)
2328
{
29+
Name = name;
2430
Type = type;
2531
Description = description;
2632
}

src/Views/ConventionalCommitMessageBuilder.axaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,33 @@
4848
Height="28" Padding="8,0"
4949
VerticalAlignment="Center" HorizontalAlignment="Stretch"
5050
ItemsSource="{Binding Source={x:Static m:ConventionalCommitType.Supported}}"
51-
SelectedItem="{Binding Type, Mode=TwoWay}">
51+
SelectedItem="{Binding Type, Mode=TwoWay}"
52+
Grid.IsSharedSizeScope="True">
53+
<ComboBox.SelectionBoxItemTemplate>
54+
<DataTemplate DataType="m:ConventionalCommitType">
55+
<StackPanel Orientation="Horizontal">
56+
<TextBlock Text="{Binding Name}" Margin="0,0,8,0"/>
57+
<Border Height="16" CornerRadius="8" Padding="8,0" VerticalAlignment="Center" Background="Green">
58+
<TextBlock Text="{Binding Type}" VerticalAlignment="Center" FontSize="11" Foreground="White"/>
59+
</Border>
60+
</StackPanel>
61+
</DataTemplate>
62+
</ComboBox.SelectionBoxItemTemplate>
63+
5264
<ComboBox.ItemTemplate>
53-
<DataTemplate x:DataType="{x:Type m:ConventionalCommitType}">
54-
<Grid Height="20" ColumnDefinitions="64,Auto" VerticalAlignment="Center">
55-
<TextBlock Grid.Column="0" Text="{Binding Type}"/>
56-
<TextBlock Grid.Column="1" Text="{Binding Description}" Foreground="{DynamicResource Brush.FG2}"/>
65+
<DataTemplate DataType="m:ConventionalCommitType">
66+
<Grid Height="24">
67+
<Grid.ColumnDefinitions>
68+
<ColumnDefinition Width="Auto" SharedSizeGroup="NameColumn"/>
69+
<ColumnDefinition Width="Auto" SharedSizeGroup="TypeColumn"/>
70+
<ColumnDefinition Width="Auto" SharedSizeGroup="DescriptionColumn"/>
71+
</Grid.ColumnDefinitions>
72+
73+
<TextBlock Grid.Column="0" Text="{Binding Name}"/>
74+
<Border Grid.Column="1" Height="16" CornerRadius="8" Padding="8,0" Margin="8,0,16,0" HorizontalAlignment="Left" VerticalAlignment="Center" Background="Green">
75+
<TextBlock Text="{Binding Type}" VerticalAlignment="Center" FontSize="11" Foreground="White"/>
76+
</Border>
77+
<TextBlock Grid.Column="2" Text="{Binding Description}" Foreground="{DynamicResource Brush.FG2}"/>
5778
</Grid>
5879
</DataTemplate>
5980
</ComboBox.ItemTemplate>

0 commit comments

Comments
 (0)