From ec6fe25e8742cec364fc13a7870083d7d8023a81 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 31 Jul 2024 16:26:58 +0800 Subject: [PATCH] code_style: run `dotnet format` --- src/Commands/Blame.cs | 1 - src/Commands/Config.cs | 8 -------- src/Commands/Diff.cs | 4 ---- src/Commands/IsConflictResolved.cs | 6 ------ src/Commands/QueryStagedChangesWithAmend.cs | 6 ++++-- src/ViewModels/Pull.cs | 2 +- src/ViewModels/Repository.cs | 4 ++-- src/ViewModels/WorkingCopy.cs | 7 ++----- src/Views/Histories.axaml.cs | 2 +- src/Views/Repository.axaml.cs | 6 +++--- 10 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/Commands/Blame.cs b/src/Commands/Blame.cs index e4c7f12a..de221b07 100644 --- a/src/Commands/Blame.cs +++ b/src/Commands/Blame.cs @@ -6,7 +6,6 @@ namespace SourceGit.Commands { public partial class Blame : Command { - [GeneratedRegex(@"^\^?([0-9a-f]+)\s+.*\((.*)\s+(\d+)\s+[\-\+]?\d+\s+\d+\) (.*)")] private static partial Regex REG_FORMAT(); diff --git a/src/Commands/Config.cs b/src/Commands/Config.cs index 67c17ce9..53416c86 100644 --- a/src/Commands/Config.cs +++ b/src/Commands/Config.cs @@ -50,24 +50,16 @@ namespace SourceGit.Commands if (!allowEmpty && string.IsNullOrWhiteSpace(value)) { if (string.IsNullOrEmpty(WorkingDirectory)) - { Args = $"config --global --unset {key}"; - } else - { Args = $"config --unset {key}"; - } } else { if (string.IsNullOrWhiteSpace(WorkingDirectory)) - { Args = $"config --global {key} \"{value}\""; - } else - { Args = $"config {key} \"{value}\""; - } } return Exec(); diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 2d7a8ec2..0f2ee626 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -38,13 +38,9 @@ namespace SourceGit.Commands ProcessInlineHighlights(); if (_result.TextDiff.Lines.Count == 0) - { _result.TextDiff = null; - } else - { _result.TextDiff.MaxLineNumber = Math.Max(_newLine, _oldLine); - } } return _result; diff --git a/src/Commands/IsConflictResolved.cs b/src/Commands/IsConflictResolved.cs index 6b0182dc..13bc12ac 100644 --- a/src/Commands/IsConflictResolved.cs +++ b/src/Commands/IsConflictResolved.cs @@ -10,11 +10,5 @@ Context = repo; Args = $"diff -a --ignore-cr-at-eol --check {opt}"; } - - public bool Result() - { - var rs = ReadToEnd(); - return rs.IsSuccess; - } } } diff --git a/src/Commands/QueryStagedChangesWithAmend.cs b/src/Commands/QueryStagedChangesWithAmend.cs index 93db31cb..f5c9659f 100644 --- a/src/Commands/QueryStagedChangesWithAmend.cs +++ b/src/Commands/QueryStagedChangesWithAmend.cs @@ -30,7 +30,8 @@ namespace SourceGit.Commands var match = REG_FORMAT2().Match(line); if (match.Success) { - var change = new Models.Change() { + var change = new Models.Change() + { Path = match.Groups[3].Value, DataForAmend = new Models.ChangeDataForAmend() { @@ -46,7 +47,8 @@ namespace SourceGit.Commands match = REG_FORMAT1().Match(line); if (match.Success) { - var change = new Models.Change() { + var change = new Models.Change() + { Path = match.Groups[4].Value, DataForAmend = new Models.ChangeDataForAmend() { diff --git a/src/ViewModels/Pull.cs b/src/ViewModels/Pull.cs index bb969b47..77867baf 100644 --- a/src/ViewModels/Pull.cs +++ b/src/ViewModels/Pull.cs @@ -58,7 +58,7 @@ namespace SourceGit.ViewModels get => _repo.Settings.PreferRebaseInsteadOfMerge; set => _repo.Settings.PreferRebaseInsteadOfMerge = value; } - + public bool FetchAllBranches { get => _repo.Settings.FetchAllBranchesOnPull; diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 92160b2d..3ee8edd8 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -207,8 +207,8 @@ namespace SourceGit.ViewModels { if (SetProperty(ref _searchCommitFilter, value) && _searchCommitFilterType == 3 && - !string.IsNullOrEmpty(value) && - value.Length >= 2 && + !string.IsNullOrEmpty(value) && + value.Length >= 2 && _revisionFiles.Count > 0) { var suggestion = new List(); diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 813be025..77db80e5 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -23,11 +23,8 @@ namespace SourceGit.ViewModels { Task.Run(() => { - var result = new Commands.IsConflictResolved(repo, change).Result(); - Dispatcher.UIThread.Post(() => - { - IsResolved = result; - }); + var result = new Commands.IsConflictResolved(repo, change).ReadToEnd().IsSuccess; + Dispatcher.UIThread.Post(() => IsResolved = result); }); } diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index f135cbf7..3071de9c 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -415,7 +415,7 @@ namespace SourceGit.Views { if (DataContext is ViewModels.Histories histories && sender is DataGrid datagrid && datagrid.SelectedItems is { Count: 1 } selectedItems) { - histories.DoubleTapped(selectedItems[0] as Models.Commit); + histories.DoubleTapped(selectedItems[0] as Models.Commit); } e.Handled = true; } diff --git a/src/Views/Repository.axaml.cs b/src/Views/Repository.axaml.cs index d2284ed6..cfe9d7ef 100644 --- a/src/Views/Repository.axaml.cs +++ b/src/Views/Repository.axaml.cs @@ -44,7 +44,7 @@ namespace SourceGit.Views SearchSuggestionBox.Focus(NavigationMethod.Tab); SearchSuggestionBox.SelectedIndex = 0; } - + e.Handled = true; } @@ -295,7 +295,7 @@ namespace SourceGit.Views } } - private void OnSearchSuggestionBoxKeyDown(object sender, KeyEventArgs e) + private void OnSearchSuggestionBoxKeyDown(object sender, KeyEventArgs e) { var repo = DataContext as ViewModels.Repository; if (e.Key == Key.Escape) @@ -314,7 +314,7 @@ namespace SourceGit.Views } } - private void OnSearchSuggestionDoubleTapped(object sender, TappedEventArgs e) + private void OnSearchSuggestionDoubleTapped(object sender, TappedEventArgs e) { var repo = DataContext as ViewModels.Repository; var content = (sender as StackPanel)?.DataContext as string;