From f34fbacf139b3e68a2f5c615f16592ddf0eb40c5 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Fri, 26 Oct 2018 15:01:48 +0300 Subject: [PATCH] Add git push to code init command --- cmd/podcli/code.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cmd/podcli/code.go b/cmd/podcli/code.go index 4e25b6e..7fead73 100644 --- a/cmd/podcli/code.go +++ b/cmd/podcli/code.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "log" "os" + "os/exec" "path" "path/filepath" "regexp" @@ -45,6 +46,7 @@ func init() { } func runCodeInit(cmd *cobra.Command, args []string) error { + if len(codeGitUser) < 0 { return fmt.Errorf("--git-user is required") } @@ -122,8 +124,23 @@ func runCodeInit(cmd *cobra.Command, args []string) error { } } - fmt.Printf("Done %s\n", codeProjectPath) + err = gitPush() + if err != nil { + log.Fatalf("git push error: %s", err) + os.Exit(1) + } + fmt.Println("Initialization finished") + return nil +} + +func gitPush() error { + cmd := exec.Command("sh", "-c", "git add . && git commit -m \"init\" && git push") + output , err := cmd.Output() + if err != nil { + return err + } + fmt.Println(string(output)) return nil }