@@ -13,11 +13,25 @@ import (
1313 "os"
1414)
1515
16- //Deliver ...
17- func Deliver (defaultBranch string ) {
16+ //DeliverCaller ...
17+ //Top level deliver call, called from cmd
18+ func DeliverCaller () {
19+ INIBlock := options .GlobalFlagTarget
20+ conf := setting .NewProjectStg (INIBlock )
21+
22+ //If Run if local deliver
23+ if options .GlobalFlagLocal {
24+ LocalDeliver (conf )
25+ return
26+ }
27+ //Deliver with ready branch
28+ Deliver (conf )
29+ }
1830
31+ //Deliver ...
32+ //Push a ready branch to the remote repository
33+ func Deliver (conf * setting.ProjectSetting ) {
1934 git := githandler.Git {Run : executor .RunGit }
20- conf := setting .NewProjectStg ("default" )
2135
2236 ui .PhlowSpinner .Start ("delivering" )
2337 defer ui .PhlowSpinner .Stop ()
@@ -35,8 +49,8 @@ func Deliver(defaultBranch string) {
3549 fmt .Printf ("Could not deliver: %s" , branchInfo .Current )
3650 return
3751 }
38-
39- _ , err = githandler . PushRename ( branchInfo .Current , conf . IntegrationBranch )
52+ //git push origin name:ready/name
53+ _ , err = git . Push ( conf . Remote , fmt . Sprintf ( "%s:ready/%s" , branchInfo .Current , branchInfo . Current ) )
4054 if err != nil {
4155 fmt .Println (err )
4256 return
@@ -45,9 +59,9 @@ func Deliver(defaultBranch string) {
4559 _ , err = git .Branch ("-m" , branchInfo .Current , "delivered/" + branchInfo .Current )
4660 if err != nil {
4761 ui .PhlowSpinner .Stop ()
48- fmt .Fprintln ( os . Stdout , "The branch have been pushed successfully to your remote, but there is a local name conflict" )
49- fmt .Fprintf ( os . Stderr , "CONFLICT: your already have a branch named %s in your workspace \n " , "delivered/" + branchInfo .Current )
50- fmt .Fprintf ( os . Stderr , "to mark it delivered run: git branch -m %s %s \n " , branchInfo .Current , "delivered/" + branchInfo .Current )
62+ fmt .Println ( "The branch have been pushed successfully to your remote, but there is a local name conflict" )
63+ fmt .Printf ( "CONFLICT: your already have a branch named %s in your workspace \n " , "delivered/" + branchInfo .Current )
64+ fmt .Printf ( "to mark it delivered run: git branch -m %s %s \n " , branchInfo .Current , "delivered/" + branchInfo .Current )
5165 os .Exit (1 )
5266 return
5367 }
@@ -64,9 +78,9 @@ func Deliver(defaultBranch string) {
6478}
6579
6680//LocalDeliver ...
67- func LocalDeliver (defaultBranch string ) {
81+ //Delivers locally and pushes the changes to the remote
82+ func LocalDeliver (conf * setting.ProjectSetting ) {
6883 git := githandler.Git {Run : executor .RunGit }
69- conf := setting .NewProjectStg ("default" )
7084
7185 out , err := git .Branch ("-a" )
7286 branchInfo := githandler .AsList (out )
@@ -115,34 +129,5 @@ func LocalDeliver(defaultBranch string) {
115129 return
116130 }
117131 ui .PhlowSpinner .Stop ()
118- fmt .Printf ("Delivered changes from %s to %s \n " , ui .Format .Branch (branchInfo .Current ), ui .Format .Branch (defaultBranch ))
119- }
120-
121- //TestDeliver ...
122- //Run tests and returns
123- func TestDeliver (args []string ) error {
124-
125- cmd , argv := convertCommand (args )
126- output , err := executor .RunCommand (cmd , argv ... )
127-
128- if err != nil {
129- return err
130- }
131-
132- if options .GlobalFlagShowTestOutput {
133- fmt .Println (output )
134- }
135-
136- return nil
137- }
138-
139- //ConvertCommand ...
140- //Formats the command to ExecutorCommand
141- func convertCommand (args []string ) (string , []string ) {
142-
143- //Command with extra arguments
144- if len (args ) > 1 {
145- return args [0 ], args [1 :]
146- }
147- return args [0 ], []string {}
132+ fmt .Printf ("Delivered changes from %s to %s \n " , ui .Format .Branch (branchInfo .Current ), ui .Format .Branch (conf .IntegrationBranch ))
148133}
0 commit comments