1
1
using System . Text ;
2
+ using System . Threading . Tasks ;
2
3
3
4
namespace SourceGit . Commands
4
5
{
@@ -13,7 +14,16 @@ public static string ShowCurrent(string repo)
13
14
return cmd . ReadToEnd ( ) . StdOut . Trim ( ) ;
14
15
}
15
16
16
- public static bool Create ( string repo , string name , string basedOn , bool force , Models . ICommandLog log )
17
+ public static async Task < string > ShowCurrentAsync ( string repo )
18
+ {
19
+ var cmd = new Command ( ) ;
20
+ cmd . WorkingDirectory = repo ;
21
+ cmd . Context = repo ;
22
+ cmd . Args = "branch --show-current" ;
23
+ return ( await cmd . ReadToEndAsync ( ) ) . StdOut . Trim ( ) ;
24
+ }
25
+
26
+ public static async Task < bool > CreateAsync ( string repo , string name , string basedOn , bool force , Models . ICommandLog log )
17
27
{
18
28
var builder = new StringBuilder ( ) ;
19
29
builder . Append ( "branch " ) ;
@@ -28,20 +38,20 @@ public static bool Create(string repo, string name, string basedOn, bool force,
28
38
cmd . Context = repo ;
29
39
cmd . Args = builder . ToString ( ) ;
30
40
cmd . Log = log ;
31
- return cmd . Exec ( ) ;
41
+ return await cmd . ExecAsync ( ) ;
32
42
}
33
43
34
- public static bool Rename ( string repo , string name , string to , Models . ICommandLog log )
44
+ public static async Task < bool > RenameAsync ( string repo , string name , string to , Models . ICommandLog log )
35
45
{
36
46
var cmd = new Command ( ) ;
37
47
cmd . WorkingDirectory = repo ;
38
48
cmd . Context = repo ;
39
49
cmd . Args = $ "branch -M { name } { to } ";
40
50
cmd . Log = log ;
41
- return cmd . Exec ( ) ;
51
+ return await cmd . ExecAsync ( ) ;
42
52
}
43
53
44
- public static bool SetUpstream ( string repo , string name , string upstream , Models . ICommandLog log )
54
+ public static async Task < bool > SetUpstreamAsync ( string repo , string name , string upstream , Models . ICommandLog log )
45
55
{
46
56
var cmd = new Command ( ) ;
47
57
cmd . WorkingDirectory = repo ;
@@ -53,31 +63,31 @@ public static bool SetUpstream(string repo, string name, string upstream, Models
53
63
else
54
64
cmd . Args = $ "branch { name } -u { upstream } ";
55
65
56
- return cmd . Exec ( ) ;
66
+ return await cmd . ExecAsync ( ) ;
57
67
}
58
68
59
- public static bool DeleteLocal ( string repo , string name , Models . ICommandLog log )
69
+ public static async Task < bool > DeleteLocalAsync ( string repo , string name , Models . ICommandLog log )
60
70
{
61
71
var cmd = new Command ( ) ;
62
72
cmd . WorkingDirectory = repo ;
63
73
cmd . Context = repo ;
64
74
cmd . Args = $ "branch -D { name } ";
65
75
cmd . Log = log ;
66
- return cmd . Exec ( ) ;
76
+ return await cmd . ExecAsync ( ) ;
67
77
}
68
78
69
- public static bool DeleteRemote ( string repo , string remote , string name , Models . ICommandLog log )
79
+ public static async Task < bool > DeleteRemoteAsync ( string repo , string remote , string name , Models . ICommandLog log )
70
80
{
71
- bool exists = new Remote ( repo ) . HasBranch ( remote , name ) ;
81
+ bool exists = await new Remote ( repo ) . HasBranchAsync ( remote , name ) ;
72
82
if ( exists )
73
- return new Push ( repo , remote , $ "refs/heads/{ name } ", true ) { Log = log } . Exec ( ) ;
83
+ return await new Push ( repo , remote , $ "refs/heads/{ name } ", true ) { Log = log } . ExecAsync ( ) ;
74
84
75
85
var cmd = new Command ( ) ;
76
86
cmd . WorkingDirectory = repo ;
77
87
cmd . Context = repo ;
78
88
cmd . Args = $ "branch -D -r { remote } /{ name } ";
79
89
cmd . Log = log ;
80
- return cmd . Exec ( ) ;
90
+ return await cmd . ExecAsync ( ) ;
81
91
}
82
92
}
83
93
}
0 commit comments