From 61e83d23cebb450a71c081e83d3fe087a0fd30bd Mon Sep 17 00:00:00 2001 From: WenHuxian Date: Wed, 14 Jan 2015 11:28:27 +0800 Subject: [PATCH 1/2] add :update support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gom 'git.example.com/example', :command => 'git clone git@git.example.com:example’, :update => 'git fetch' --- install.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/install.go b/install.go index f01a795..08502b8 100644 --- a/install.go +++ b/install.go @@ -109,15 +109,25 @@ func (gom *Gom) Clone(args []string) error { target = gom.name } + var customCmd []string srcdir := filepath.Join(vendor, "src", target) - customCmd := strings.Split(command, " ") - customCmd = append(customCmd, srcdir) - - fmt.Printf("fetching %s (%v)\n", gom.name, customCmd) - err = run(customCmd, Blue) - if err != nil { - return err + if _, err := os.Stat(srcdir); err == nil || os.IsExist(err) { + if update, ok := gom.options["update"].(string); ok { + customCmd = strings.Split(update, " ") + customCmd = append(customCmd) + fmt.Printf("updating %s (%v)\n", gom.name, customCmd) + vcsExec(srcdir, customCmd...) + } + } else { + customCmd := strings.Split(command, " ") + customCmd = append(customCmd, srcdir) + fmt.Printf("fetching %s (%v)\n", gom.name, customCmd) + err = run(customCmd, Blue) + if err != nil { + return err + } } + } else if private, ok := gom.options["private"].(string); ok { if private == "true" { target, ok := gom.options["target"].(string) From 27f3cbd16a2e7091cc88734ea688b1a5da11fef9 Mon Sep 17 00:00:00 2001 From: WenHuxian Date: Wed, 14 Jan 2015 18:07:50 +0800 Subject: [PATCH 2/2] update README , add :update => xxx ``` gom 'github.com/username/repository', :command => 'git clone http://example.com/repository.git', :update => 'git fetch' ``` --- README.mkd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 2995903..0166e75 100644 --- a/README.mkd +++ b/README.mkd @@ -89,7 +89,7 @@ If you want to bundle specified tag, branch or commit If you want to bundle a repository that `go get` can't access - gom 'github.com/username/repository', :command => 'git clone http://example.com/repository.git' + gom 'github.com/username/repository', :command => 'git clone http://example.com/repository.git', :update => 'git fetch' Todo ----