From 0f533467f2b813cacebcb420852b2d8045709482 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 18 Aug 2013 17:52:58 +0000 Subject: subversion: Add a new pre-commit hook that will prevent commits to paths which have been converted to git --- modules/subversion/manifests/init.pp | 5 +++++ modules/subversion/manifests/repository.pp | 2 ++ modules/subversion/templates/converted_to_git | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 modules/subversion/templates/converted_to_git diff --git a/modules/subversion/manifests/init.pp b/modules/subversion/manifests/init.pp index aa8b866b..d09144c9 100644 --- a/modules/subversion/manifests/init.pp +++ b/modules/subversion/manifests/init.pp @@ -55,6 +55,11 @@ class subversion { content => template('subversion/pre-revprop-change') } + file { "$local_dir/pre-commit.d/converted_to_git": + mode => '0755', + content => template('subversion/converted_to_git') + } + # TODO : add check for # - ym perl -MYAML -e 'YAML::LoadFile("-");' # - tt ( do not seem to be possible, but this would be great ) diff --git a/modules/subversion/manifests/repository.pp b/modules/subversion/manifests/repository.pp index 60846339..92d2e43c 100644 --- a/modules/subversion/manifests/repository.pp +++ b/modules/subversion/manifests/repository.pp @@ -123,6 +123,8 @@ define subversion::repository($group = 'svn', pre_commit_link { "$name/hooks/pre-commit.d/no_root_commit": } + pre_commit_link { "$name/hooks/pre-commit.d/converted_to_git": } + if $syntax_check { $syntax_check_array = regsubst($syntax_check,'^',"$name/hooks/pre-commit.d/") pre_commit_link { $syntax_check_array: } diff --git a/modules/subversion/templates/converted_to_git b/modules/subversion/templates/converted_to_git new file mode 100644 index 00000000..8f137506 --- /dev/null +++ b/modules/subversion/templates/converted_to_git @@ -0,0 +1,16 @@ +#!/bin/sh + +REPOS="$1" +TXN="$2" + +if [ ! -f "$REPOS/conf/git.conf" ]; then + exit 0 +fi + +REGEX=$(cat "$REPOS/conf/git.conf" | grep -v "^#" | grep -v "^ *$" | xargs | sed 's/ /|/g') + +if (svnlook dirs-changed -t $TXN "$REPOS" | grep -qE "^($REGEX)"); then + echo "The subversion path you have attempted to commit to has been converted to git." >&2 + echo "Please see: https://wiki.mageia.org/en/Git_Migration" >&2 + exit 1 +fi -- cgit v1.2.1