Skip to content

Commit 743d609

Browse files
committed
code_style: general cleanup
1 parent 6ae8c7c commit 743d609

39 files changed

+195
-336
lines changed

build/scripts/localization-check.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async function calculateTranslationRate() {
6969
const badgeColor = progress >= 75 ? 'yellow' : 'red';
7070

7171
lines.push(`### ![${locale}](https://img.shields.io/badge/${locale}-${progress.toFixed(2)}%25-${badgeColor})`);
72-
lines.push(`<details>\n<summary>Missing keys in ${file}</summary>\n\n${missingKeys.map(key => `- ${key}`).join('\n')}\n\n</details>`)
72+
lines.push(`<details>\n<summary>Missing keys in ${file}</summary>\n\n${missingKeys.map(key => `- \`${key}\``).join('\n')}\n\n</details>`)
7373
} else {
7474
lines.push(`### ![${locale}](https://img.shields.io/badge/${locale}-%E2%88%9A-brightgreen)`);
7575
}

src/App.axaml.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public override void OnFrameworkInitializationCompleted()
411411
if (!string.IsNullOrEmpty(arg))
412412
{
413413
if (arg.StartsWith('"') && arg.EndsWith('"'))
414-
arg = arg.Substring(1, arg.Length - 2).Trim();
414+
arg = arg[1..^1].Trim();
415415

416416
if (arg.Length > 0 && !Path.IsPathFullyQualified(arg))
417417
arg = Path.GetFullPath(arg);
@@ -687,12 +687,10 @@ private string FixFontFamilyName(string input)
687687
}
688688

689689
var name = sb.ToString();
690-
if (name.Contains('#'))
691-
{
692-
if (!name.Equals("fonts:Inter#Inter", StringComparison.Ordinal) &&
693-
!name.Equals("fonts:SourceGit#JetBrains Mono", StringComparison.Ordinal))
694-
continue;
695-
}
690+
if (name.Contains('#') &&
691+
!name.Equals("fonts:Inter#Inter", StringComparison.Ordinal) &&
692+
!name.Equals("fonts:SourceGit#JetBrains Mono", StringComparison.Ordinal))
693+
continue;
696694

697695
trimmed.Add(name);
698696
}

src/Commands/Apply.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
namespace SourceGit.Commands
1+
using System.Text;
2+
3+
namespace SourceGit.Commands
24
{
35
public class Apply : Command
46
{
57
public Apply(string repo, string file, bool ignoreWhitespace, string whitespaceMode, string extra)
68
{
79
WorkingDirectory = repo;
810
Context = repo;
9-
Args = "apply ";
11+
12+
var builder = new StringBuilder("apply ");
1013
if (ignoreWhitespace)
11-
Args += "--ignore-whitespace ";
14+
builder.Append("--ignore-whitespace ");
1215
else
13-
Args += $"--whitespace={whitespaceMode} ";
16+
builder.Append("--whitespace=").Append(whitespaceMode).Append(' ');
1417
if (!string.IsNullOrEmpty(extra))
15-
Args += $"{extra} ";
16-
Args += $"{file.Quoted()}";
18+
builder.Append(extra).Append(' ');
19+
Args = builder.Append(file.Quoted()).ToString();
1720
}
1821
}
1922
}

src/Commands/CherryPick.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace SourceGit.Commands
1+
using System.Text;
2+
3+
namespace SourceGit.Commands
24
{
35
public class CherryPick : Command
46
{
@@ -7,14 +9,14 @@ public CherryPick(string repo, string commits, bool noCommit, bool appendSourceT
79
WorkingDirectory = repo;
810
Context = repo;
911

10-
Args = "cherry-pick ";
12+
var builder = new StringBuilder("cherry-pick ");
1113
if (noCommit)
12-
Args += "-n ";
14+
builder.Append("-n ");
1315
if (appendSourceToMessage)
14-
Args += "-x ";
16+
builder.Append("-x ");
1517
if (!string.IsNullOrEmpty(extraParams))
16-
Args += $"{extraParams} ";
17-
Args += commits;
18+
builder.Append(extraParams).Append(' ');
19+
Args = builder.Append(commits).ToString();
1820
}
1921
}
2022
}

src/Commands/Clone.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace SourceGit.Commands
1+
using System.Text;
2+
3+
namespace SourceGit.Commands
24
{
35
public class Clone : Command
46
{
@@ -7,15 +9,14 @@ public Clone(string ctx, string path, string url, string localName, string sshKe
79
Context = ctx;
810
WorkingDirectory = path;
911
SSHKey = sshKey;
10-
Args = "clone --progress --verbose ";
1112

13+
var builder = new StringBuilder("clone --progress --verbose ");
1214
if (!string.IsNullOrEmpty(extraArgs))
13-
Args += $"{extraArgs} ";
14-
15-
Args += $"{url} ";
16-
15+
builder.Append(extraArgs).Append(' ');
16+
builder.Append(url);
1717
if (!string.IsNullOrEmpty(localName))
18-
Args += localName;
18+
builder.Append(' ').Append(localName);
19+
Args = builder.ToString();
1920
}
2021
}
2122
}

