#!/bin/sh . $HOME/.shenv set -e sign () { if ! git is-clean; then echo >&2 "$0: cannot -S --amend commit: dotfiles working tree not clean" exit 1 fi branch=$(git rev-parse --abbrev-ref HEAD) [ "$branch" = "master" ] || git checkout master git commit -S --amend --no-edit if [ "$branch" != "master" ]; then git checkout "$branch" git rebase master fi } cd $HOME/src/dotfiles hostname="$(hostname)" # use '-s' ? if git rev-parse refs/heads/$hostname >/dev/null 2>&1; then git checkout $hostname git rebase master if ! git push origin master +$hostname; then sign git push origin master +$hostname fi else if ! git push origin master; then sign git push origin master fi fi