Skip to content

Commit

Permalink
fix(clone): omit checkout depth if it is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrocode committed Mar 3, 2023
1 parent 890a5f7 commit b58c33d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions server/events/working_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,24 @@ func (w *FileWorkspace) forceClone(log logging.SimpleLogging,
return nil
}

// if branch strategy, use depth=1
if !w.CheckoutMerge {
return runGit("clone", "--depth=1", "--branch", p.HeadBranch, "--single-branch", headCloneURL, cloneDir)
}

// if merge strategy...

if err := runGit("clone", "--depth", fmt.Sprint(w.CheckoutDepth), "--branch", p.BaseBranch, "--single-branch", baseCloneURL, cloneDir); err != nil {
return err
// if no checkout depth, omit depth arg
if w.CheckoutDepth == 0 {
if err := runGit("clone", "--branch", p.BaseBranch, "--single-branch", baseCloneURL, cloneDir); err != nil {
return err
}
} else {
if err := runGit("clone", "--depth", fmt.Sprint(w.CheckoutDepth), "--branch", p.BaseBranch, "--single-branch", baseCloneURL, cloneDir); err != nil {
return err
}
}

if err := runGit("remote", "add", "head", headCloneURL); err != nil {
return err
}
Expand Down

0 comments on commit b58c33d

Please sign in to comment.