summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--everest-sync/bin/everest-sync52
1 files changed, 48 insertions, 4 deletions
diff --git a/everest-sync/bin/everest-sync b/everest-sync/bin/everest-sync
index b798571..798f781 100644
--- a/everest-sync/bin/everest-sync
+++ b/everest-sync/bin/everest-sync
@@ -108,10 +108,28 @@ Main {
FileUtils.mkdir_p(bare_repo_parent_dir)
verbose("Cloning #{d} to #{dest}")
- Git.clone(d,
- bare_repo_name,
- :path => bare_repo_parent_dir,
- :bare => true)
+
+ # Handle the special puppet module case
+ if repo_base_path =~ %r-^/?puppet-
+ puppetmaster_dir = "/etc/puppet/modules/main/#{bare_repo_name}"
+ Git.clone(d, puppetmaster_dir)
+ # HACK: I couldn't get the git gem to clone the working dir for the
+ # puppetmaster and the bare repo for gitweb. This is a workaround.
+ FileUtils.mv(File.join(puppetmaster_dir, ".git"), dest)
+
+ # Lay down hook to update the puppetmaster
+ hook_file = File.join(dest, "hooks/post-receive")
+ File.open(hook_file, "w") do |f|
+ verbose("Laying down #{hook_file}")
+ f.puts(puppet_post_receive_hook)
+ end
+ File.chmod(0744, hook_file)
+ else
+ Git.clone(d,
+ bare_repo_name,
+ :path => bare_repo_parent_dir,
+ :bare => true)
+ end
end
end
end
@@ -246,4 +264,30 @@ Main {
end
end
end
+
+ # I _really_ don't like putting this in this tool. I couldn't figure out a
+ # way to lay it down with puppet.
+ def puppet_post_receive_hook
+ <<-HOOK
+#!/bin/sh
+
+update_working_dir() {
+ GIT_DIR=`pwd`
+ GIT_WORK_TREE="/etc/puppet/modules/main/`/bin/basename $GIT_DIR`"
+
+ pushd $GIT_WORK_TREE
+ git --git-dir=$GIT_DIR reset --hard $1
+ echo "$GIT_WORK_TREE updated."
+ popd
+}
+
+while read oldrev newrev ref; do
+ # We only care when master gets updated
+ if [[ $ref == 'refs/heads/master' ]]
+ then
+ update_working_dir $newrev
+ fi
+done
+ HOOK
+ end
}