set default timeout for git context

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
pull/1470/head
CrazyMax 3 years ago
parent b741d26eb5
commit 9ac3072589
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7

@ -6,6 +6,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"
"github.com/docker/buildx/util/gitutil"
specs "github.com/opencontainers/image-spec/specs-go/v1"
@ -15,6 +16,9 @@ import (
const DockerfileLabel = "com.docker.image.source.entrypoint"
func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath string) (res map[string]string) {
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()
res = make(map[string]string)
if contextPath == "" {
return

@ -98,7 +98,7 @@ func (c *Git) run(args ...string) (string, error) {
}
args = append(extraArgs, args...)
cmd := exec.Command("git", args...)
cmd := exec.CommandContext(c.ctx, "git", args...)
if c.wd != "" {
cmd.Dir = c.wd
}

Loading…
Cancel
Save