Преглед на файлове

utils: move git functions to pkg/gitutils

Signed-off-by: Tibor Vass <tibor@docker.com>
Tibor Vass преди 9 години
родител
ревизия
135cca6f52
променени са 4 файла, в които са добавени 8 реда и са изтрити 7 реда
  1. 2 1
      api/client/build.go
  2. 2 2
      builder/git.go
  3. 3 3
      pkg/gitutils/gitutils.go
  4. 1 1
      pkg/gitutils/gitutils_test.go

+ 2 - 1
api/client/build.go

@@ -20,6 +20,7 @@ import (
 	"github.com/docker/docker/opts"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/fileutils"
+	"github.com/docker/docker/pkg/gitutils"
 	"github.com/docker/docker/pkg/httputils"
 	"github.com/docker/docker/pkg/jsonmessage"
 	flag "github.com/docker/docker/pkg/mflag"
@@ -421,7 +422,7 @@ func getContextFromReader(r io.Reader, dockerfileName string) (absContextDir, re
 // path of the dockerfile in that context directory, and a non-nil error on
 // success.
 func getContextFromGitURL(gitURL, dockerfileName string) (absContextDir, relDockerfile string, err error) {
-	if absContextDir, err = utils.GitClone(gitURL); err != nil {
+	if absContextDir, err = gitutils.Clone(gitURL); err != nil {
 		return "", "", fmt.Errorf("unable to 'git clone' to temporary context directory: %v", err)
 	}
 

+ 2 - 2
builder/git.go

@@ -4,12 +4,12 @@ import (
 	"os"
 
 	"github.com/docker/docker/pkg/archive"
-	"github.com/docker/docker/utils"
+	"github.com/docker/docker/pkg/gitutils"
 )
 
 // MakeGitContext returns a Context from gitURL that is cloned in a temporary directory.
 func MakeGitContext(gitURL string) (ModifiableContext, error) {
-	root, err := utils.GitClone(gitURL)
+	root, err := gitutils.Clone(gitURL)
 	if err != nil {
 		return nil, err
 	}

+ 3 - 3
utils/git.go → pkg/gitutils/gitutils.go

@@ -1,4 +1,4 @@
-package utils
+package gitutils
 
 import (
 	"fmt"
@@ -14,9 +14,9 @@ import (
 	"github.com/docker/docker/pkg/urlutil"
 )
 
-// GitClone clones a repository into a newly created directory which
+// Clone clones a repository into a newly created directory which
 // will be under "docker-build-git"
-func GitClone(remoteURL string) (string, error) {
+func Clone(remoteURL string) (string, error) {
 	if !urlutil.IsGitTransport(remoteURL) {
 		remoteURL = "https://" + remoteURL
 	}

+ 1 - 1
utils/git_test.go → pkg/gitutils/gitutils_test.go

@@ -1,4 +1,4 @@
-package utils
+package gitutils
 
 import (
 	"fmt"