utils: move git functions to pkg/gitutils

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2015-12-14 11:17:51 +01:00
parent 5fd9a8f603
commit 135cca6f52
4 changed files with 8 additions and 7 deletions

View File

@ -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)
} }

View File

@ -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
} }

View File

@ -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
} }

View File

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