diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-03 15:08:15 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-03 15:08:15 -0300 |
commit | c7d3048eadf49882c159d03294d2dec2ee843bfe (patch) | |
tree | 3944670353dc1b4220ddfe11375cc849de24cb08 | |
parent | 7087278751fb051f8a5e5eef40fab20163b8b9d5 (diff) | |
download | puppet-bootstrap-c7d3048eadf49882c159d03294d2dec2ee843bfe.tar.gz puppet-bootstrap-c7d3048eadf49882c159d03294d2dec2ee843bfe.tar.bz2 |
Adding subtrees script and updating submodules script
-rwxr-xr-x | bin/submodules | 3 | ||||
-rwxr-xr-x | bin/subtrees | 41 |
2 files changed, 44 insertions, 0 deletions
diff --git a/bin/submodules b/bin/submodules index f004f2b..f79b635 100755 --- a/bin/submodules +++ b/bin/submodules @@ -21,6 +21,9 @@ for repo in $repos; do if [ ! -d "modules/$module" ]; then echo "Processing puppet module $module..." git submodule add $repo modules/$module + elif [ -e "modules/$module/.git" ]; then + # The puppet module exists and is a git submodule, so update it + ( cd module/$module && git pull origin master ) fi done diff --git a/bin/subtrees b/bin/subtrees new file mode 100755 index 0000000..1858a48 --- /dev/null +++ b/bin/subtrees @@ -0,0 +1,41 @@ +#!/bin/bash +# +# Setup subtrees. +# + +# Parameters +DIRNAME="`dirname $0`" + +# Usage +function usage { + echo "Usage: $1 add-submodules <DIR>" + exit $2 +} + +# Check for git-subtree +if ! which git-subtree &> /dev/null; then + echo "fatal: please install git-subtree" + exit 1 +fi + +# Get module list +repos="`grep = $DIRNAME/../.mrconfig | cut -d = -f 2 | cut -d ' ' -f 4`" + +# Add subtrees +for repo in $repos; do + module="`basename $repo .git | sed -e s/^puppet-//`" + if [ ! -d "modules/$module" ]; then + echo "Processing puppet module $module..." + git remote add $module $repo + git subtree add --prefix modules/$module $module master --squash + elif [ ! -d "modules/$module/.git" ]; then + # The puppet module exists and is a subtree, so update it + if ! git remote | grep -qe "^$module$"; then + git remote add $module $repo + fi + + # Update subtrees + git fetch $module master + git subtree pull --prefix modules/$module $module master --squash + fi +done |