entirely skip passing the --depth argument to git if the depth is configured to 0
fixes #7
This commit is contained in:
parent
45cef75960
commit
38362eebdd
12
git/clone.go
12
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)
|
||||
}
|
||||
|
|
13
git/pull.go
13
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue