diff --git a/CHANGELOG.mkd b/CHANGELOG.mkd index cf26c3664..255980761 100644 --- a/CHANGELOG.mkd +++ b/CHANGELOG.mkd @@ -7,6 +7,7 @@ Unreleased - Add Ruby 3.3 to CI [#1403](https://github.com/puppetlabs/r10k/pull/1403) - Require Ruby 3.1 [#1402](https://github.com/puppetlabs/r10k/pull/1402) - Replace deprecated action: actions/setup-ruby->ruby/setup-ruby [#1406](https://github.com/puppetlabs/r10k/pull/1406) +- Ensure git repositories are pruned on fetch [#1410](https://github.com/puppetlabs/r10k/pull/1410) 4.1.0 ----- diff --git a/lib/r10k/git/rugged/working_repository.rb b/lib/r10k/git/rugged/working_repository.rb index a5bc44b38..ed1d82e4a 100644 --- a/lib/r10k/git/rugged/working_repository.rb +++ b/lib/r10k/git/rugged/working_repository.rb @@ -89,7 +89,7 @@ def fetch(remote_name = 'origin') remote = remotes[remote_name] proxy = R10K::Git.get_proxy_for_remote(remote) - options = {:credentials => credentials, :proxy_url => proxy} + options = {:credentials => credentials, :proxy_url => proxy, :prune => true} refspecs = ["+refs/heads/*:refs/remotes/#{remote_name}/*"] results = nil diff --git a/lib/r10k/git/shellgit/thin_repository.rb b/lib/r10k/git/shellgit/thin_repository.rb index 850e110a8..e748e78f3 100644 --- a/lib/r10k/git/shellgit/thin_repository.rb +++ b/lib/r10k/git/shellgit/thin_repository.rb @@ -31,7 +31,7 @@ def clone(remote, opts = {}) # Fetch refs from the backing bare Git repository. def fetch(remote = 'cache') - git ['fetch', remote], :path => @path.to_s + git ['fetch', remote, '--prune'], :path => @path.to_s end # @return [String] The origin remote URL