Skip to content

Commit

Permalink
Limit Rugged Control Repo refspec
Browse files Browse the repository at this point in the history
Some Git platforms (e.g. GitLab) store additional references
beyond the ones typically found in refs/heads for various
tracking/historical reference purposes. For Control Repos
which have been around a long time these additional refs
can number in the tens of thousands. Refs that numerous seem
to cause issues with some versions of Rugged being unable
to properly clone and reference the Control Repo.

This patch limits Control Repo reference fetching to
refs/heads, which is all R10K should need anyways.

See https://docs.gitlab.com/ee/development/gitaly.html#gitlab-specific-references
for details on some of these additional references.
  • Loading branch information
seanmil committed Dec 2, 2024
1 parent 3f06dc6 commit c582010
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Unreleased
- 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)
- Limit Rugged Control Repo refspec to only clone refs/heads [#1412](https://github.com/puppetlabs/r10k/pull/1412)

4.1.0
-----
Expand Down
4 changes: 2 additions & 2 deletions lib/r10k/git/rugged/bare_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def clone(remote)
@_rugged_repo = ::Rugged::Repository.init_at(@path.to_s, true).tap do |repo|
config = repo.config
config['remote.origin.url'] = remote
config['remote.origin.fetch'] = '+refs/*:refs/*'
config['remote.origin.fetch'] = '+refs/heads/*:refs/heads/*'
config['remote.origin.mirror'] = 'true'
end

Expand All @@ -60,7 +60,7 @@ def fetch(remote_name='origin')
proxy = R10K::Git.get_proxy_for_remote(remote)

options = {:credentials => credentials, :prune => true, :proxy_url => proxy}
refspecs = ['+refs/*:refs/*']
refspecs = ['+refs/heads/*:refs/heads/*']

results = nil

Expand Down

0 comments on commit c582010

Please sign in to comment.