From f01a3f5ffbdefcf79b08ea67f87c18bc61ec8eb0 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 8 May 2019 22:03:06 -0400 Subject: [PATCH] adds git initialization to scaffolded asset repo --- Makefile | 2 +- scaffold/scaffold.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 51e076e..1dbccce 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ $(SCAFFOLD_BIN): $(PACKR_FILE) $(PACKR_FILE): $(ASSETS) ifndef HAS_PACKR2 - go get -u github.com/gobuffalo/packr/v2/packr2 + gobin github.com/gobuffalo/packr/v2/packr2 endif packr2 diff --git a/scaffold/scaffold.go b/scaffold/scaffold.go index 317c767..98b4288 100644 --- a/scaffold/scaffold.go +++ b/scaffold/scaffold.go @@ -3,8 +3,10 @@ package main import ( "fmt" "os" + "os/exec" "github.com/davidovich/summon/pkg/scaffold" + "github.com/davidovich/summon/pkg/command" "github.com/spf13/cobra" ) @@ -21,6 +23,8 @@ func execute(rootCmd *cobra.Command) int { return 0 } +var execCmd = command.New + func newMainCmd() *cobra.Command { var dest string var force bool @@ -39,6 +43,14 @@ func newMainCmd() *cobra.Command { err := scaffold.Create(dest, args[0], summonName, force) if err == nil { fmt.Println("Successfully scaffolded a summon asset repo") + git, err := exec.LookPath("git") + if err != nil { + fmt.Println("Warn: could not find git on PATH to initialize repository") + return nil + } + gitcmd := execCmd(git, "-C", dest, "init") + gitcmd.Stdout = os.Stdout + _ = gitcmd.Run() } return err },