IRC, git (git help hooks)
this script .
$GIT_DIR/.git/hooks/.
, $_origbranch, ($_destbranch).
, . , , .
#!/usr/bin/env bash
_prefix="/usr/bin"
_git="$_prefix/git"
_generate="$_prefix/jekyll"
_opts=(--no-safe --no-server --no-auto --kramdown)
_origbranch="master"
_destbranch="gh-pages"
_site="$("$_prefix/mktemp" -d /tmp/_site.XXXXXXXXX)"
_currbranch="$(/bin/grep "^*" < <("$_git" branch) | /bin/cut -d' ' -f2)"
if [[ $_currbranch == $_origbranch ]]; then
cd "$("$_git" rev-parse --show-toplevel)"
"$_generate" ${_opts[@]} . "$_site"
"$_git" checkout "$_destbranch"
builtin shopt -s dotglob
/bin/cp -rf "$_site"/* .
builtin shopt -u dotglob
"$_git" add .
"$_git" commit -a -m "updated site @ $(date +"%F %T")"
/bin/rm -rfv "$_site"
"$_git" checkout "$_origbranch"
fi
o/
, , bash Linux.
, POSIX sh.
, , mktemp GNU-coreutils, , , .
: , $_origbranch. , , . , , - .