mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-27 21:27:19 -08:00
Compare commits
3 commits
14334b08d2
...
93706449be
Author | SHA1 | Date | |
---|---|---|---|
|
93706449be | ||
|
68519c76ca | ||
|
ac74e4ba32 |
8 changed files with 52 additions and 21 deletions
|
@ -81,6 +81,8 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
public class RegistryOptionsWrapper(ThemeName defaultTheme) : IRegistryOptions
|
public class RegistryOptionsWrapper(ThemeName defaultTheme) : IRegistryOptions
|
||||||
{
|
{
|
||||||
|
public string LastScope { get; set; } = string.Empty;
|
||||||
|
|
||||||
public IRawTheme GetTheme(string scopeName) => _backend.GetTheme(scopeName);
|
public IRawTheme GetTheme(string scopeName) => _backend.GetTheme(scopeName);
|
||||||
public IRawTheme GetDefaultTheme() => _backend.GetDefaultTheme();
|
public IRawTheme GetDefaultTheme() => _backend.GetDefaultTheme();
|
||||||
public IRawTheme LoadTheme(ThemeName name) => _backend.LoadTheme(name);
|
public IRawTheme LoadTheme(ThemeName name) => _backend.LoadTheme(name);
|
||||||
|
@ -111,10 +113,15 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
public static void SetGrammarByFileName(TextMate.Installation installation, string filePath)
|
public static void SetGrammarByFileName(TextMate.Installation installation, string filePath)
|
||||||
{
|
{
|
||||||
if (installation is { RegistryOptions: RegistryOptionsWrapper reg })
|
if (installation is { RegistryOptions: RegistryOptionsWrapper reg } && !string.IsNullOrEmpty(filePath))
|
||||||
{
|
{
|
||||||
installation.SetGrammar(reg.GetScope(filePath));
|
var scope = reg.GetScope(filePath);
|
||||||
GC.Collect();
|
if (reg.LastScope != scope)
|
||||||
|
{
|
||||||
|
reg.LastScope = scope;
|
||||||
|
installation.SetGrammar(reg.GetScope(filePath));
|
||||||
|
GC.Collect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -562,6 +562,8 @@
|
||||||
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">Include untracked files</x:String>
|
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">Include untracked files</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message" xml:space="preserve">Message:</x:String>
|
<x:String x:Key="Text.Stash.Message" xml:space="preserve">Message:</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">Optional. Name of this stash</x:String>
|
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">Optional. Name of this stash</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">Only staged changes</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.TipForSelectedFiles" xml:space="preserve">Both staged and unstaged changes of selected file(s) will be stashed!!!</x:String>
|
||||||
<x:String x:Key="Text.Stash.Title" xml:space="preserve">Stash Local Changes</x:String>
|
<x:String x:Key="Text.Stash.Title" xml:space="preserve">Stash Local Changes</x:String>
|
||||||
<x:String x:Key="Text.StashCM.Apply" xml:space="preserve">Apply</x:String>
|
<x:String x:Key="Text.StashCM.Apply" xml:space="preserve">Apply</x:String>
|
||||||
<x:String x:Key="Text.StashCM.Drop" xml:space="preserve">Drop</x:String>
|
<x:String x:Key="Text.StashCM.Drop" xml:space="preserve">Drop</x:String>
|
||||||
|
|
|
@ -560,6 +560,8 @@
|
||||||
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未跟踪的文件</x:String>
|
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未跟踪的文件</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message" xml:space="preserve">信息 :</x:String>
|
<x:String x:Key="Text.Stash.Message" xml:space="preserve">信息 :</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">选填,用于命名此贮藏</x:String>
|
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">选填,用于命名此贮藏</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">仅贮藏暂存区的变更</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.TipForSelectedFiles" xml:space="preserve">选中文件的所有变更均会被贮藏!</x:String>
|
||||||
<x:String x:Key="Text.Stash.Title" xml:space="preserve">贮藏本地变更</x:String>
|
<x:String x:Key="Text.Stash.Title" xml:space="preserve">贮藏本地变更</x:String>
|
||||||
<x:String x:Key="Text.StashCM.Apply" xml:space="preserve">应用(apply)</x:String>
|
<x:String x:Key="Text.StashCM.Apply" xml:space="preserve">应用(apply)</x:String>
|
||||||
<x:String x:Key="Text.StashCM.Drop" xml:space="preserve">删除(drop)</x:String>
|
<x:String x:Key="Text.StashCM.Drop" xml:space="preserve">删除(drop)</x:String>
|
||||||
|
|
|
@ -565,6 +565,8 @@
|
||||||
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未追蹤的檔案</x:String>
|
<x:String x:Key="Text.Stash.IncludeUntracked" xml:space="preserve">包含未追蹤的檔案</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message" xml:space="preserve">擱置變更訊息:</x:String>
|
<x:String x:Key="Text.Stash.Message" xml:space="preserve">擱置變更訊息:</x:String>
|
||||||
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">選填,用於命名此擱置變更</x:String>
|
<x:String x:Key="Text.Stash.Message.Placeholder" xml:space="preserve">選填,用於命名此擱置變更</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.OnlyStagedChanges" xml:space="preserve">僅擱置已暫存的變更</x:String>
|
||||||
|
<x:String x:Key="Text.Stash.TipForSelectedFiles" xml:space="preserve">選中檔案的所有變更均會被擱置!</x:String>
|
||||||
<x:String x:Key="Text.Stash.Title" xml:space="preserve">擱置本機變更</x:String>
|
<x:String x:Key="Text.Stash.Title" xml:space="preserve">擱置本機變更</x:String>
|
||||||
<x:String x:Key="Text.StashCM.Apply" xml:space="preserve">套用 (apply)</x:String>
|
<x:String x:Key="Text.StashCM.Apply" xml:space="preserve">套用 (apply)</x:String>
|
||||||
<x:String x:Key="Text.StashCM.Drop" xml:space="preserve">刪除 (drop)</x:String>
|
<x:String x:Key="Text.StashCM.Drop" xml:space="preserve">刪除 (drop)</x:String>
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace SourceGit.ViewModels
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
Current = current;
|
Current = current;
|
||||||
To = to;
|
To = to;
|
||||||
SelectedMode = Models.ResetMode.Supported[0];
|
SelectedMode = Models.ResetMode.Supported[1];
|
||||||
View = new Views.Reset() { DataContext = this };
|
View = new Views.Reset() { DataContext = this };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace SourceGit.ViewModels
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanIgnoreUntracked
|
public bool HasSelectedFiles
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
@ -22,21 +22,28 @@ namespace SourceGit.ViewModels
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StashChanges(Repository repo, List<Models.Change> changes, bool onlyStaged, bool canIgnoreUntracked)
|
public bool OnlyStaged
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StashChanges(Repository repo, List<Models.Change> changes, bool hasSelectedFiles)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_changes = changes;
|
_changes = changes;
|
||||||
_onlyStaged = onlyStaged;
|
|
||||||
|
|
||||||
CanIgnoreUntracked = canIgnoreUntracked;
|
HasSelectedFiles = hasSelectedFiles;
|
||||||
IncludeUntracked = true;
|
IncludeUntracked = true;
|
||||||
|
OnlyStaged = false;
|
||||||
|
|
||||||
View = new Views.StashChanges() { DataContext = this };
|
View = new Views.StashChanges() { DataContext = this };
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
{
|
{
|
||||||
var jobs = _changes;
|
var jobs = _changes;
|
||||||
if (CanIgnoreUntracked && !IncludeUntracked)
|
if (!HasSelectedFiles && !IncludeUntracked)
|
||||||
{
|
{
|
||||||
jobs = new List<Models.Change>();
|
jobs = new List<Models.Change>();
|
||||||
foreach (var job in _changes)
|
foreach (var job in _changes)
|
||||||
|
@ -56,7 +63,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, _onlyStaged);
|
var succ = new Commands.Stash(_repo.FullPath).Push(jobs, Message, !HasSelectedFiles && OnlyStaged);
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
{
|
{
|
||||||
_repo.MarkWorkingCopyDirtyManually();
|
_repo.MarkWorkingCopyDirtyManually();
|
||||||
|
@ -68,6 +75,5 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private readonly List<Models.Change> _changes = null;
|
private readonly List<Models.Change> _changes = null;
|
||||||
private readonly bool _onlyStaged = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,9 +318,9 @@ namespace SourceGit.ViewModels
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (autoStart)
|
if (autoStart)
|
||||||
PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false, true));
|
PopupHost.ShowAndStartPopup(new StashChanges(_repo, _cached, false));
|
||||||
else
|
else
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _cached, false, true));
|
PopupHost.ShowPopup(new StashChanges(_repo, _cached, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StageSelected(Models.Change next)
|
public void StageSelected(Models.Change next)
|
||||||
|
@ -523,9 +523,8 @@ namespace SourceGit.ViewModels
|
||||||
stash.Click += (_, e) =>
|
stash.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
{
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, true));
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false));
|
|
||||||
}
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -843,7 +842,7 @@ namespace SourceGit.ViewModels
|
||||||
stash.Click += (_, e) =>
|
stash.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, false, false));
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedUnstaged, true));
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -928,7 +927,7 @@ namespace SourceGit.ViewModels
|
||||||
stash.Click += (_, e) =>
|
stash.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false));
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true));
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -1097,7 +1096,7 @@ namespace SourceGit.ViewModels
|
||||||
stash.Click += (_, e) =>
|
stash.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
if (PopupHost.CanCreatePopup())
|
if (PopupHost.CanCreatePopup())
|
||||||
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true, false));
|
PopupHost.ShowPopup(new StashChanges(_repo, _selectedStaged, true));
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<TextBlock FontSize="18"
|
<TextBlock FontSize="18"
|
||||||
Classes="bold"
|
Classes="bold"
|
||||||
Text="{DynamicResource Text.Stash.Title}"/>
|
Text="{DynamicResource Text.Stash.Title}"/>
|
||||||
<Grid Margin="8,16,0,0" RowDefinitions="32,Auto" ColumnDefinitions="120,*">
|
<Grid Margin="8,16,0,0" RowDefinitions="32,Auto,Auto" ColumnDefinitions="120,*">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
|
@ -23,11 +23,24 @@
|
||||||
Watermark="{DynamicResource Text.Stash.Message.Placeholder}"
|
Watermark="{DynamicResource Text.Stash.Message.Placeholder}"
|
||||||
v:AutoFocusBehaviour.IsEnabled="True"/>
|
v:AutoFocusBehaviour.IsEnabled="True"/>
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
Text="{DynamicResource Text.Stash.TipForSelectedFiles}"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Foreground="{DynamicResource Brush.FG2}"
|
||||||
|
IsVisible="{Binding HasSelectedFiles}"/>
|
||||||
|
|
||||||
<CheckBox Grid.Row="1" Grid.Column="1"
|
<CheckBox Grid.Row="1" Grid.Column="1"
|
||||||
Height="32"
|
Height="32"
|
||||||
Content="{DynamicResource Text.Stash.IncludeUntracked}"
|
Content="{DynamicResource Text.Stash.IncludeUntracked}"
|
||||||
IsChecked="{Binding IncludeUntracked, Mode=TwoWay}"
|
IsChecked="{Binding IncludeUntracked, Mode=TwoWay}"
|
||||||
IsVisible="{Binding CanIgnoreUntracked}"/>
|
IsVisible="{Binding !HasSelectedFiles}"/>
|
||||||
|
|
||||||
|
<CheckBox Grid.Row="2" Grid.Column="1"
|
||||||
|
Height="32"
|
||||||
|
Content="{DynamicResource Text.Stash.OnlyStagedChanges}"
|
||||||
|
IsChecked="{Binding OnlyStaged, Mode=TwoWay}"
|
||||||
|
IsVisible="{Binding !HasSelectedFiles}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
Loading…
Reference in a new issue