Skip to content

Add --filter to Git.clone for partial clones #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a test for the --filter option of git clone
  • Loading branch information
jcouball committed Apr 1, 2023
commit fa178a2d409b401b023d739c5971e725b039328d
25 changes: 25 additions & 0 deletions tests/units/test_git_clone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,29 @@ def test_git_clone_with_no_name
assert_equal(expected_command_line, actual_command_line)
end

test 'clone with a filter' do
repository_url = 'https://github.com/ruby-git/ruby-git.git'
destination = 'ruby-git'

actual_command_line = nil

in_temp_dir do |path|
git = Git.init('.')

# Mock the Git::Lib#command method to capture the actual command line args
git.lib.define_singleton_method(:command) do |cmd, *opts, &block|
actual_command_line = [cmd, *opts.flatten]
end

git.lib.clone(repository_url, destination, filter: 'tree:0')
end

expected_command_line = [
'clone',
'--filter', 'tree:0',
'--', repository_url, destination
]

assert_equal(expected_command_line, actual_command_line)
end
end