diff --git a/src/App.axaml.cs b/src/App.axaml.cs index 6d73bfab..69917120 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -163,14 +163,14 @@ namespace SourceGit try { var resDic = new ResourceDictionary(); - + var schema = JsonSerializer.Deserialize(File.ReadAllText(colorsFile), JsonCodeGen.Default.DictionaryStringString); foreach (var kv in schema) resDic[kv.Key] = Color.Parse(kv.Value); app.Resources.MergedDictionaries.Add(resDic); app._colorOverrides = resDic; - } + } catch { } diff --git a/src/Commands/QueryBranches.cs b/src/Commands/QueryBranches.cs index ed5282f7..9200db4b 100644 --- a/src/Commands/QueryBranches.cs +++ b/src/Commands/QueryBranches.cs @@ -52,12 +52,12 @@ namespace SourceGit.Commands var refName = parts[0]; if (refName.EndsWith("/HEAD", StringComparison.Ordinal)) return; - + if (refName.StartsWith(PREFIX_DETACHED, StringComparison.Ordinal)) { branch.IsHead = true; } - + if (refName.StartsWith(PREFIX_LOCAL, StringComparison.Ordinal)) { branch.Name = refName.Substring(PREFIX_LOCAL.Length); diff --git a/src/Commands/QueryCommits.cs b/src/Commands/QueryCommits.cs index 0bfb132c..8308f577 100644 --- a/src/Commands/QueryCommits.cs +++ b/src/Commands/QueryCommits.cs @@ -57,7 +57,8 @@ namespace SourceGit.Commands if (line.Equals(_endOfBodyToken, StringComparison.Ordinal)) { _nextPartIdx = 0; - if (!string.IsNullOrEmpty(_current.Message)) _current.Message = _current.Message.Trim(); + if (!string.IsNullOrEmpty(_current.Message)) + _current.Message = _current.Message.Trim(); } else { diff --git a/src/Commands/QuerySingleCommit.cs b/src/Commands/QuerySingleCommit.cs index 3ea7fd08..7d443c4e 100644 --- a/src/Commands/QuerySingleCommit.cs +++ b/src/Commands/QuerySingleCommit.cs @@ -6,7 +6,8 @@ namespace SourceGit.Commands { public class QuerySingleCommit : Command { - public QuerySingleCommit(string repo, string sha) { + public QuerySingleCommit(string repo, string sha) + { WorkingDirectory = repo; Context = repo; Args = $"show --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%B -s {sha}"; @@ -19,7 +20,7 @@ namespace SourceGit.Commands { var commit = new Models.Commit(); var lines = rs.StdOut.Split('\n'); - if (lines.Length < 8) + if (lines.Length < 8) return null; commit.SHA = lines[0]; diff --git a/src/Converters/ChangeViewModeConverters.cs b/src/Converters/ChangeViewModeConverters.cs index 01bc1774..a5b07bca 100644 --- a/src/Converters/ChangeViewModeConverters.cs +++ b/src/Converters/ChangeViewModeConverters.cs @@ -19,14 +19,5 @@ namespace SourceGit.Converters return App.Current?.FindResource("Icons.Tree") as StreamGeometry; } }); - - public static readonly FuncValueConverter IsList = - new FuncValueConverter(v => v == Models.ChangeViewMode.List); - - public static readonly FuncValueConverter IsGrid = - new FuncValueConverter(v => v == Models.ChangeViewMode.Grid); - - public static readonly FuncValueConverter IsTree = - new FuncValueConverter(v => v == Models.ChangeViewMode.Tree); } } diff --git a/src/Converters/DecoratorTypeConverters.cs b/src/Converters/DecoratorTypeConverters.cs index 9f3d9447..e19cb37c 100644 --- a/src/Converters/DecoratorTypeConverters.cs +++ b/src/Converters/DecoratorTypeConverters.cs @@ -38,8 +38,8 @@ namespace SourceGit.Converters }); public static readonly FuncValueConverter ToFontWeight = - new FuncValueConverter(v => - v is Models.DecoratorType.CurrentBranchHead or Models.DecoratorType.CurrentCommitHead + new FuncValueConverter(v => + v is Models.DecoratorType.CurrentBranchHead or Models.DecoratorType.CurrentCommitHead ? FontWeight.Bold : FontWeight.Regular ); } diff --git a/src/Converters/LauncherPageConverters.cs b/src/Converters/LauncherPageConverters.cs index 05eec2b1..cc040653 100644 --- a/src/Converters/LauncherPageConverters.cs +++ b/src/Converters/LauncherPageConverters.cs @@ -25,14 +25,7 @@ namespace SourceGit.Converters var selected = array[1] as ViewModels.LauncherPage; var collections = array[2] as AvaloniaList; - if (selected != null && collections != null && (self == selected || collections.IndexOf(self) + 1 == collections.IndexOf(selected))) - { - return false; - } - else - { - return true; - } + return selected != null && collections != null && (self == selected || collections.IndexOf(self) + 1 == collections.IndexOf(selected)); }); } } diff --git a/src/Converters/StringConverters.cs b/src/Converters/StringConverters.cs index aa687f23..ac1785c0 100644 --- a/src/Converters/StringConverters.cs +++ b/src/Converters/StringConverters.cs @@ -30,17 +30,11 @@ namespace SourceGit.Converters { var theme = (string)value; if (theme.Equals("Light", StringComparison.OrdinalIgnoreCase)) - { return ThemeVariant.Light; - } else if (theme.Equals("Dark", StringComparison.OrdinalIgnoreCase)) - { return ThemeVariant.Dark; - } else - { return ThemeVariant.Default; - } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) @@ -70,7 +64,7 @@ namespace SourceGit.Converters public static readonly FuncValueConverter ToShortSHA = new FuncValueConverter(v => v == null ? string.Empty : (v.Length > 10 ? v.Substring(0, 10) : v)); - + public static readonly FuncValueConverter UnderRecommendGitVersion = new(v => { diff --git a/src/Converters/WindowStateConverters.cs b/src/Converters/WindowStateConverters.cs index 7122dc1f..05f0b1cd 100644 --- a/src/Converters/WindowStateConverters.cs +++ b/src/Converters/WindowStateConverters.cs @@ -12,30 +12,20 @@ namespace SourceGit.Converters new FuncValueConverter(state => { if (OperatingSystem.IsWindows() && state == WindowState.Maximized) - { return new Thickness(6); - } else if (OperatingSystem.IsLinux() && state != WindowState.Maximized) - { return new Thickness(6); - } else - { return new Thickness(0); - } }); public static readonly FuncValueConverter ToTitleBarHeight = new FuncValueConverter(state => { if (state == WindowState.Maximized) - { return new GridLength(OperatingSystem.IsMacOS() ? 34 : 30); - } else - { return new GridLength(38); - } }); public static readonly FuncValueConverter IsNormal = diff --git a/src/Models/TreeDataGridSelectionModel.cs b/src/Models/TreeDataGridSelectionModel.cs index e45393d0..be9d7d7c 100644 --- a/src/Models/TreeDataGridSelectionModel.cs +++ b/src/Models/TreeDataGridSelectionModel.cs @@ -182,7 +182,7 @@ namespace SourceGit.Models { var focus = _source.Rows[row.RowIndex]; if (focus is IExpander expander && HasChildren(focus)) - expander.IsExpanded = !expander.IsExpanded; + expander.IsExpanded = !expander.IsExpanded; else _rowDoubleTapped?.Invoke(this, e); @@ -455,7 +455,7 @@ namespace SourceGit.Models foreach (var c in children) return true; } - + return false; } } diff --git a/src/ViewModels/BranchTreeNode.cs b/src/ViewModels/BranchTreeNode.cs index d5690889..ef61579d 100644 --- a/src/ViewModels/BranchTreeNode.cs +++ b/src/ViewModels/BranchTreeNode.cs @@ -52,7 +52,7 @@ namespace SourceGit.ViewModels { get => Type == BranchTreeNodeType.Branch; } - + public bool IsDetachedHead { get => Type == BranchTreeNodeType.DetachedHead; @@ -219,7 +219,7 @@ namespace SourceGit.ViewModels start = sepIdx + 1; sepIdx = branch.Name.IndexOf('/', start); } - + lastFolder.Children.Add(new BranchTreeNode() { Name = Path.GetFileName(branch.Name), @@ -242,7 +242,7 @@ namespace SourceGit.ViewModels { return l.Name.CompareTo(r.Name); } - + return (int)l.Type - (int)r.Type; }); diff --git a/src/ViewModels/CheckoutCommit.cs b/src/ViewModels/CheckoutCommit.cs index da91f7fb..3f610e6f 100644 --- a/src/ViewModels/CheckoutCommit.cs +++ b/src/ViewModels/CheckoutCommit.cs @@ -2,14 +2,14 @@ namespace SourceGit.ViewModels { - public class CheckoutCommit: Popup + public class CheckoutCommit : Popup { public Models.Commit Commit { get; private set; } - + public bool HasLocalChanges { get => _repo.WorkingCopyChangesCount > 0; @@ -32,7 +32,7 @@ namespace SourceGit.ViewModels { _repo.SetWatcherEnabled(false); ProgressDescription = $"Checkout Commit '{Commit.SHA}' ..."; - + return Task.Run(() => { var needPopStash = false; diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs index 9f79f81d..bcacd042 100644 --- a/src/ViewModels/CommitDetail.cs +++ b/src/ViewModels/CommitDetail.cs @@ -228,7 +228,7 @@ namespace SourceGit.ViewModels e.Handled = true; }; menu.Items.Add(copyFileName); - + return menu; } diff --git a/src/ViewModels/CreateBranch.cs b/src/ViewModels/CreateBranch.cs index ad270809..aa3dc165 100644 --- a/src/ViewModels/CreateBranch.cs +++ b/src/ViewModels/CreateBranch.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; namespace SourceGit.ViewModels -{ +{ public class CreateBranch : Popup { [Required(ErrorMessage = "Branch name is required!")] @@ -19,13 +19,13 @@ namespace SourceGit.ViewModels get; private set; } - + public Models.DealWithLocalChanges PreAction { get => _preAction; set => SetProperty(ref _preAction, value); } - + public bool CheckoutAfterCreated { get; diff --git a/src/ViewModels/DeleteBranch.cs b/src/ViewModels/DeleteBranch.cs index 52a04d93..787e00fc 100644 --- a/src/ViewModels/DeleteBranch.cs +++ b/src/ViewModels/DeleteBranch.cs @@ -58,7 +58,7 @@ namespace SourceGit.ViewModels { SetProgressDescription("Deleting tracking remote branch..."); Commands.Branch.DeleteRemote(_repo.FullPath, TrackingRemoteBranch.Remote, TrackingRemoteBranch.Name); - } + } } else { diff --git a/src/ViewModels/DeleteMultipleBranches.cs b/src/ViewModels/DeleteMultipleBranches.cs index a863db16..433d80c6 100644 --- a/src/ViewModels/DeleteMultipleBranches.cs +++ b/src/ViewModels/DeleteMultipleBranches.cs @@ -17,7 +17,7 @@ namespace SourceGit.ViewModels Targets = branches; View = new Views.DeleteMultipleBranches() { DataContext = this }; } - + public override Task Sure() { _repo.SetWatcherEnabled(false); diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs index 4ff80c23..1e6e105e 100644 --- a/src/ViewModels/DiffContext.cs +++ b/src/ViewModels/DiffContext.cs @@ -122,7 +122,7 @@ namespace SourceGit.ViewModels if (latest.TextDiff != null) { var repo = Preference.FindRepository(_repo); - if (repo != null && repo.Submodules.Contains(_option.Path)) + if (repo != null && repo.Submodules.Contains(_option.Path)) { var submoduleDiff = new Models.SubmoduleDiff(); var submoduleRoot = $"{_repo}/{_option.Path}".Replace("\\", "/"); @@ -164,7 +164,7 @@ namespace SourceGit.ViewModels { var fullPath = Path.Combine(_repo, _option.Path); (imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, "HEAD", oldPath); - + if (File.Exists(fullPath)) { imgDiff.New = new Bitmap(fullPath); diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index 86987895..b4f06a9d 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -136,7 +136,7 @@ namespace SourceGit.ViewModels } needPopStash = true; - } + } else if (_preAction == Models.DealWithLocalChanges.Discard) { SetProgressDescription("Discard local changes ..."); diff --git a/src/ViewModels/RevisionCompare.cs b/src/ViewModels/RevisionCompare.cs index 1fdec102..99fae39f 100644 --- a/src/ViewModels/RevisionCompare.cs +++ b/src/ViewModels/RevisionCompare.cs @@ -192,7 +192,7 @@ namespace SourceGit.ViewModels e.Handled = true; }; menu.Items.Add(copyFileName); - + return menu; } diff --git a/src/ViewModels/StashesPage.cs b/src/ViewModels/StashesPage.cs index 8276e654..487e08e1 100644 --- a/src/ViewModels/StashesPage.cs +++ b/src/ViewModels/StashesPage.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Threading.Tasks; + using Avalonia.Controls; using Avalonia.Threading; diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 3d481153..91e07b7f 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; -using Avalonia; using Avalonia.Controls; using Avalonia.Platform.Storage; using Avalonia.Threading; @@ -793,7 +792,7 @@ namespace SourceGit.ViewModels App.CopyText(change.Path); e.Handled = true; }; - + var copyFileName = new MenuItem(); copyFileName.Header = App.Text("CopyFileName"); copyFileName.Icon = App.CreateMenuIcon("Icons.Copy"); diff --git a/src/Views/AssumeUnchangedManager.axaml.cs b/src/Views/AssumeUnchangedManager.axaml.cs index 3035ab77..6db53f42 100644 --- a/src/Views/AssumeUnchangedManager.axaml.cs +++ b/src/Views/AssumeUnchangedManager.axaml.cs @@ -21,7 +21,8 @@ namespace SourceGit.Views Close(); } - private void OnRemoveButtonClicked(object sender, RoutedEventArgs e) { + private void OnRemoveButtonClicked(object sender, RoutedEventArgs e) + { if (DataContext is ViewModels.AssumeUnchangedManager vm && sender is Button button) vm.Remove(button.DataContext as string); diff --git a/src/Views/ChangeCollectionView.axaml.cs b/src/Views/ChangeCollectionView.axaml.cs index 5d0694c0..61f8de97 100644 --- a/src/Views/ChangeCollectionView.axaml.cs +++ b/src/Views/ChangeCollectionView.axaml.cs @@ -81,7 +81,7 @@ namespace SourceGit.Views { if (Content is TreeDataGrid tree && tree.Source is IDisposable disposable) disposable.Dispose(); - + Content = null; var changes = Changes; diff --git a/src/Views/Clone.axaml.cs b/src/Views/Clone.axaml.cs index a1e38050..9148daec 100644 --- a/src/Views/Clone.axaml.cs +++ b/src/Views/Clone.axaml.cs @@ -17,7 +17,7 @@ namespace SourceGit.Views var toplevel = TopLevel.GetTopLevel(this); if (toplevel == null) return; - + var selected = await toplevel.StorageProvider.OpenFolderPickerAsync(options); if (selected.Count == 1) TxtParentFolder.Text = selected[0].Path.LocalPath; @@ -31,7 +31,7 @@ namespace SourceGit.Views var toplevel = TopLevel.GetTopLevel(this); if (toplevel == null) return; - + var selected = await toplevel.StorageProvider.OpenFilePickerAsync(options); if (selected.Count == 1) TxtSshKey.Text = selected[0].Path.LocalPath; diff --git a/src/Views/CommitBaseInfo.axaml.cs b/src/Views/CommitBaseInfo.axaml.cs index a4775570..d835895b 100644 --- a/src/Views/CommitBaseInfo.axaml.cs +++ b/src/Views/CommitBaseInfo.axaml.cs @@ -24,7 +24,7 @@ namespace SourceGit.Views { if (DataContext is ViewModels.CommitDetail detail && CanNavigate) detail.NavigateTo((sender as Control).DataContext as string); - + e.Handled = true; } } diff --git a/src/Views/CommitDetail.axaml.cs b/src/Views/CommitDetail.axaml.cs index 75806e59..a7373acb 100644 --- a/src/Views/CommitDetail.axaml.cs +++ b/src/Views/CommitDetail.axaml.cs @@ -16,7 +16,7 @@ namespace SourceGit.Views { var datagrid = sender as DataGrid; detail.ActivePageIndex = 1; - detail.SelectedChanges = new () { datagrid.SelectedItem as Models.Change }; + detail.SelectedChanges = new() { datagrid.SelectedItem as Models.Change }; } e.Handled = true; diff --git a/src/Views/ContextMenuExtension.cs b/src/Views/ContextMenuExtension.cs index c03a20de..6e6dbf20 100644 --- a/src/Views/ContextMenuExtension.cs +++ b/src/Views/ContextMenuExtension.cs @@ -8,8 +8,9 @@ namespace SourceGit.Views { public static void OpenContextMenu(this Control control, ContextMenu menu) { - if (menu == null) return; - + if (menu == null) + return; + menu.PlacementTarget = control; menu.Closing += OnContextMenuClosing; // Clear context menu because it is dynamic. diff --git a/src/Views/LoadingIcon.axaml.cs b/src/Views/LoadingIcon.axaml.cs index 5a7e0014..62efed1d 100644 --- a/src/Views/LoadingIcon.axaml.cs +++ b/src/Views/LoadingIcon.axaml.cs @@ -18,7 +18,7 @@ namespace SourceGit.Views { base.OnLoaded(e); - if (IsVisible) + if (IsVisible) StartAnim(); } @@ -37,7 +37,7 @@ namespace SourceGit.Views if (IsVisible) StartAnim(); else - StopAnim(); + StopAnim(); } } diff --git a/src/Views/Repository.axaml.cs b/src/Views/Repository.axaml.cs index 2cca3ab3..bc155592 100644 --- a/src/Views/Repository.axaml.cs +++ b/src/Views/Repository.axaml.cs @@ -88,7 +88,7 @@ namespace SourceGit.Views ViewModels.BranchTreeNode prev = null; foreach (var node in repo.LocalBranchTrees) node.UpdateCornerRadius(ref prev); - + if (tree.SelectedItems.Count == 1) { var node = tree.SelectedItem as ViewModels.BranchTreeNode; @@ -303,12 +303,12 @@ namespace SourceGit.Views e.Handled = true; } - + private void CollectBranchesFromNode(List outs, ViewModels.BranchTreeNode node) { if (node == null || node.IsRemote) return; - + if (node.IsFolder) { foreach (var child in node.Children)