diff --git a/git/clone.go b/git/clone.go index 10b9f3b..ac7ea3a 100644 --- a/git/clone.go +++ b/git/clone.go @@ -64,14 +64,20 @@ func (c *gitClient) clone(url string, defaultBranch string, dst string) error { } } else { // Clone the repo - _, err := utils.ExecProcess( - "git", "clone", + args := []string{ + "clone", "--origin", c.GitClientParam.Remote, - "--depth", strconv.Itoa(c.GitClientParam.Depth), + } + if c.GitClientParam.Depth != 0 { + args = append(args, "--depth", strconv.Itoa(c.GitClientParam.Depth)) + } + args = append(args, "--", url, // repository dst, // directory ) + + _, err := utils.ExecProcess("git", args...) if err != nil { return fmt.Errorf("failed to clone git repo %v to %v: %v", url, dst, err) } diff --git a/git/pull.go b/git/pull.go index b53d908..549ec69 100644 --- a/git/pull.go +++ b/git/pull.go @@ -20,14 +20,19 @@ func (c *gitClient) pull(repoPath string, defaultBranch string) error { if branchName == defaultBranch { // Pull the repo - _, err = utils.ExecProcessInDir( - repoPath, // workdir - "git", "pull", - "--depth", strconv.Itoa(c.GitClientParam.Depth), + args := []string{ + "pull", + } + if c.GitClientParam.Depth != 0 { + args = append(args, "--depth", strconv.Itoa(c.GitClientParam.Depth)) + } + args = append(args, "--", c.GitClientParam.Remote, // repository defaultBranch, // refspec ) + + _, err = utils.ExecProcessInDir(repoPath, "git", args...) if err != nil { return fmt.Errorf("failed to pull git repo %v: %v", repoPath, err) }