Merge "allow override to run git gc instead of repack on repos"

This commit is contained in:
Jenkins 2016-07-21 23:16:15 +00:00 committed by Gerrit Code Review
commit e957bd3f2e
1 changed files with 17 additions and 3 deletions

View File

@ -3,25 +3,39 @@
class gerrit::cron (
$replicate_local = true,
$replicate_path = '/opt/lib/git',
# run `git repack` on gerrit repos by default, set true run `git gc` instead
$gitgc_repos = false,
) {
if $gitgc_repos {
$git_cmd = 'gc'
} else {
$git_cmd = 'repack -afd'
}
cron { 'gerrit_repack':
ensure => absent,
}
cron { 'optimize_git_repo':
user => 'gerrit2',
weekday => '0',
hour => '4',
minute => '7',
command => 'find /home/gerrit2/review_site/git/ -type d -name "*.git" -print -exec git --git-dir="{}" repack -afd \;',
command => "find /home/gerrit2/review_site/git/ -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" ${git_cmd} \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
}
# if local replication is enabled, repack this mirror as well
# if local replication is enabled, optimize this mirror as well
if $replicate_local {
cron { 'mirror_repack_local':
ensure => absent,
}
cron { 'optimize_git_repo_local_replication':
user => 'gerrit2',
weekday => '0',
hour => '4',
minute => '17',
command => "find ${replicate_path} -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" repack -afd \\;",
command => "find ${replicate_path} -type d -name \"*.git\" -print -exec git --git-dir=\"{}\" ${git_cmd} \\;",
environment => 'PATH=/usr/bin:/bin:/usr/sbin:/sbin',
}
}