entirely skip passing the --depth argument to git if the depth is configured to 0
fixes #7
This commit is contained in:
parent
de68c4952e
commit
324be5f1f6
12
git/clone.go
12
git/clone.go
|
@ -64,14 +64,20 @@ func (c *gitClient) clone(url string, defaultBranch string, dst string) error {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Clone the repo
|
// Clone the repo
|
||||||
_, err := utils.ExecProcess(
|
args := []string{
|
||||||
"git", "clone",
|
"clone",
|
||||||
"--origin", c.GitClientParam.Remote,
|
"--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
|
url, // repository
|
||||||
dst, // directory
|
dst, // directory
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_, err := utils.ExecProcess("git", args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to clone git repo %v to %v: %v", url, dst, err)
|
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 {
|
if branchName == defaultBranch {
|
||||||
// Pull the repo
|
// Pull the repo
|
||||||
_, err = utils.ExecProcessInDir(
|
args := []string{
|
||||||
repoPath, // workdir
|
"pull",
|
||||||
"git", "pull",
|
}
|
||||||
"--depth", strconv.Itoa(c.GitClientParam.Depth),
|
if c.GitClientParam.Depth != 0 {
|
||||||
|
args = append(args, "--depth", strconv.Itoa(c.GitClientParam.Depth))
|
||||||
|
}
|
||||||
|
args = append(args,
|
||||||
"--",
|
"--",
|
||||||
c.GitClientParam.Remote, // repository
|
c.GitClientParam.Remote, // repository
|
||||||
defaultBranch, // refspec
|
defaultBranch, // refspec
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_, err = utils.ExecProcessInDir(repoPath, "git", args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to pull git repo %v: %v", repoPath, err)
|
return fmt.Errorf("failed to pull git repo %v: %v", repoPath, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue