Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 12fb6e6

Browse files
committed
Make the code less error-prone
1 parent 466df4d commit 12fb6e6

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/GitHub.Api/Git/GitClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public ITask<string> Fetch(string remote,
276276
{
277277
//Logger.Trace("Fetch");
278278

279-
return new GitFetchTask(remote, cancellationToken, true, true, processor)
279+
return new GitFetchTask(remote, cancellationToken, processor: processor)
280280
.Configure(processManager);
281281
}
282282

src/GitHub.Api/Git/Tasks/GitFetchTask.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
using System.Text;
2+
using System.Collections.Generic;
33
using System.Threading;
44

55
namespace GitHub.Unity
@@ -10,30 +10,28 @@ class GitFetchTask : ProcessTask<string>
1010
private readonly string arguments;
1111

1212
public GitFetchTask(string remote,
13-
CancellationToken token, bool prune = false, bool tags = false, IOutputProcessor<string> processor = null)
13+
CancellationToken token, bool prune = true, bool tags = true, IOutputProcessor<string> processor = null)
1414
: base(token, processor ?? new SimpleOutputProcessor())
1515
{
1616
Name = TaskName;
17-
var stringBuilder = new StringBuilder();
18-
stringBuilder.Append("fetch");
17+
var args = new List<string> { "fetch" };
1918

2019
if (prune)
2120
{
22-
stringBuilder.Append(" -p");
21+
args.Add("--prune");
2322
}
2423

2524
if (tags)
2625
{
27-
stringBuilder.Append(" --tags");
26+
args.Add("--tags");
2827
}
2928

3029
if (!String.IsNullOrEmpty(remote))
3130
{
32-
stringBuilder.Append(" ");
33-
stringBuilder.Append(remote);
31+
args.Add(remote);
3432
}
3533

36-
arguments = stringBuilder.ToString();
34+
arguments = args.Join(" ");
3735
}
3836

3937
public override string ProcessArguments { get { return arguments; } }

0 commit comments

Comments
 (0)