Skip to content

Commit

Permalink
feat(worker): depth to 50 (#3151)
Browse files Browse the repository at this point in the history
before having advanced action parameters on
gitClone and checkoutApplication

Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
yesnault authored Aug 7, 2018
1 parent c3263a0 commit 618d407
Showing 3 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions engine/worker/builtin_checkout_application.go
Original file line number Diff line number Diff line change
@@ -30,33 +30,34 @@ func runCheckoutApplication(w *currentWorker) BuiltInAction {
}

//Prepare all options - clone options
var clone = &git.CloneOpts{
var opts = &git.CloneOpts{
Recursive: true,
NoStrictHostKeyChecking: true,
Depth: 50,
}
if branch != nil {
clone.Branch = branch.Value
opts.Branch = branch.Value
} else {
clone.SingleBranch = true
opts.SingleBranch = true
}

// if there is no branch, check if there a defaultBranch
if (clone.Branch == "" || clone.Branch == "{{.git.branch}}") && defaultBranch != "" {
clone.Branch = defaultBranch
clone.SingleBranch = false
if (opts.Branch == "" || opts.Branch == "{{.git.branch}}") && defaultBranch != "" {
opts.Branch = defaultBranch
opts.SingleBranch = false
sendLog(fmt.Sprintf("branch is empty, using the default branch %s", defaultBranch))
}

r, _ := regexp.Compile("{{.*}}")
if commit != nil && commit.Value != "" && !r.MatchString(commit.Value) {
clone.CheckoutCommit = commit.Value
opts.CheckoutCommit = commit.Value
}

var dir string
if directory != nil {
dir = directory.Value
}

return gitClone(w, params, gitURL, dir, auth, clone, sendLog)
return gitClone(w, params, gitURL, dir, auth, opts, sendLog)
}
}
17 changes: 9 additions & 8 deletions engine/worker/builtin_gitclone.go
Original file line number Diff line number Diff line change
@@ -125,33 +125,34 @@ func runGitClone(w *currentWorker) BuiltInAction {
}

//Prepare all options - clone options
var clone = &git.CloneOpts{
var opts = &git.CloneOpts{
Recursive: true,
NoStrictHostKeyChecking: true,
Depth: 50,
}
if branch != nil {
clone.Branch = branch.Value
opts.Branch = branch.Value
} else {
clone.SingleBranch = true
opts.SingleBranch = true
}

// if there is no branch, check if there a defaultBranch
if (clone.Branch == "" || clone.Branch == "{{.git.branch}}") && defaultBranch != "" {
clone.Branch = defaultBranch
clone.SingleBranch = false
if (opts.Branch == "" || opts.Branch == "{{.git.branch}}") && defaultBranch != "" {
opts.Branch = defaultBranch
opts.SingleBranch = false
sendLog(fmt.Sprintf("branch is empty, using the default branch %s", defaultBranch))
}

r, _ := regexp.Compile("{{.*}}")
if commit != nil && commit.Value != "" && !r.MatchString(commit.Value) {
clone.CheckoutCommit = commit.Value
opts.CheckoutCommit = commit.Value
}

var dir string
if directory != nil {
dir = directory.Value
}
return gitClone(w, params, url.Value, dir, auth, clone, sendLog)
return gitClone(w, params, url.Value, dir, auth, opts, sendLog)
}
}

2 changes: 1 addition & 1 deletion sdk/hatchery/pool.go
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ func WorkerPool(h Interface, status ...sdk.Status) ([]sdk.Worker, error) {
if !found && w.Status != sdk.StatusDisabled {
log.Error("Hatchery > WorkerPool> Worker %s (status = %s) inconsistency", w.Name, w.Status.String())
if err := h.CDSClient().WorkerDisable(w.ID); err != nil {
log.Error("Hatchery > WorkerPool> Unable to disable worker [%d]%s", w.ID, w.Name)
log.Error("Hatchery > WorkerPool> Unable to disable worker [%s]%s", w.ID, w.Name)
}
w.Status = sdk.StatusDisabled
}

0 comments on commit 618d407

Please sign in to comment.