#!/bin/sh set -e die() { echo "error: $*" >&2 exit 1 } run() { echo "+ $*" >&2 "$@" } set -- while read -r file; do # skip empty patches (cover letter) if grep -q "^diff --git " "$file"; then set -- "$@" "$file" fi done if [ $# -eq 0 ]; then exit 0 fi echo 'Cloning upstream repo in temp dir ...' tmp=$(mktemp -d) trap "rm -rf -- $tmp" EXIT run git clone -q --depth=1 "https://git.sr.ht/~rjarry/aerc" "$tmp" || die "Failed to clone upstream repository. No network connection?" export GIT_DIR="$tmp/.git" run cd $tmp run git am -3 "$@" || die "Failed to apply patch on upstream master branch. git pull --rebase?" for target in all lint tests check-patches; do run make $target || die "Please fix the above issues and amend your patch(es)." done