Skip to content

Commit 892f3b8

Browse files
committed
code_style: move SourceGit.CommandExtensions to SourceGit.ViewModels.CommandExtensions
Signed-off-by: leo <longshuang@msn.cn>
1 parent afe5d4b commit 892f3b8

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

src/App.Utils.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Commands/Branch.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static bool DeleteRemote(string repo, string remote, string name, Models.
6060
{
6161
bool exists = new Remote(repo).HasBranch(remote, name);
6262
if (exists)
63-
return new Push(repo, remote, $"refs/heads/{name}", true).Use(log).Exec();
63+
return new Push(repo, remote, $"refs/heads/{name}", true) { Log = log }.Exec();
6464

6565
var cmd = new Command();
6666
cmd.WorkingDirectory = repo;

src/Commands/Discard.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public static class Discard
77
{
88
public static void All(string repo, bool includeIgnored, Models.ICommandLog log)
99
{
10-
new Restore(repo).Use(log).Exec();
11-
new Clean(repo, includeIgnored).Use(log).Exec();
10+
new Restore(repo) { Log = log }.Exec();
11+
new Clean(repo, includeIgnored) { Log = log }.Exec();
1212
}
1313

1414
public static void Changes(string repo, List<Models.Change> changes, Models.ICommandLog log)
@@ -27,13 +27,13 @@ public static void Changes(string repo, List<Models.Change> changes, Models.ICom
2727
for (int i = 0; i < needClean.Count; i += 10)
2828
{
2929
var count = Math.Min(10, needClean.Count - i);
30-
new Clean(repo, needClean.GetRange(i, count)).Use(log).Exec();
30+
new Clean(repo, needClean.GetRange(i, count)) { Log = log }.Exec();
3131
}
3232

3333
for (int i = 0; i < needCheckout.Count; i += 10)
3434
{
3535
var count = Math.Min(10, needCheckout.Count - i);
36-
new Restore(repo, needCheckout.GetRange(i, count), "--worktree --recurse-submodules").Use(log).Exec();
36+
new Restore(repo, needCheckout.GetRange(i, count), "--worktree --recurse-submodules") { Log = log }.Exec();
3737
}
3838
}
3939
}

src/ViewModels/CommandLog.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,13 @@ public void Complete()
8484
private StringBuilder _builder = new StringBuilder();
8585
private event Action<string> _onNewLineReceived;
8686
}
87+
88+
public static class CommandExtensions
89+
{
90+
public static T Use<T>(this T cmd, CommandLog log) where T : Commands.Command
91+
{
92+
cmd.Log = log;
93+
return cmd;
94+
}
95+
}
8796
}

0 commit comments

Comments
 (0)