From 4954b251f843766bd18b4f4716fe43a4f9dd2745 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 12 Jan 2014 20:21:05 +0800 Subject: [PATCH] =?UTF-8?q?Added=20svn=20update=20support=20for=20option?= =?UTF-8?q?=20=E2=80=9D=E2=80=94update,=20-u=E2=80=9D=20of=20command=20get?= =?UTF-8?q?=20when=20update=20GOPATH=20projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/get.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/get.go b/cmd/get.go index 6a90b1aca..b50bbcab5 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -355,19 +355,12 @@ func updateByVcs(vcs, dirPath string) error { switch vcs { case "git": - stdout, _, err := com.ExecCmd("git", "status") + branch, _, err := com.ExecCmd("git", "rev-parse", "--abbrev-ref", "HEAD") if err != nil { - log.Error("", "Error occurs when 'git status'") + log.Error("", "Error occurs when 'git rev-parse --abbrev-ref HEAD'") log.Error("", "\t"+err.Error()) } - i := strings.Index(stdout, "\n") - if i == -1 { - log.Error("", "Empty result for 'git status'") - return nil - } - - branch := strings.TrimPrefix(stdout[:i], "# On branch ") _, _, err = com.ExecCmd("git", "pull", "origin", branch) if err != nil { log.Error("", "Error occurs when 'git pull origin "+branch+"'") @@ -392,7 +385,14 @@ func updateByVcs(vcs, dirPath string) error { log.Error("", "Error: "+stderr) } case "svn": - log.Error("", "Error: not support svn yet") + _, stderr, err := com.ExecCmd("svn", "update") + if err != nil { + log.Error("", "Error occurs when 'svn update'") + log.Error("", "\t"+err.Error()) + } + if len(stderr) > 0 { + log.Error("", "Error: "+stderr) + } } return nil }