CI Handle new branch in scikit-learn.github.io
# The behavior of the script is controlled by environment variable defined
# in the circle.yml in the top level folder of the project.
-set -e
+set -ex
if [ -z $CIRCLE_PROJECT_USERNAME ];
then USERNAME="sklearn-ci";
@@ -38,11 +38,23 @@ if [ ! -d $DOC_REPO ];
then git clone --depth 1 --no-checkout "git@github.com:scikit-learn/"$DOC_REPO".git";
fi
cd $DOC_REPO
-git config core.sparseCheckout true
+
+# check if it's a new branch
+
echo $dir > .git/info/sparse-checkout
-git checkout $CIRCLE_BRANCH
-git reset --hard origin/$CIRCLE_BRANCH
+if ! git show HEAD:$dir >/dev/null
+then
+ # directory does not exist. Need to make it so sparse checkout works
+ mkdir $dir
+ touch $dir/index.html
+ git add $dir
+fi
+git checkout master
+git reset --hard origin/master
+if [ -d $dir ]
+then
git rm -rf $dir/ && rm -rf $dir/
+fi
cp -R $GENERATED_DOC_DIR $dir
git config user.email "olivier.grisel+sklearn-ci@gmail.com"
git config user.name $USERNAME
