patch-apply.sh 410 B

12345678910111213141516171819
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
  4. PATCH="$DIRNAME/upgradeable.patch"
  5. error() {
  6. echo Error: "$*" >&2
  7. exit 1
  8. }
  9. if ! git diff-files --quiet ":!$PATCH" || ! git diff-index --quiet HEAD ":!$PATCH"; then
  10. error "Repository must have no staged or unstaged changes"
  11. fi
  12. if ! git apply -3 "$PATCH"; then
  13. error "Fix conflicts and run $DIRNAME/patch-save.sh"
  14. fi