Skip to content

Commit 2478d29

Browse files
committed
code_style: remove unnecessary code in DiffContext
Signed-off-by: leo <longshuang@msn.cn>
1 parent 74f52fb commit 2478d29

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

src/ViewModels/DiffContext.cs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class DiffContext : ObservableObject
1212
{
1313
public string Title
1414
{
15-
get => _title;
15+
get;
1616
}
1717

1818
public bool IgnoreWhitespace
@@ -68,9 +68,9 @@ public DiffContext(string repo, Models.DiffOption option, DiffContext previous =
6868
}
6969

7070
if (string.IsNullOrEmpty(_option.OrgPath) || _option.OrgPath == "/dev/null")
71-
_title = _option.Path;
71+
Title = _option.Path;
7272
else
73-
_title = $"{_option.OrgPath}{_option.Path}";
73+
Title = $"{_option.OrgPath}{_option.Path}";
7474

7575
LoadDiffContent();
7676
}
@@ -112,9 +112,9 @@ private void LoadDiffContent()
112112
Task.Run(() =>
113113
{
114114
var numLines = Preferences.Instance.UseFullTextDiff ? 999999999 : _unifiedLines;
115-
var ignoreWS = Preferences.Instance.IgnoreWhitespaceChangesInDiff;
116-
var latest = new Commands.Diff(_repo, _option, numLines, ignoreWS).Result();
117-
var info = new Info(_option, numLines, ignoreWS, latest);
115+
var ignoreWhitespace = Preferences.Instance.IgnoreWhitespaceChangesInDiff;
116+
var latest = new Commands.Diff(_repo, _option, numLines, ignoreWhitespace).Result();
117+
var info = new Info(_option, numLines, ignoreWhitespace, latest);
118118
if (_info != null && info.IsSame(_info))
119119
return;
120120

@@ -239,30 +239,24 @@ private void LoadDiffContent()
239239
private Models.RevisionSubmodule QuerySubmoduleRevision(string repo, string sha)
240240
{
241241
var commit = new Commands.QuerySingleCommit(repo, sha).Result();
242-
if (commit != null)
243-
{
244-
var body = new Commands.QueryCommitFullMessage(repo, sha).Result();
245-
return new Models.RevisionSubmodule()
246-
{
247-
Commit = commit,
248-
FullMessage = new Models.CommitFullMessage { Message = body }
249-
};
250-
}
242+
if (commit == null)
243+
return new Models.RevisionSubmodule() { Commit = new Models.Commit() { SHA = sha } };
251244

245+
var body = new Commands.QueryCommitFullMessage(repo, sha).Result();
252246
return new Models.RevisionSubmodule()
253247
{
254-
Commit = new Models.Commit() { SHA = sha },
255-
FullMessage = null,
248+
Commit = commit,
249+
FullMessage = new Models.CommitFullMessage { Message = body }
256250
};
257251
}
258252

259253
private class Info
260254
{
261-
public string Argument { get; set; }
262-
public int UnifiedLines { get; set; }
263-
public bool IgnoreWhitespace { get; set; }
264-
public string OldHash { get; set; }
265-
public string NewHash { get; set; }
255+
public string Argument { get; }
256+
public int UnifiedLines { get; }
257+
public bool IgnoreWhitespace { get; }
258+
public string OldHash { get; }
259+
public string NewHash { get; }
266260

267261
public Info(Models.DiffOption option, int unifiedLines, bool ignoreWhitespace, Models.DiffResult result)
268262
{
@@ -285,7 +279,6 @@ public bool IsSame(Info other)
285279

286280
private readonly string _repo;
287281
private readonly Models.DiffOption _option = null;
288-
private string _title;
289282
private string _fileModeChange = string.Empty;
290283
private int _unifiedLines = 4;
291284
private bool _isTextDiff = false;

0 commit comments

Comments
 (0)