Compare commits

..

5 commits

Author SHA1 Message Date
leo
bb907deddb
code_style: correct the comment of invisible commit button
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
2024-09-27 23:02:25 +08:00
leo
9768b21859
code_style: use Windows, Linux instead of Default in On.Options 2024-09-27 22:58:30 +08:00
leo
f0e35b2563
ux: style for commit search box and invisible commit button 2024-09-27 22:49:46 +08:00
leo
c14c645bb9
ux: add tooltips for commit message template parameters 2024-09-27 22:33:21 +08:00
leo
9a8f4e20fb
feature: add hotkey Alt+Enter/⌥+Enter to auto stage all local changes and then commit (#521) 2024-09-27 22:21:56 +08:00
10 changed files with 68 additions and 27 deletions

View file

@ -126,11 +126,9 @@ namespace SourceGit.Commands
}
return false;
}
else
{
return true;
}
}
public ReadToEndResult ReadToEnd()
{

View file

@ -327,6 +327,7 @@
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">REPOSITORY</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">Commit staged changes</x:String>
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">Commit and push staged changes</x:String>
<x:String x:Key="Text.Hotkeys.Repo.CommitWithAutoStage" xml:space="preserve">Stage all changes and commit</x:String>
<x:String x:Key="Text.Hotkeys.Repo.DiscardSelected" xml:space="preserve">Discard selected changes</x:String>
<x:String x:Key="Text.Hotkeys.Repo.GoHome" xml:space="preserve">Dashboard mode (Default)</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Refresh" xml:space="preserve">Force to reload this repository</x:String>
@ -622,6 +623,8 @@
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">COMMIT &amp; PUSH</x:String>
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" xml:space="preserve">Template/Histories</x:String>
<x:String x:Key="Text.WorkingCopy.CommitTip" xml:space="preserve">CTRL + Enter</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">Use 'Alt+Enter' to stage all changes and commit</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage.MacOS" xml:space="preserve">Use '⌥+Enter' to stage all changes and commit</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">CONFLICTS DETECTED</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">FILE CONFLICTS ARE RESOLVED</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">INCLUDE UNTRACKED FILES</x:String>

View file

@ -330,6 +330,7 @@
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">仓库页面快捷键</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">提交暂存区更改</x:String>
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">提交暂存区更改并推送</x:String>
<x:String x:Key="Text.Hotkeys.Repo.CommitWithAutoStage" xml:space="preserve">自动暂存全部变更并提交</x:String>
<x:String x:Key="Text.Hotkeys.Repo.DiscardSelected" xml:space="preserve">丢弃选中的更改</x:String>
<x:String x:Key="Text.Hotkeys.Repo.GoHome" xml:space="preserve">切换左边栏为分支/标签等显示模式(默认)</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Refresh" xml:space="preserve">重新加载仓库状态</x:String>
@ -620,6 +621,8 @@
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">提交并推送</x:String>
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" xml:space="preserve">历史输入/模板</x:String>
<x:String x:Key="Text.WorkingCopy.CommitTip" xml:space="preserve">CTRL + Enter</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">使用 Alt+Enter 自动暂存所有变更并提交</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage.MacOS" xml:space="preserve">使用 ⌥+Enter 自动暂存所有变更并提交</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">检测到冲突</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">文件冲突已解决</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">显示未跟踪文件</x:String>

View file

@ -330,6 +330,7 @@
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">存放庫頁面快速鍵</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Commit" xml:space="preserve">提交暫存區變更</x:String>
<x:String x:Key="Text.Hotkeys.Repo.CommitAndPush" xml:space="preserve">提交暫存區變更並推送</x:String>
<x:String x:Key="Text.Hotkeys.Repo.CommitWithAutoStage" xml:space="preserve">自動暫存全部變更並提交</x:String>
<x:String x:Key="Text.Hotkeys.Repo.DiscardSelected" xml:space="preserve">捨棄選取的變更</x:String>
<x:String x:Key="Text.Hotkeys.Repo.GoHome" xml:space="preserve">切換左邊欄為分支/標籤等顯示模式 (預設)</x:String>
<x:String x:Key="Text.Hotkeys.Repo.Refresh" xml:space="preserve">強制重新載入存放庫</x:String>
@ -625,6 +626,8 @@
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">提交並推送</x:String>
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" xml:space="preserve">歷史輸入/範本</x:String>
<x:String x:Key="Text.WorkingCopy.CommitTip" xml:space="preserve">CTRL + Enter</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage" xml:space="preserve">使用 Alt+Enter 自動暫存全部變更並提交</x:String>
<x:String x:Key="Text.WorkingCopy.CommitWithAutoStage.MacOS" xml:space="preserve">使用 ⌥+Enter 自動暫存全部變更並提交</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts" xml:space="preserve">檢測到衝突</x:String>
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" xml:space="preserve">檔案衝突已解決</x:String>
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">顯示未追蹤檔案</x:String>

View file

@ -240,11 +240,6 @@ namespace SourceGit.ViewModels
_cached = changes;
_count = _cached.Count;
var unstaged = new List<Models.Change>();
var staged = new List<Models.Change>();
var selectedUnstaged = new List<Models.Change>();
var selectedStaged = new List<Models.Change>();
var lastSelectedUnstaged = new HashSet<string>();
var lastSelectedStaged = new HashSet<string>();
if (_selectedUnstaged != null && _selectedUnstaged.Count > 0)
@ -258,6 +253,8 @@ namespace SourceGit.ViewModels
lastSelectedStaged.Add(c.Path);
}
var unstaged = new List<Models.Change>();
var selectedUnstaged = new List<Models.Change>();
var hasConflict = false;
foreach (var c in changes)
{
@ -271,7 +268,8 @@ namespace SourceGit.ViewModels
}
}
staged = GetStagedChanges();
var staged = GetStagedChanges();
var selectedStaged = new List<Models.Change>();
foreach (var c in staged)
{
if (lastSelectedStaged.Contains(c.Path))
@ -418,12 +416,17 @@ namespace SourceGit.ViewModels
public void Commit()
{
DoCommit(false);
DoCommit(AutoStageBeforeCommit, false);
}
public void CommitWithAutoStage()
{
DoCommit(true, false);
}
public void CommitWithPush()
{
DoCommit(true);
DoCommit(AutoStageBeforeCommit, true);
}
public ContextMenu CreateContextMenuForUnstagedChanges()
@ -1276,7 +1279,7 @@ namespace SourceGit.ViewModels
_repo.SetWatcherEnabled(true);
}
private void DoCommit(bool autoPush)
private void DoCommit(bool autoStage, bool autoPush)
{
if (!PopupHost.CanCreatePopup())
{
@ -1290,7 +1293,6 @@ namespace SourceGit.ViewModels
return;
}
var autoStage = AutoStageBeforeCommit;
if (!_useAmend)
{
if (autoStage)

View file

@ -78,7 +78,7 @@
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
Margin="0,8"/>
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
<Grid RowDefinitions="20,20,20,20,20,20,20,20,20,20,20" ColumnDefinitions="150,*">
<TextBlock Grid.Row="0" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+H, macOS=⌘+⇧+H}"/>
<TextBlock Grid.Row="0" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.GoHome}" />
@ -103,11 +103,14 @@
<TextBlock Grid.Row="7" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"/>
<TextBlock Grid.Row="7" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Commit}" />
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+Enter, macOS=⌘+⇧+Enter}"/>
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.CommitAndPush}" />
<TextBlock Grid.Row="8" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Alt+Enter, macOS=⌥+Enter}"/>
<TextBlock Grid.Row="8" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.CommitWithAutoStage}" />
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="F5"/>
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Refresh}" />
<TextBlock Grid.Row="9" Grid.Column="0" Classes="primary bold" Text="{OnPlatform Ctrl+Shift+Enter, macOS=⌘+⇧+Enter}"/>
<TextBlock Grid.Row="9" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.CommitAndPush}" />
<TextBlock Grid.Row="10" Grid.Column="0" Classes="primary bold" Text="F5"/>
<TextBlock Grid.Row="10" Grid.Column="1" Margin="16,0,0,0" Text="{DynamicResource Text.Hotkeys.Repo.Refresh}" />
</Grid>
<TextBlock Text="{DynamicResource Text.Hotkeys.TextEditor}"

