11using System . Text ;
2+ using System . Threading . Tasks ;
23
34namespace SourceGit . Commands
45{
@@ -13,7 +14,16 @@ public static string ShowCurrent(string repo)
1314 return cmd . ReadToEnd ( ) . StdOut . Trim ( ) ;
1415 }
1516
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 )
1727 {
1828 var builder = new StringBuilder ( ) ;
1929 builder . Append ( "branch " ) ;
@@ -28,20 +38,20 @@ public static bool Create(string repo, string name, string basedOn, bool force,
2838 cmd . Context = repo ;
2939 cmd . Args = builder . ToString ( ) ;
3040 cmd . Log = log ;
31- return cmd . Exec ( ) ;
41+ return await cmd . ExecAsync ( ) ;
3242 }
3343
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 )
3545 {
3646 var cmd = new Command ( ) ;
3747 cmd . WorkingDirectory = repo ;
3848 cmd . Context = repo ;
3949 cmd . Args = $ "branch -M { name } { to } ";
4050 cmd . Log = log ;
41- return cmd . Exec ( ) ;
51+ return await cmd . ExecAsync ( ) ;
4252 }
4353
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 )
4555 {
4656 var cmd = new Command ( ) ;
4757 cmd . WorkingDirectory = repo ;
@@ -53,31 +63,31 @@ public static bool SetUpstream(string repo, string name, string upstream, Models
5363 else
5464 cmd . Args = $ "branch { name } -u { upstream } ";
5565
56- return cmd . Exec ( ) ;
66+ return await cmd . ExecAsync ( ) ;
5767 }
5868
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 )
6070 {
6171 var cmd = new Command ( ) ;
6272 cmd . WorkingDirectory = repo ;
6373 cmd . Context = repo ;
6474 cmd . Args = $ "branch -D { name } ";
6575 cmd . Log = log ;
66- return cmd . Exec ( ) ;
76+ return await cmd . ExecAsync ( ) ;
6777 }
6878
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 )
7080 {
71- bool exists = new Remote ( repo ) . HasBranch ( remote , name ) ;
81+ bool exists = await new Remote ( repo ) . HasBranchAsync ( remote , name ) ;
7282 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 ( ) ;
7484
7585 var cmd = new Command ( ) ;
7686 cmd . WorkingDirectory = repo ;
7787 cmd . Context = repo ;
7888 cmd . Args = $ "branch -D -r { remote } /{ name } ";
7989 cmd . Log = log ;
80- return cmd . Exec ( ) ;
90+ return await cmd . ExecAsync ( ) ;
8191 }
8292 }
8393}
0 commit comments