Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FIX: DRY update for managing documented module checkouts. (Fixes #2)

  • Loading branch information...
commit 5b2a11c23b8db7ea5bbd7ae6d98135c3a9d3403d 1 parent 146c34a
@wilr wilr authored
Showing with 62 additions and 25 deletions.
  1. +11 −18 Makefile
  2. +51 −7 bin/update.sh
View
29 Makefile
@@ -1,24 +1,17 @@
-update:
- @echo "Cleaning up existing folders..";
- @if [ -d $(CURDIR)/src/sapphire_master ]; then rm -rf $(CURDIR)/src/sapphire_master; fi
-
- @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
-
- @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
+all:
+ @echo "Available commands:"
+ @grep "^[^#[:space:]].*:$$" Makefile
- @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
+update:
+ @make fetch
+ @make index
- @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
+fetch:
+ @./bin/update.sh $(CURDIR)
- @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
View
58 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."
Please sign in to comment.
Something went wrong with that request. Please try again.