diff --git a/Makefile b/Makefile index bb113e5..a58a2c1 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,17 @@ +all: + @echo "Available commands:" + @grep "^[^#[:space:]].*:$$" Makefile + update: - @echo "Cleaning up existing folders.."; - @if [ -d $(CURDIR)/src/sapphire_master ]; then rm -rf $(CURDIR)/src/sapphire_master; fi + @make fetch + @make index - @echo "Checking out SilverStripe (Framework).."; - @if [ -d $(CURDIR)/src/framework ]; then cd $(CURDIR)/src/framework; git pull -q; else git clone --depth=100 -q git://github.com/silverstripe/sapphire.git $(CURDIR)/src/framework; fi +fetch: + @./bin/update.sh $(CURDIR) - @echo "-- master"; - @if [ -d $(CURDIR)/src/framework_master ]; then cd $(CURDIR)/src/framework_master; git pull -q; else cp -R $(CURDIR)/src/framework $(CURDIR)/src/framework_master; cd $(CURDIR)/src/framework_master; git pull -q; fi - - @echo "-- 3.0"; - @if [ -d $(CURDIR)/src/framework_3.0 ]; then cd $(CURDIR)/src/framework_3.0; git pull -q; else cp -R $(CURDIR)/src/framework $(CURDIR)/src/framework_3.0; cd $(CURDIR)/src/framework_3.0; git pull -q; fi - - @echo "-- 2.4"; - @if [ -d $(CURDIR)/src/framework_2.4 ]; then cd $(CURDIR)/src/framework_2.4; git pull -q; else cp -R $(CURDIR)/src/framework $(CURDIR)/src/framework_2.4; cd $(CURDIR)/src/framework_2.4; git pull -q; fi - - @echo "-- 2.3"; - @if [ -d $(CURDIR)/src/framework_2.3 ]; then cd $(CURDIR)/src/framework_2.3; git pull -q; else cp -R $(CURDIR)/src/framework $(CURDIR)/src/framework_2.3; cd $(CURDIR)/src/framework_2.3; git pull -q; fi - - @echo "Building index"; - @cd $(CURDIR); php framework/cli-script.php dev/tasks/RebuildLuceneDocsIndex flush=1 +index: + @mkdir -p $(CURDIR)/silverstripe-cache/ + @php framework/cli-script.php dev/tasks/RebuildLuceneDocsIndex flush=1 test: $(MAKE) QUERYSTRING="$(QUERYSTRING)&SkipTests=RestfulServiceTest" -C sapphire test diff --git a/bin/update.sh b/bin/update.sh index 5014378..59cff0e 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -1,9 +1,53 @@ -url='git@github.com:chillu/silverstripe-doc-restructuring.git' -base=`dirname $0` -if [ ! -d "$base/../src/github" ]; then - mkdir $base/../src/ - git clone $url $base/../src/github +dir=$1 + +if [ ! "$dir" ]; then + echo "Usage: $0 /base/folder/to/docs" + exit 1 fi -cd $base/../src/github/ -git pull origin +#=== FUNCTION ================================================================ +# NAME: checkout +# DESCRIPTION: Checks out a specific branch of a module into a folder. Not +# particular good for taking up space, but at the moment separate +# folders for each version we need will do. +# +# The master branch will checked out by default +# PARAMETERS: +# $1 - module path on github (e.g silverstripe/sapphire.git) +# $2 - branch name (e.g 3.0) +# $3 - module name (e.g sapphire) +# +#=============================================================================== +# Parameters: github path +function checkout { + if [ ! -d $dir/src/$3 ]; then + echo "Cloning $1 " + cd $dir/src + git clone --depth=100 -q git://github.com/$1 $3 --quiet + cd $3 + git checkout master -q + else + cd $dir/src/$3 + git pull -q + git checkout master -q + fi + + echo "Checking out $2 from $1 into $3_$2" + + if [ -d $dir/src/$3_$2 ]; then + cd $dir/src/$3_$2 + else + cp -R $dir/src/$3 $dir/src/$3_$2 + cd $dir/src/$3_$2 + fi + + git reset --hard -q + git checkout $2 -q + git pull -q +} + +checkout 'silverstripe/sapphire.git' '3.0' 'framework' +checkout 'silverstripe/sapphire.git' '2.4' 'framework' +checkout 'silverstripe/sapphire.git' '2.3' 'framework' + +echo "Done." \ No newline at end of file