From 18ab96ac84bd3f27c580c35dd6bde7256845f431 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 12 Dec 2014 23:54:02 -0800 Subject: [PATCH] minor reorg; deplopy progress --- .gitignore | 1 + cmd_build.go | 2 +- cmd_deploy.go | 28 +++++++++++++++++++++------- {src => lib}/warren/warren.go | 0 warren.go => main.go | 0 5 files changed, 23 insertions(+), 8 deletions(-) rename {src => lib}/warren/warren.go (100%) rename warren.go => main.go (100%) diff --git a/.gitignore b/.gitignore index 9969099..8a35a86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .*.swp /warren +/deploy diff --git a/cmd_build.go b/cmd_build.go index 673d171..fce1357 100644 --- a/cmd_build.go +++ b/cmd_build.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "github.com/dballard/warren/src/warren" + "github.com/dballard/warren/lib/warren" "log" "os" "os/exec" diff --git a/cmd_deploy.go b/cmd_deploy.go index 5c06bf7..cf83a14 100644 --- a/cmd_deploy.go +++ b/cmd_deploy.go @@ -2,8 +2,9 @@ package main import ( "fmt" - "github.com/dballard/warren/src/warren" + "github.com/dballard/warren/lib/warren" "os" + "os/exec" ) var deployUsage = ` @@ -18,13 +19,19 @@ var deployCmd = &Command{ Run: deployRun, } -func checkDeployDir() { +func checkDeployDir() string { _, err := os.Stat("deploy") if err != nil { - os.Mkdir("deploy", os.ModeDir) + os.Mkdir("deploy", os.ModeDir|0777) } - // does ./deploy/DST exist? - // if not make + + githash := warren.GitHash() + dst := "deploy/" + githash + "/" + _, err = os.Stat(dst) + if err != nil { + os.Mkdir(dst, os.ModeDir|0777) + } + return dst } func getDeployFilesList() []string { @@ -32,14 +39,21 @@ func getDeployFilesList() []string { return []string{name} } +func cp(dst, src string) error { + return exec.Command("cp", src, dst, "-r").Run() +} + func deployRun(cmd *Command, args ...string) { if len(args) > 0 && args[0] == "help" { fmt.Print(cmd.Help) return } - - checkDeployDir() + dst := checkDeployDir() + fmt.Println(dst) files := getDeployFilesList() fmt.Println(files) + for _, file := range files { + cp(dst+file, file) + } } diff --git a/src/warren/warren.go b/lib/warren/warren.go similarity index 100% rename from src/warren/warren.go rename to lib/warren/warren.go diff --git a/warren.go b/main.go similarity index 100% rename from warren.go rename to main.go