From 75d7a70f73bfe621c6adca89aa9011f4e1fe47ee Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 14 Sep 2018 00:50:28 +0700 Subject: 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. --- lib/git/git.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib/git/git.go') 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 -- cgit v1.3-5-g45d5