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

Commit d57f5d6

Browse files
authored
Merge pull request #162 from github-for-unity/fixes/task-field-cleanup
Refactoring task names
2 parents fba79fa + c9b040f commit d57f5d6

29 files changed

+69
-47
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ namespace GitHub.Unity
55
{
66
class GitAddTask : ProcessTask<string>
77
{
8+
private const string TaskName = "git add";
89
private readonly string arguments;
910

1011
public GitAddTask(IEnumerable<string> files,
1112
CancellationToken token, IOutputProcessor<string> processor = null)
1213
: base(token, processor ?? new SimpleOutputProcessor())
1314
{
1415
Guard.ArgumentNotNull(files, "files");
16+
Name = TaskName;
1517

1618
arguments = "add ";
1719
arguments += " -- ";
@@ -22,7 +24,6 @@ public GitAddTask(IEnumerable<string> files,
2224
}
2325
}
2426

25-
public override string Name { get { return "git add"; } }
2627
public override string ProcessArguments { get { return arguments; } }
2728
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
2829
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace GitHub.Unity
55
{
66
class GitBranchCreateTask : ProcessTask<string>
77
{
8+
private const string TaskName = "git branch";
89
private readonly string arguments;
910

1011
public GitBranchCreateTask(string newBranch, string baseBranch,
@@ -14,10 +15,10 @@ public GitBranchCreateTask(string newBranch, string baseBranch,
1415
Guard.ArgumentNotNullOrWhiteSpace(newBranch, "newBranch");
1516
Guard.ArgumentNotNullOrWhiteSpace(baseBranch, "baseBranch");
1617

18+
Name = TaskName;
1719
arguments = String.Format("branch {0} {1}", newBranch, baseBranch);
1820
}
1921

20-
public override string Name { get { return "git branch"; } }
2122
public override string ProcessArguments { get { return arguments; } }
2223
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
2324
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ namespace GitHub.Unity
44
{
55
class GitBranchDeleteTask : ProcessTask<string>
66
{
7+
private const string TaskName = "git branch -d";
78
private readonly string arguments;
89

910
public GitBranchDeleteTask(string branch, bool deleteUnmerged,
1011
CancellationToken token, IOutputProcessor<string> processor = null)
1112
: base(token, processor ?? new SimpleOutputProcessor())
1213
{
1314
Guard.ArgumentNotNullOrWhiteSpace(branch, "branch");
15+
Name = TaskName;
1416
arguments = !deleteUnmerged ? $"branch -d {branch}" : $"branch -D {branch}";
1517
}
1618

17-
public override string Name { get { return "git branch"; } }
1819
public override string ProcessArguments { get { return arguments; } }
1920
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
2021
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace GitHub.Unity
55
{
66
class GitCommitTask : ProcessTask<string>
77
{
8+
private const string TaskName = "git commit";
89
private readonly string arguments;
910

1011
public GitCommitTask(string message, string body,
@@ -13,14 +14,14 @@ public GitCommitTask(string message, string body,
1314
{
1415
Guard.ArgumentNotNullOrWhiteSpace(message, "message");
1516

17+
Name = TaskName;
1618
arguments = "commit ";
1719
arguments += String.Format(" -m \"{0}", message);
1820
if (!String.IsNullOrEmpty(body))
1921
arguments += String.Format("{0}{1}", Environment.NewLine, body);
2022
arguments += "\"";
2123
}
2224

23-
public override string Name { get { return "git commit"; } }
2425
public override string ProcessArguments { get { return arguments; } }
2526
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
2627
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ namespace GitHub.Unity
55
{
66
class GitConfigGetAllTask : ProcessTaskWithListOutput<string>
77
{
8+
private const string TaskName = "git config get";
89
private readonly string arguments;
910

1011
public GitConfigGetAllTask(string key, GitConfigSource configSource,
1112
CancellationToken token, BaseOutputListProcessor<string> processor = null)
1213
: base(token, processor ?? new SimpleListOutputProcessor())
1314
{
15+
Guard.ArgumentNotNullOrWhiteSpace(key, nameof(key));
16+
Name = TaskName;
1417
var source = "";
1518
source +=
1619
configSource == GitConfigSource.NonSpecified ? "--get-all" :
@@ -20,19 +23,20 @@ public GitConfigGetAllTask(string key, GitConfigSource configSource,
2023
arguments = String.Format("config {0} {1}", source, key);
2124
}
2225

23-
public override string Name { get { return "git config get"; } }
2426
public override string ProcessArguments { get { return arguments; } }
2527
public override TaskAffinity Affinity { get { return TaskAffinity.Concurrent; } }
2628
}
2729

2830
class GitConfigGetTask : ProcessTask<string>
2931
{
32+
private const string TaskName = "git config get";
3033
private readonly string arguments;
3134

3235
public GitConfigGetTask(string key, GitConfigSource configSource,
3336
CancellationToken token, IOutputProcessor<string> processor = null)
3437
: base(token, processor ?? new FirstNonNullLineOutputProcessor())
3538
{
39+
Name = TaskName;
3640
var source = "";
3741
source +=
3842
configSource == GitConfigSource.NonSpecified ? "--get-all" :
@@ -42,7 +46,6 @@ public GitConfigGetTask(string key, GitConfigSource configSource,
4246
arguments = String.Format("config {0} {1}", source, key);
4347
}
4448

45-
public override string Name { get { return "git config get"; } }
4649
public override string ProcessArguments { get { return arguments; } }
4750
public override TaskAffinity Affinity { get { return TaskAffinity.Concurrent; } }
4851
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ namespace GitHub.Unity
66
{
77
class GitConfigListTask : ProcessTaskWithListOutput<KeyValuePair<string, string>>
88
{
9+
private const string TaskName = "git config list";
910
private readonly string arguments;
1011

1112
public GitConfigListTask(GitConfigSource configSource, CancellationToken token, BaseOutputListProcessor<KeyValuePair<string, string>> processor = null)
1213
: base(token, processor ?? new ConfigOutputProcessor())
1314
{
15+
Name = TaskName;
1416
var source = "";
1517
if (configSource != GitConfigSource.NonSpecified)
1618
{
@@ -24,7 +26,6 @@ public GitConfigListTask(GitConfigSource configSource, CancellationToken token,
2426
arguments = String.Format("config {0} -l", source);
2527
}
2628

27-
public override string Name { get { return "git config list"; } }
2829
public override string ProcessArguments { get { return arguments; } }
2930
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
3031
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Threading;
43

54
namespace GitHub.Unity
65
{
76
class GitConfigSetTask : ProcessTask<string>
87
{
9-
private readonly string value;
108
private readonly string arguments;
11-
private string label;
129

1310
public GitConfigSetTask(string key, string value, GitConfigSource configSource,
1411
CancellationToken token, IOutputProcessor<string> processor = null)
1512
: base(token, processor ?? new SimpleOutputProcessor())
1613
{
17-
this.value = value;
1814
var source = "";
1915
source +=
2016
configSource == GitConfigSource.NonSpecified ? "" :
2117
configSource == GitConfigSource.Local ? "--replace-all --local" :
2218
configSource == GitConfigSource.User ? "--replace-all --global" :
2319
"--replace-all --system";
2420
arguments = String.Format("config {0} {1} \"{2}\"", source, key, value);
25-
label = String.Format("config {0} {1} \"{2}\"", source, key, new String('*', value.Length));
21+
Name = String.Format("config {0} {1} \"{2}\"", source, key, new String('*', value.Length));
2622
}
2723

28-
public override string Name { get { return label;} }
2924
public override string ProcessArguments { get { return arguments; } }
3025
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
3126
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ namespace GitHub.Unity
66
{
77
class GitFetchTask : ProcessTask<string>
88
{
9+
private const string TaskName = "git fetch";
910
private readonly string arguments;
1011

1112
public GitFetchTask(string remote,
1213
CancellationToken token, IOutputProcessor<string> processor = null)
1314
: base(token, processor ?? new SimpleOutputProcessor())
1415
{
16+
Name = TaskName;
1517
var stringBuilder = new StringBuilder();
1618
stringBuilder.Append("fetch");
1719

@@ -24,7 +26,6 @@ public GitFetchTask(string remote,
2426
arguments = stringBuilder.ToString();
2527
}
2628

27-
public override string Name { get { return "git fetch"; } }
2829
public override string ProcessArguments { get { return arguments; } }
2930
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
3031
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ namespace GitHub.Unity
44
{
55
class GitInitTask : ProcessTask<string>
66
{
7+
private const string TaskName = "git init";
8+
79
public GitInitTask(CancellationToken token, IOutputProcessor<string> processor = null)
810
: base(token, processor ?? new SimpleOutputProcessor())
9-
{ }
11+
{
12+
Name = TaskName;
13+
}
1014

11-
public override string Name { get { return "git init"; } }
1215
public override string ProcessArguments { get { return "init"; } }
1316
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
1417
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ namespace GitHub.Unity
44
{
55
class GitLfsInstallTask : ProcessTask<string>
66
{
7+
private const string TaskName = "git lsf install";
8+
79
public GitLfsInstallTask(CancellationToken token, IOutputProcessor<string> processor = null)
810
: base(token, processor ?? new SimpleOutputProcessor())
9-
{ }
11+
{
12+
Name = TaskName;
13+
}
1014

11-
public override string Name { get { return "git lfs install"; } }
1215
public override string ProcessArguments { get { return "lfs install"; } }
1316
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
1417
}

0 commit comments

Comments
 (0)