瀏覽代碼

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/opts"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/archive"
 	"github.com/docker/docker/pkg/fileutils"
 	"github.com/docker/docker/pkg/fileutils"
+	"github.com/docker/docker/pkg/gitutils"
 	"github.com/docker/docker/pkg/httputils"
 	"github.com/docker/docker/pkg/httputils"
 	"github.com/docker/docker/pkg/jsonmessage"
 	"github.com/docker/docker/pkg/jsonmessage"
 	flag "github.com/docker/docker/pkg/mflag"
 	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
 // path of the dockerfile in that context directory, and a non-nil error on
 // success.
 // success.
 func getContextFromGitURL(gitURL, dockerfileName string) (absContextDir, relDockerfile string, err error) {
 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)
 		return "", "", fmt.Errorf("unable to 'git clone' to temporary context directory: %v", err)
 	}
 	}
 
 

+ 2 - 2
builder/git.go

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

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

@@ -1,4 +1,4 @@
-package utils
+package gitutils
 
 
 import (
 import (
 	"fmt"
 	"fmt"
@@ -14,9 +14,9 @@ import (
 	"github.com/docker/docker/pkg/urlutil"
 	"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"
 // will be under "docker-build-git"
-func GitClone(remoteURL string) (string, error) {
+func Clone(remoteURL string) (string, error) {
 	if !urlutil.IsGitTransport(remoteURL) {
 	if !urlutil.IsGitTransport(remoteURL) {
 		remoteURL = "https://" + remoteURL
 		remoteURL = "https://" + remoteURL
 	}
 	}

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

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