Dzahn has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/383842 )
Change subject: Support --bare in git::clone() ...................................................................... Support --bare in git::clone() --bare have the git objects directly inside <directory> which acts as the $GIT_DIR. The workspace is not fetched out. For CI containers, we need objects to be available on the hosts to speed up the clone operations. That is similar to what we did for Nodepool images that already ship with a selection of git repositories. Example usage: git clone --reference /srv/git/operations/puppet.git \ https://gerrit.wikimedia.org/r/p/operations/puppet.git The git clone exec has a 'creates' for $GIT_DIR/config. Which thus vary depending on $bare. Bug: T178076 Change-Id: I4244c9507a8ef063fa0f6210c92ea3a42356c3ce --- M modules/git/.fixtures.yml M modules/git/manifests/clone.pp A modules/git/spec/defines/clone_spec.rb 3 files changed, 48 insertions(+), 2 deletions(-) Approvals: Ottomata: Looks good to me, but someone else must approve Hashar: Looks good to me, but someone else must approve jenkins-bot: Verified Dzahn: Looks good to me, approved diff --git a/modules/git/.fixtures.yml b/modules/git/.fixtures.yml index 13e8f29..cde0bd2 100644 --- a/modules/git/.fixtures.yml +++ b/modules/git/.fixtures.yml @@ -1,3 +1,4 @@ fixtures: symlinks: git: "#{source_dir}" + stdlib: "../../../../stdlib" diff --git a/modules/git/manifests/clone.pp b/modules/git/manifests/clone.pp index de0fc34..3dcfe36 100644 --- a/modules/git/manifests/clone.pp +++ b/modules/git/manifests/clone.pp @@ -19,6 +19,8 @@ # $+owner+:: Owner of $directory, default: _root_. git commands will be run # by this user. # $+group+:: Group owner of $directory, default: 'root' +# $+bare+:: $directory is the GIT_DIR itself. Workspace is not checked out. +# Default: false # $+recurse_submodules:: If true, git # $+shared+:: Enable git's core.sharedRepository=group setting for sharing the # repository between serveral users, default: false @@ -57,6 +59,7 @@ $shared=false, $timeout='300', $depth='full', + $bare=false, $recurse_submodules=false, $umask=undef, $mode=undef, @@ -129,6 +132,14 @@ default => " --depth=${depth}" } + if $bare == true { + $barearg = ' --bare' + $git_dir = $directory + } else { + $barearg = '' + $git_dir = "${directory}/.git" + } + if $shared { $shared_arg = '-c core.sharedRepository=group' } else { @@ -141,12 +152,12 @@ Exec { path => '/usr/bin:/bin' } # clone the repository exec { "git_clone_${title}": - command => "${git} ${shared_arg} clone ${recurse_submodules_arg}${brancharg}${remote}${deptharg} ${directory}", + command => "${git} ${shared_arg} clone ${recurse_submodules_arg}${brancharg}${remote}${deptharg}${barearg} ${directory}", provider => shell, logoutput => on_failure, cwd => '/tmp', environment => $env, - creates => "${directory}/.git/config", + creates => "${git_dir}/config", user => $owner, group => $group, umask => $git_umask, diff --git a/modules/git/spec/defines/clone_spec.rb b/modules/git/spec/defines/clone_spec.rb new file mode 100644 index 0000000..20d2271 --- /dev/null +++ b/modules/git/spec/defines/clone_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe 'git::clone' do + let(:title) { 'operations/puppet' } + + context 'dummy invocation' do + let(:params) { { + :directory => '/srv/git/operations/puppet' + } } + it 'checkouts a workspace' do + should contain_exec('git_clone_operations/puppet') + .without_command(/ --bare /) + end + it 'tracks the proper created file' do + should contain_exec('git_clone_operations/puppet') + .with_creates('/srv/git/operations/puppet/.git/config') + end + end + + context 'when enabling $bare' do + let(:params) { { + :directory => '/srv/git/operations/puppet.git', + :bare => true, + } } + it 'git clone is passed --bare' do + should contain_exec('git_clone_operations/puppet') + .with_command(/ --bare /) + end + it 'tracks the proper created file' do + should contain_exec('git_clone_operations/puppet') + .with_creates('/srv/git/operations/puppet.git/config') + end + end +end -- To view, visit https://gerrit.wikimedia.org/r/383842 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4244c9507a8ef063fa0f6210c92ea3a42356c3ce Gerrit-PatchSet: 5 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Hashar <has...@free.fr> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Dzahn <dz...@wikimedia.org> Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: Ottomata <ao...@wikimedia.org> Gerrit-Reviewer: Thcipriani <tcipri...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits