code_style: remove unnecessary code in DiffContext

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-06-07 20:42:45 +08:00
parent 74f52fb266
commit 2478d2953b
No known key found for this signature in database

View file

@ -12,7 +12,7 @@ namespace SourceGit.ViewModels
{ {
public string Title public string Title
{ {
get => _title; get;
} }
public bool IgnoreWhitespace public bool IgnoreWhitespace
@ -68,9 +68,9 @@ namespace SourceGit.ViewModels
} }
if (string.IsNullOrEmpty(_option.OrgPath) || _option.OrgPath == "/dev/null") if (string.IsNullOrEmpty(_option.OrgPath) || _option.OrgPath == "/dev/null")
_title = _option.Path; Title = _option.Path;
else else
_title = $"{_option.OrgPath} → {_option.Path}"; Title = $"{_option.OrgPath} → {_option.Path}";
LoadDiffContent(); LoadDiffContent();
} }
@ -112,9 +112,9 @@ namespace SourceGit.ViewModels
Task.Run(() => Task.Run(() =>
{ {
var numLines = Preferences.Instance.UseFullTextDiff ? 999999999 : _unifiedLines; var numLines = Preferences.Instance.UseFullTextDiff ? 999999999 : _unifiedLines;
var ignoreWS = Preferences.Instance.IgnoreWhitespaceChangesInDiff; var ignoreWhitespace = Preferences.Instance.IgnoreWhitespaceChangesInDiff;
var latest = new Commands.Diff(_repo, _option, numLines, ignoreWS).Result(); var latest = new Commands.Diff(_repo, _option, numLines, ignoreWhitespace).Result();
var info = new Info(_option, numLines, ignoreWS, latest); var info = new Info(_option, numLines, ignoreWhitespace, latest);
if (_info != null && info.IsSame(_info)) if (_info != null && info.IsSame(_info))
return; return;
@ -239,30 +239,24 @@ namespace SourceGit.ViewModels
private Models.RevisionSubmodule QuerySubmoduleRevision(string repo, string sha) private Models.RevisionSubmodule QuerySubmoduleRevision(string repo, string sha)
{ {
var commit = new Commands.QuerySingleCommit(repo, sha).Result(); var commit = new Commands.QuerySingleCommit(repo, sha).Result();
if (commit != null) if (commit == null)
{ return new Models.RevisionSubmodule() { Commit = new Models.Commit() { SHA = sha } };
var body = new Commands.QueryCommitFullMessage(repo, sha).Result();
return new Models.RevisionSubmodule()
{
Commit = commit,
FullMessage = new Models.CommitFullMessage { Message = body }
};
}
var body = new Commands.QueryCommitFullMessage(repo, sha).Result();
return new Models.RevisionSubmodule() return new Models.RevisionSubmodule()
{ {
Commit = new Models.Commit() { SHA = sha }, Commit = commit,
FullMessage = null, FullMessage = new Models.CommitFullMessage { Message = body }
}; };
} }
private class Info private class Info
{ {
public string Argument { get; set; } public string Argument { get; }
public int UnifiedLines { get; set; } public int UnifiedLines { get; }
public bool IgnoreWhitespace { get; set; } public bool IgnoreWhitespace { get; }
public string OldHash { get; set; } public string OldHash { get; }
public string NewHash { get; set; } public string NewHash { get; }
public Info(Models.DiffOption option, int unifiedLines, bool ignoreWhitespace, Models.DiffResult result) public Info(Models.DiffOption option, int unifiedLines, bool ignoreWhitespace, Models.DiffResult result)
{ {
@ -285,7 +279,6 @@ namespace SourceGit.ViewModels
private readonly string _repo; private readonly string _repo;
private readonly Models.DiffOption _option = null; private readonly Models.DiffOption _option = null;
private string _title;
private string _fileModeChange = string.Empty; private string _fileModeChange = string.Empty;
private int _unifiedLines = 4; private int _unifiedLines = 4;
private bool _isTextDiff = false; private bool _isTextDiff = false;