mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: add hotkey Alt+Enter/⌥+Enter
to auto stage all local changes and then commit (#521)
This commit is contained in:
parent
2346082228
commit
9a8f4e20fb
8 changed files with 60 additions and 23 deletions
|
@ -126,11 +126,9 @@ namespace SourceGit.Commands
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public ReadToEndResult ReadToEnd()
|
public ReadToEndResult ReadToEnd()
|
||||||
{
|
{
|
||||||
|
|
|
@ -327,6 +327,7 @@
|
||||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">REPOSITORY</x:String>
|
<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.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.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.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.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>
|
<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 & PUSH</x:String>
|
<x:String x:Key="Text.WorkingCopy.CommitAndPush" xml:space="preserve">COMMIT & PUSH</x:String>
|
||||||
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" xml:space="preserve">Template/Histories</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.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" 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.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>
|
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">INCLUDE UNTRACKED FILES</x:String>
|
||||||
|
|
|
@ -330,6 +330,7 @@
|
||||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">仓库页面快捷键</x:String>
|
<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.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.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.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.GoHome" xml:space="preserve">切换左边栏为分支/标签等显示模式(默认)</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.Repo.Refresh" 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.CommitAndPush" xml:space="preserve">提交并推送</x:String>
|
||||||
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" 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.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" xml:space="preserve">检测到冲突</x:String>
|
||||||
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" 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>
|
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">显示未跟踪文件</x:String>
|
||||||
|
|
|
@ -330,6 +330,7 @@
|
||||||
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">存放庫頁面快速鍵</x:String>
|
<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.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.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.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.GoHome" xml:space="preserve">切換左邊欄為分支/標籤等顯示模式 (預設)</x:String>
|
||||||
<x:String x:Key="Text.Hotkeys.Repo.Refresh" 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.CommitAndPush" xml:space="preserve">提交並推送</x:String>
|
||||||
<x:String x:Key="Text.WorkingCopy.CommitMessageHelper" 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.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" xml:space="preserve">檢測到衝突</x:String>
|
||||||
<x:String x:Key="Text.WorkingCopy.Conflicts.Resolved" 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>
|
<x:String x:Key="Text.WorkingCopy.IncludeUntracked" xml:space="preserve">顯示未追蹤檔案</x:String>
|
||||||
|
|
|
@ -240,11 +240,6 @@ namespace SourceGit.ViewModels
|
||||||
_cached = changes;
|
_cached = changes;
|
||||||
_count = _cached.Count;
|
_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 lastSelectedUnstaged = new HashSet<string>();
|
||||||
var lastSelectedStaged = new HashSet<string>();
|
var lastSelectedStaged = new HashSet<string>();
|
||||||
if (_selectedUnstaged != null && _selectedUnstaged.Count > 0)
|
if (_selectedUnstaged != null && _selectedUnstaged.Count > 0)
|
||||||
|
@ -258,6 +253,8 @@ namespace SourceGit.ViewModels
|
||||||
lastSelectedStaged.Add(c.Path);
|
lastSelectedStaged.Add(c.Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var unstaged = new List<Models.Change>();
|
||||||
|
var selectedUnstaged = new List<Models.Change>();
|
||||||
var hasConflict = false;
|
var hasConflict = false;
|
||||||
foreach (var c in changes)
|
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)
|
foreach (var c in staged)
|
||||||
{
|
{
|
||||||
if (lastSelectedStaged.Contains(c.Path))
|
if (lastSelectedStaged.Contains(c.Path))
|
||||||
|
@ -418,12 +416,17 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public void Commit()
|
public void Commit()
|
||||||
{
|
{
|
||||||
DoCommit(false);
|
DoCommit(AutoStageBeforeCommit, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CommitWithAutoStage()
|
||||||
|
{
|
||||||
|
DoCommit(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CommitWithPush()
|
public void CommitWithPush()
|
||||||
{
|
{
|
||||||
DoCommit(true);
|
DoCommit(AutoStageBeforeCommit, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextMenu CreateContextMenuForUnstagedChanges()
|
public ContextMenu CreateContextMenuForUnstagedChanges()
|
||||||
|
@ -1276,7 +1279,7 @@ namespace SourceGit.ViewModels
|
||||||
_repo.SetWatcherEnabled(true);
|
_repo.SetWatcherEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoCommit(bool autoPush)
|
private void DoCommit(bool autoStage, bool autoPush)
|
||||||
{
|
{
|
||||||
if (!PopupHost.CanCreatePopup())
|
if (!PopupHost.CanCreatePopup())
|
||||||
{
|
{
|
||||||
|
@ -1290,7 +1293,6 @@ namespace SourceGit.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var autoStage = AutoStageBeforeCommit;
|
|
||||||
if (!_useAmend)
|
if (!_useAmend)
|
||||||
{
|
{
|
||||||
if (autoStage)
|
if (autoStage)
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
|
FontSize="{Binding Source={x:Static vm:Preference.Instance}, Path=DefaultFontSize, Converter={x:Static c:DoubleConverters.Increase}}"
|
||||||
Margin="0,8"/>
|
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="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}" />
|
<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="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="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="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.CommitAndPush}" />
|
<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="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.Refresh}" />
|
<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>
|
</Grid>
|
||||||
|
|
||||||
<TextBlock Text="{DynamicResource Text.Hotkeys.TextEditor}"
|
<TextBlock Text="{DynamicResource Text.Hotkeys.TextEditor}"
|
||||||
|
|
|
@ -185,7 +185,7 @@
|
||||||
ToolTip.Tip="{DynamicResource Text.WorkingCopy.CommitMessageHelper}"
|
ToolTip.Tip="{DynamicResource Text.WorkingCopy.CommitMessageHelper}"
|
||||||
ToolTip.Placement="Top"
|
ToolTip.Placement="Top"
|
||||||
ToolTip.VerticalOffset="0">
|
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>
|
||||||
|
|
||||||
<Button Grid.Column="1"
|
<Button Grid.Column="1"
|
||||||
|
@ -223,9 +223,35 @@
|
||||||
Padding="8,0"
|
Padding="8,0"
|
||||||
Command="{Binding Commit}"
|
Command="{Binding Commit}"
|
||||||
HotKey="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"
|
HotKey="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"
|
||||||
ToolTip.Tip="{OnPlatform Ctrl+Enter, macOS=⌘+Enter}"
|
|
||||||
ToolTip.Placement="Top"
|
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="Default">
|
||||||
|
<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 `Ctrl+Alt+Enter` to commit with auto-stage -->
|
||||||
|
<Button Grid.Column="6"
|
||||||
|
Width="0" Height="0"
|
||||||
|
Background="Transparent"
|
||||||
|
Command="{Binding CommitWithAutoStage}"
|
||||||
|
HotKey="Alt+Enter"/>
|
||||||
|
|
||||||
<Button Grid.Column="7"
|
<Button Grid.Column="7"
|
||||||
Classes="flat"
|
Classes="flat"
|
||||||
|
|
|
@ -81,7 +81,6 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
vm.Discard(selected);
|
vm.Discard(selected);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue