Skip to content

Commit

Permalink
Introduce --jobs flag on fetch and submodule update commands (#158)
Browse files Browse the repository at this point in the history
* Introduce `--jobs` flag on fetch and submodule update commands

* Added jobs flag to spare checkout tests
  • Loading branch information
Mate Herber authored Apr 9, 2021
1 parent 6dae3c8 commit 02ca068
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 57 deletions.
2 changes: 2 additions & 0 deletions gitclone/checkout_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (

func fetch(gitCmd git.Git, remote string, ref string, traits fetchOptions) error {
var opts []string
opts = append(opts, jobsFlag)

if traits.depth != 0 {
opts = append(opts, "--depth="+strconv.Itoa(traits.depth))
}
Expand Down
3 changes: 2 additions & 1 deletion gitclone/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
const (
checkoutFailedTag = "checkout_failed"
fetchFailedTag = "fetch_failed"
jobsFlag = "--jobs=10"
)

var runner CommandRunner = DefaultRunner{}
Expand Down Expand Up @@ -122,7 +123,7 @@ type getAvailableBranches func() (map[string][]string, error)

func listBranches(gitCmd git.Git) getAvailableBranches {
return func() (map[string][]string, error) {
if err := runner.Run(gitCmd.Fetch()); err != nil {
if err := runner.Run(gitCmd.Fetch(jobsFlag)); err != nil {
return nil, err
}
out, err := runner.RunForOutput(gitCmd.Branch("-r"))
Expand Down
2 changes: 1 addition & 1 deletion gitclone/gitclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func checkoutState(gitCmd git.Git, cfg Config, patch patchSource) error {
}

func updateSubmodules(gitCmd git.Git, cfg Config) error {
if err := runner.Run(gitCmd.SubmoduleUpdate(cfg.LimitSubmoduleUpdateDepth)); err != nil {
if err := runner.Run(gitCmd.SubmoduleUpdate(cfg.LimitSubmoduleUpdateDepth, jobsFlag)); err != nil {
return newStepError(
updateSubmodelFailedTag,
fmt.Errorf("submodule update: %v", err),
Expand Down
Loading

0 comments on commit 02ca068

Please sign in to comment.