Skip to content

Instantly share code, notes, and snippets.

@edavis10
Created February 2, 2011 04:45
Show Gist options
  • Save edavis10/9278e19f8e28b05a831b to your computer and use it in GitHub Desktop.
Save edavis10/9278e19f8e28b05a831b to your computer and use it in GitHub Desktop.
def local_git_mirror
package(:curl, :ensure => :installed)
file("/srv/git_mirrors",
:ensure => :directory,
:owner => configuration[:user],
:group => configuration[:user])
target_path = '/srv/git_mirrors/chiliproject_mirror.git'
exec('git-mirror-chiliproject',
:command => "git clone --bare --mirror git://github.com/edavis10/test.git #{target_path}",
:creates => target_path,
:cwd => rails_root,
:user => configuration[:user])
project_id = 'chiliproject'
scm_key = 'random'
update_repo_view_hook = "#!/bin/bash\n
curl -s -o /dev/null 'https://www.chiliproject.org/sys/fetch_changesets?key=#{scm_key}&id=#{project_id}'"
file("#{target_path}/hooks/post-receive",
:content => update_repo_view_hook,
:ensure => :present,
:mode => '0755',
:owner => configuration[:user],
:group => configuration[:user])
cron('update_app_mirror',
:command => "cd #{target_path} && git fetch --quiet origin && hooks/post-receive",
:user => configuration[:user],
:minute => '*/15')
end
recipe :local_git_mirror
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment