aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/git/files/update_git_svn.sh13
-rw-r--r--modules/git/manifests/init.pp15
2 files changed, 24 insertions, 4 deletions
diff --git a/modules/git/files/update_git_svn.sh b/modules/git/files/update_git_svn.sh
new file mode 100644
index 00000000..b3802f81
--- /dev/null
+++ b/modules/git/files/update_git_svn.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+GIT_REP="$1"
+LOCKFILE="$GIT_REP/.git/update.cron.lock"
+
+cd "$GIT_REP"
+[ -f $LOCKFILE ] && exit 0
+trap "rm -f '$LOCKFILE'" EXIT
+
+touch "$LOCKFILE"
+
+/usr/bin/git svn fetch
+/usr/bin/git svn rebase
+exit 0
diff --git a/modules/git/manifests/init.pp b/modules/git/manifests/init.pp
index e32a9642..c4847c3b 100644
--- a/modules/git/manifests/init.pp
+++ b/modules/git/manifests/init.pp
@@ -84,14 +84,21 @@ class git {
alias => "git svn $name",
creates => $name,
}
- # TODO what if there is 2 concurents jobs ?
- # should we add a lock ( ie, a script + lock file for first sync )
+
+ file { "/usr/local/bin/update_git_svn.sh":
+ ensure => present,
+ owner => root,
+ group => root,
+ mode => 755,
+ source => 'puppet:///modules/git/update_git_svn.sh',
+ }
+
cron { "update $name":
# done in 2 times, so fetch can fill the repo after init
- command => "cd $name && /usr/bin/git svn fetch && /usr/bin/git svn rebase" ,
+ command => "/usr/local/bin/update_git_svn.sh $name" ,
minute => $refresh
}
- # TODO find a way to prevent commit
+
file { "$name/.git/hooks/pre-receive":
ensure => present,
owner => root,