From 16f5a675ae4fe765fad6a01e16e159405320f438 Mon Sep 17 00:00:00 2001 From: Nick Bertrand Date: Fri, 22 Nov 2024 14:22:32 -0600 Subject: [PATCH 1/2] Ensure old refs are pruned on fetch --- lib/r10k/git/rugged/working_repository.rb | 2 +- lib/r10k/git/shellgit/thin_repository.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From 72acc2b66eeeb630efa1a3fa41a100561bcf8755 Mon Sep 17 00:00:00 2001 From: Nick Bertrand Date: Fri, 22 Nov 2024 14:39:07 -0600 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.mkd | 1 + 1 file changed, 1 insertion(+) 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 -----