From ab1826f523cb97eb57cc82db1dc1f8c53d3a7b20 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Tue, 27 Sep 2022 19:57:22 -0700 Subject: [PATCH] Fix ~depth parameter for git downloads --- download/download.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/download/download.go b/download/download.go index dd58bb7..68771c9 100644 --- a/download/download.go +++ b/download/download.go @@ -76,7 +76,7 @@ func Get(ctx context.Context, opts GetOptions) error { commit := query.Get("~commit") query.Del("~commit") - depth := query.Get("~depth") + depthStr := query.Get("~depth") query.Del("~depth") var refName plumbing.ReferenceName @@ -98,9 +98,12 @@ func Get(ctx context.Context, opts GetOptions) error { dstDir = filepath.Join(opts.Destination, name) } - depth, err := strconv.Atoi(depth) - if err != nil { - return err + depth := 0 + if depthStr != "" { + depth, err = strconv.Atoi(depthStr) + if err != nil { + return err + } } cloneOpts := &git.CloneOptions{