Skip to content

Commit

Permalink
[match] git storage: allow simultaneous usage of clone_branch_directl…
Browse files Browse the repository at this point in the history
…y and shallow_clone (#21716)

* [match] combine clone_branch_directly and shallow_clone

* fix: typo

Co-authored-by: Roger Oba <rogerluan.oba@gmail.com>

* chore: refactor git_storage tests

* Remove parenthesis around "it" statements.

---------

Co-authored-by: Roger Oba <rogerluan.oba@gmail.com>
  • Loading branch information
nekrich and rogerluan committed Dec 13, 2023
1 parent 38572a5 commit c54d747
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 206 deletions.
9 changes: 7 additions & 2 deletions match/lib/match/storage/git_storage.rb
Expand Up @@ -92,9 +92,14 @@ def download
command << " -c http.extraheader='Authorization: Bearer #{self.git_bearer_authorization}'" unless self.git_bearer_authorization.nil?

if self.shallow_clone
command << " --depth 1 --no-single-branch"
elsif self.clone_branch_directly
command << " --depth 1"
end

if self.clone_branch_directly
command += " -b #{self.branch.shellescape} --single-branch"
elsif self.shallow_clone
# shallow clone all branches if not cloning branch directly
command += " --no-single-branch"
end

command = command_from_private_key(command) unless self.git_private_key.nil?
Expand Down

0 comments on commit c54d747

Please sign in to comment.