View file

@ -348,7 +348,7 @@
BorderThickness="1"
BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}"
CornerRadius="4"
CornerRadius="12"
Watermark="{DynamicResource Text.Repository.Search}"
Text="{Binding SearchCommitFilter, Mode=TwoWay}"
VerticalContentAlignment="Center"

View file

@ -206,7 +206,11 @@
<TextBox Margin="0,4,0,0" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>
<TextBlock Margin="0,12,0,0" Text="{DynamicResource Text.Configure.CommitMessageTemplate.Content}"/>
<v:CommitMessageTextBox Height="150" Text="{Binding Content, Mode=TwoWay}"/>
<v:CommitMessageTextBox Margin="0,4,0,0" Height="100" Text="{Binding Content, Mode=TwoWay}"/>
<TextBlock Margin="0,2,0,0"
Text="You can use ${files_num}, ${files} and ${files:N} where N is the max number of file paths to output."
Foreground="{DynamicResource Brush.FG2}"
TextWrapping="Wrap"/>
</StackPanel>
</DataTemplate>
</ContentControl.DataTemplates>

View file

@ -177,7 +177,7 @@
<v:CommitMessageTextBox Grid.Row="2" Text="{Binding CommitMessage, Mode=TwoWay}"/>
<!-- Commit Options -->
<Grid Grid.Row="3" Margin="0,6,0,0" ColumnDefinitions="Auto,Auto,Auto,Auto,*,Auto,Auto,Auto">
<Grid Grid.Row="3" Margin="0,6,0,0" ColumnDefinitions="Auto,Auto,Auto,Auto,*,Auto,Auto,Auto,Auto">
<Button Grid.Column="0"
Classes="icon_button"
Margin="4,0,0,0" Padding="0"
@ -185,7 +185,7 @@
ToolTip.Tip="{DynamicResource Text.WorkingCopy.CommitMessageHelper}"
ToolTip.Placement="Top"
ToolTip.VerticalOffset="0">
<Path Grid.Column="0" Width="12" Height="12" Data="{StaticResource Icons.Menu}"/>
<Path Width="12" Height="12" Data="{StaticResource Icons.Menu}"/>
</Button>
<Button Grid.Column="1"
@ -223,11 +223,37 @@
Padding="8,0"
Command="{Binding Commit}"
HotKey="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"
ToolTip.Tip="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"
ToolTip.Placement="Top"
ToolTip.VerticalOffset="0"/>
ToolTip.VerticalOffset="0">
<ToolTip.Tip>
<StackPanel Orientation="Vertical">
<TextBlock Text="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"/>
<TextBlock Classes="small italic"
Margin="0,4,0,0"
Foreground="{DynamicResource Brush.FG2}">
<TextBlock.Text>
<OnPlatform>
<On Options="Windows, Linux">
<DynamicResource ResourceKey="Text.WorkingCopy.CommitWithAutoStage"/>
</On>
<On Options="macOS">
<DynamicResource ResourceKey="Text.WorkingCopy.CommitWithAutoStage.MacOS"/>
</On>
</OnPlatform>
</TextBlock.Text>
</TextBlock>
</StackPanel>
</ToolTip.Tip>
</Button>
<!-- Invisible button just to add another hotkey `Alt+Enter/⌥+Enter` to commit with auto-stage -->
<Button Grid.Column="7"
Width="0" Height="0"
Background="Transparent"
Command="{Binding CommitWithAutoStage}"
HotKey="Alt+Enter"/>
<Button Grid.Column="8"
Classes="flat"
Content="{DynamicResource Text.WorkingCopy.CommitAndPush}"
Height="28"

View file

@ -81,7 +81,6 @@ namespace SourceGit.Views
{
vm.Discard(selected);
e.Handled = true;
return;
}
}
}