mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 21:24:59 +00:00
code_style: remove all IDE warnings
This commit is contained in:
parent
24ca3eaf8c
commit
f4eca45754
79 changed files with 1462 additions and 1378 deletions
|
@ -75,7 +75,10 @@ namespace SourceGit.Models
|
|||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
|
||||
lock (_synclock)
|
||||
{
|
||||
|
@ -84,10 +87,7 @@ namespace SourceGit.Models
|
|||
|
||||
Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
if (_resources.ContainsKey(md5))
|
||||
_resources[md5] = img;
|
||||
else
|
||||
_resources.Add(md5, img);
|
||||
_resources[md5] = img;
|
||||
NotifyResourceChanged(md5);
|
||||
});
|
||||
}
|
||||
|
@ -134,7 +134,10 @@ namespace SourceGit.Models
|
|||
return img;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +159,7 @@ namespace SourceGit.Models
|
|||
}
|
||||
|
||||
private static readonly object _synclock = new object();
|
||||
private static readonly string _storePath = string.Empty;
|
||||
private static readonly string _storePath;
|
||||
private static readonly List<IAvatarHost> _avatars = new List<IAvatarHost>();
|
||||
private static readonly Dictionary<string, Bitmap> _resources = new Dictionary<string, Bitmap>();
|
||||
private static readonly HashSet<string> _requesting = new HashSet<string>();
|
||||
|
|
|
@ -22,9 +22,8 @@ namespace SourceGit.Models
|
|||
public string AuthorTimeStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||||
public string CommitterTimeStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
|
||||
public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd");
|
||||
public string CommitterTimeShortStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToString("yyyy/MM/dd");
|
||||
|
||||
public bool IsCommitterVisible => Author != Committer || AuthorTime != CommitterTime;
|
||||
public bool IsCommitterVisible => !Author.Equals(Committer) || AuthorTime != CommitterTime;
|
||||
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,8 +268,9 @@ namespace SourceGit.Models
|
|||
var path = unsolved[i];
|
||||
var endY = (commits.Count - 0.5) * UNIT_HEIGHT;
|
||||
|
||||
if (path.Path.Points.Count == 1 && path.Path.Points[0].Y == endY)
|
||||
if (path.Path.Points.Count == 1 && Math.Abs(path.Path.Points[0].Y - endY) < 0.0001)
|
||||
continue;
|
||||
|
||||
path.Add((i + 0.5) * UNIT_WIDTH, endY + HALF_HEIGHT, HALF_HEIGHT, true);
|
||||
}
|
||||
unsolved.Clear();
|
||||
|
|
|
@ -108,8 +108,8 @@ namespace SourceGit.Models
|
|||
|
||||
private readonly Change _workingCopyChange = null;
|
||||
private readonly bool _isUnstaged = false;
|
||||
private readonly string _path;
|
||||
private readonly string _orgPath = string.Empty;
|
||||
private readonly string _path = string.Empty;
|
||||
private readonly string _extra = string.Empty;
|
||||
private readonly List<string> _revisions = new List<string>();
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ namespace SourceGit.Models
|
|||
{
|
||||
public class ExternalTool
|
||||
{
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
public string Executable { get; private set; } = string.Empty;
|
||||
public string OpenCmdArgs { get; private set; } = string.Empty;
|
||||
public string Name { get; private set; }
|
||||
public string Executable { get; private set; }
|
||||
public string OpenCmdArgs { get; private set; }
|
||||
public Bitmap IconImage { get; private set; } = null;
|
||||
|
||||
public ExternalTool(string name, string icon, string executable, string openCmdArgs)
|
||||
|
@ -25,10 +25,14 @@ namespace SourceGit.Models
|
|||
|
||||
try
|
||||
{
|
||||
var asset = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{icon}.png", UriKind.RelativeOrAbsolute));
|
||||
var asset = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{icon}.png",
|
||||
UriKind.RelativeOrAbsolute));
|
||||
IconImage = new Bitmap(asset);
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
public void Open(string repo)
|
||||
|
|
|
@ -14,7 +14,6 @@ namespace SourceGit.Models
|
|||
|
||||
public class RevisionTextFile
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string Content { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Styling;
|
||||
|
||||
using AvaloniaEdit;
|
||||
|
@ -14,14 +15,10 @@ namespace SourceGit.Models
|
|||
{
|
||||
public static TextMate.Installation CreateForEditor(TextEditor editor)
|
||||
{
|
||||
if (App.Current?.ActualThemeVariant == ThemeVariant.Dark)
|
||||
{
|
||||
if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark)
|
||||
return editor.InstallTextMate(new RegistryOptions(ThemeName.DarkPlus));
|
||||
}
|
||||
else
|
||||
{
|
||||
return editor.InstallTextMate(new RegistryOptions(ThemeName.LightPlus));
|
||||
}
|
||||
|
||||
return editor.InstallTextMate(new RegistryOptions(ThemeName.LightPlus));
|
||||
}
|
||||
|
||||
public static void SetThemeByApp(TextMate.Installation installation)
|
||||
|
@ -29,35 +26,28 @@ namespace SourceGit.Models
|
|||
if (installation == null)
|
||||
return;
|
||||
|
||||
var reg = installation.RegistryOptions as RegistryOptions;
|
||||
if (App.Current?.ActualThemeVariant == ThemeVariant.Dark)
|
||||
if (installation.RegistryOptions is RegistryOptions reg)
|
||||
{
|
||||
installation.SetTheme(reg.LoadTheme(ThemeName.DarkPlus));
|
||||
}
|
||||
else
|
||||
{
|
||||
installation.SetTheme(reg.LoadTheme(ThemeName.LightPlus));
|
||||
if (Application.Current?.ActualThemeVariant == ThemeVariant.Dark)
|
||||
installation.SetTheme(reg.LoadTheme(ThemeName.DarkPlus));
|
||||
else
|
||||
installation.SetTheme(reg.LoadTheme(ThemeName.LightPlus));
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetGrammarByFileName(TextMate.Installation installation, string filePath)
|
||||
{
|
||||
if (installation == null)
|
||||
return;
|
||||
|
||||
var ext = Path.GetExtension(filePath);
|
||||
if (ext == ".h")
|
||||
if (installation is { RegistryOptions: RegistryOptions reg })
|
||||
{
|
||||
ext = ".cpp";
|
||||
}
|
||||
else if (ext == ".resx" || ext == ".plist")
|
||||
{
|
||||
ext = ".xml";
|
||||
}
|
||||
var ext = Path.GetExtension(filePath);
|
||||
if (ext == ".h")
|
||||
ext = ".cpp";
|
||||
else if (ext == ".resx" || ext == ".plist")
|
||||
ext = ".xml";
|
||||
|
||||
var reg = installation.RegistryOptions as RegistryOptions;
|
||||
installation.SetGrammar(reg.GetScopeByExtension(ext));
|
||||
GC.Collect();
|
||||
installation.SetGrammar(reg.GetScopeByExtension(ext));
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,20 @@ namespace SourceGit.Models
|
|||
public string Name { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public User()
|
||||
{
|
||||
// Only used by User.Invalid
|
||||
}
|
||||
|
||||
public User(string data)
|
||||
{
|
||||
var nameEndIdx = data.IndexOf('±', StringComparison.Ordinal);
|
||||
|
||||
Name = nameEndIdx > 0 ? data.Substring(0, nameEndIdx) : string.Empty;
|
||||
Email = data.Substring(nameEndIdx + 1);
|
||||
_hash = data.GetHashCode();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || !(obj is User))
|
||||
|
@ -21,21 +35,15 @@ namespace SourceGit.Models
|
|||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
return _hash;
|
||||
}
|
||||
|
||||
public static User FindOrAdd(string data)
|
||||
{
|
||||
return _caches.GetOrAdd(data, key =>
|
||||
{
|
||||
var nameEndIdx = key.IndexOf('±', StringComparison.Ordinal);
|
||||
var name = nameEndIdx > 0 ? key.Substring(0, nameEndIdx) : string.Empty;
|
||||
var email = key.Substring(nameEndIdx + 1);
|
||||
|
||||
return new User() { Name = name, Email = email };
|
||||
});
|
||||
return _caches.GetOrAdd(data, key => new User(key));
|
||||
}
|
||||
|
||||
private static ConcurrentDictionary<string, User> _caches = new ConcurrentDictionary<string, User>();
|
||||
private readonly int _hash;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace SourceGit.Models
|
|||
|
||||
var major = int.Parse(match.Groups[1].Value);
|
||||
var minor = int.Parse(match.Groups[2].Value);
|
||||
var ver = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
var ver = Assembly.GetExecutingAssembly().GetName().Version!;
|
||||
return ver.Major < major || (ver.Major == major && ver.Minor < minor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace SourceGit.Models
|
|||
|
||||
// If this repository is a worktree repository, just watch the main repository's gitdir.
|
||||
var gitDirNormalized = _repo.GitDir.Replace("\\", "/");
|
||||
var worktreeIdx = gitDirNormalized.IndexOf(".git/worktrees/");
|
||||
var worktreeIdx = gitDirNormalized.IndexOf(".git/worktrees/", StringComparison.Ordinal);
|
||||
var repoWatchDir = _repo.GitDir;
|
||||
if (worktreeIdx > 0)
|
||||
repoWatchDir = _repo.GitDir.Substring(0, worktreeIdx + 4);
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace SourceGit.Models
|
|||
public string Head { get; set; } = string.Empty;
|
||||
public bool IsBare { get; set; } = false;
|
||||
public bool IsDetached { get; set; } = false;
|
||||
public bool IsPrunable { get; set; } = false;
|
||||
|
||||
public bool IsLocked
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue