aboutsummaryrefslogtreecommitdiff
path: root/lib/git/git.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2018-09-14 00:50:28 +0700
committerShulhan <ms@kilabit.info>2018-09-14 04:09:00 +0700
commit75d7a70f73bfe621c6adca89aa9011f4e1fe47ee (patch)
tree5f3ef2700561c08cd113d0f9486505bbeae30afb /lib/git/git.go
parentab4af2a75dba68d50eb48aa8d86160c8c840508c (diff)
downloadpakakeh.go-75d7a70f73bfe621c6adca89aa9011f4e1fe47ee.tar.xz
lib/git: remove call to FetchAll when checking out revision
Let the client handle fetch, to prevent calling double fetch by package and by user.
Diffstat (limited to 'lib/git/git.go')
-rw-r--r--lib/git/git.go10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/git/git.go b/lib/git/git.go
index 18576797..3e067c03 100644
--- a/lib/git/git.go
+++ b/lib/git/git.go
@@ -35,6 +35,10 @@ var (
// If branch is empty, it will use default branch "master".
// If revision is empty, it will do nothing.
//
+// This function assume that repository is up-to-date with remote.
+// Client may call FetchAll() before, to prevent checking out revision that
+// may not exist.
+//
func CheckoutRevision(repoDir, ref, branch, revision string) error {
if len(revision) == 0 {
return nil
@@ -54,12 +58,6 @@ func CheckoutRevision(repoDir, ref, branch, revision string) error {
return err
}
- err = FetchAll(repoDir)
- if err != nil {
- err = fmt.Errorf("CheckoutRevision: %s", err)
- return err
- }
-
cmd = exec.Command("git")
cmd.Dir = repoDir
cmd.Stdout = _stdout