src/Commands/Commit.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.IO;
2+
using System.Text;
23
using System.Threading.Tasks;
34

45
namespace SourceGit.Commands
@@ -12,11 +13,17 @@ public Commit(string repo, string message, bool signOff, bool amend, bool resetA
1213

1314
WorkingDirectory = repo;
1415
Context = repo;
15-
Args = $"commit --allow-empty --file={_tmpFile.Quoted()}";
16+
17+
var builder = new StringBuilder("commit --allow-empty --file=").Append(_tmpFile.Quoted());
1618
if (signOff)
17-
Args += " --signoff";
19+
builder.Append(" --signoff");
1820
if (amend)
19-
Args += resetAuthor ? " --amend --reset-author --no-edit" : " --amend --no-edit";
21+
{
22+
builder.Append(" --amend --no-edit");
23+
if (resetAuthor)
24+
builder.Append(" --reset-author");
25+
}
26+
Args = builder.ToString();
2027
}
2128

2229
public async Task<bool> RunAsync()

src/Commands/CompareRevisions.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,18 @@ private void ParseLine(List<Models.Change> outs, string line)
6464
var change = new Models.Change() { Path = match.Groups[2].Value };
6565
var status = match.Groups[1].Value;
6666

67-
switch (status[0])
67+
var state = status[0] switch
6868
{
69-
case 'M':
70-
change.Set(Models.ChangeState.Modified);
71-
outs.Add(change);
72-
break;
73-
case 'A':
74-
change.Set(Models.ChangeState.Added);
75-
outs.Add(change);
76-
break;
77-
case 'D':
78-
change.Set(Models.ChangeState.Deleted);
79-
outs.Add(change);
80-
break;
81-
case 'C':
82-
change.Set(Models.ChangeState.Copied);
83-
outs.Add(change);
84-
break;
69+
'M' => Models.ChangeState.Modified,
70+
'A' => Models.ChangeState.Added,
71+
'D' => Models.ChangeState.Deleted,
72+
'C' => Models.ChangeState.Copied,
73+
_ => Models.ChangeState.None
74+
};
75+
if (state != Models.ChangeState.None)
76+
{
77+
change.Set(state);
78+
outs.Add(change);
8579
}
8680
}
8781
}

src/Commands/Fetch.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System.Text;
2+
using System.Threading.Tasks;
23

34
namespace SourceGit.Commands
45
{
@@ -10,18 +11,14 @@ public Fetch(string repo, string remote, bool noTags, bool force)
1011

1112
WorkingDirectory = repo;
1213
Context = repo;
13-
Args = "fetch --progress --verbose ";
1414

15-
if (noTags)
16-
Args += "--no-tags ";
17-
else
18-
Args += "--tags ";
15+
var builder = new StringBuilder("fetch --progress --verbose ");
16+
builder.Append(noTags ? "--no-tags " : "--tags ");
1917

2018
if (force)
21-
Args += "--force ";
22-
23-
Args += remote;
19+
builder.Append("--force ");
2420

21+
Args = builder.Append(remote).ToString();
2522
}
2623

2724
public Fetch(string repo, Models.Branch local, Models.Branch remote)

src/Commands/Push.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System.Text;
2+
using System.Threading.Tasks;
23

34
namespace SourceGit.Commands
45
{
@@ -10,18 +11,17 @@ public Push(string repo, string local, string remote, string remoteBranch, bool
1011

1112
WorkingDirectory = repo;
1213
Context = repo;
13-
Args = "push --progress --verbose ";
1414

15+
var builder = new StringBuilder("push --progress --verbose ");
1516
if (withTags)
16-
Args += "--tags ";
17+
builder.Append("--tags ");
1718
if (checkSubmodules)
18-
Args += "--recurse-submodules=check ";
19+
builder.Append("--recurse-submodules=check ");
1920
if (track)
20-
Args += "-u ";
21+
builder.Append("-u ");
2122
if (force)
22-
Args += "--force-with-lease ";
23-
24-
Args += $"{remote} {local}:{remoteBranch}";
23+
builder.Append("--force-with-lease ");
24+
Args = builder.Append(remote).Append(' ').Append(local).Append(':').Append(remoteBranch).ToString();
2525
}
2626

2727
public Push(string repo, string remote, string refname, bool isDelete)

0 commit comments

Comments
 (0)