transpile-onto.sh 665 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. if [ $# -lt 1 ]; then
  4. echo "usage: bash $0 <target> [base]" >&2
  5. exit 1
  6. fi
  7. set -x
  8. target="$1"
  9. base="${2-}"
  10. bash scripts/upgradeable/transpile.sh
  11. commit="$(git rev-parse --short HEAD)"
  12. branch="$(git rev-parse --abbrev-ref HEAD)"
  13. git add contracts
  14. git checkout --quiet --detach
  15. if git rev-parse -q --verify "$target"; then
  16. git reset --soft "$target"
  17. git checkout "$target"
  18. else
  19. git checkout --orphan "$target"
  20. if [ -n "$base" ] && git rev-parse -q --verify "$base"; then
  21. git reset --soft "$base"
  22. fi
  23. fi
  24. if ! git diff --quiet --cached; then
  25. git commit -m "Transpile $commit"
  26. fi
  27. git checkout "$branch"