diff --git a/git-hooks/README.md b/git-hooks/README.md index 18b81ef..9444272 100644 --- a/git-hooks/README.md +++ b/git-hooks/README.md @@ -3,7 +3,7 @@ git hooks for IPython add these to your `.git/hooks` For now, we just have `post-checkout` and `post-merge`, -both of which just update submodules, +both of which update submodules and attempt to rebuild css sourcemaps, so make sure that you have a fully synced repo whenever you checkout or pull. To use these hooks, run `./install-hooks.sh`. diff --git a/git-hooks/post-checkout b/git-hooks/post-checkout index 2e83484..38f3ac9 100755 --- a/git-hooks/post-checkout +++ b/git-hooks/post-checkout @@ -2,3 +2,16 @@ git submodule init git submodule update + +PREVIOUS_HEAD=$1 +# if style changed (and less/fabric available), rebuild sourcemaps +if [[ + ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/ipython.min.css)" + && ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/style.min.css)" + && ! -z $(which 2>/dev/null lessc) + && ! -z $(which 2>/dev/null fab) +]]; then + echo "rebuilding sourcemaps" + cd IPython/html + fab css +fi diff --git a/git-hooks/post-merge b/git-hooks/post-merge index 2e83484..38f3ac9 100755 --- a/git-hooks/post-merge +++ b/git-hooks/post-merge @@ -2,3 +2,16 @@ git submodule init git submodule update + +PREVIOUS_HEAD=$1 +# if style changed (and less/fabric available), rebuild sourcemaps +if [[ + ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/ipython.min.css)" + && ! -z "$(git diff $PREVIOUS_HEAD IPython/html/static/style/style.min.css)" + && ! -z $(which 2>/dev/null lessc) + && ! -z $(which 2>/dev/null fab) +]]; then + echo "rebuilding sourcemaps" + cd IPython/html + fab css +fi