merge-translation-pairing-driver.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/sh
  2. if [ "$#" -ne 4 ]; then
  3. echo 'merge-translation-pairing: expected <ancestor> <current> <other> <repository-path>' >&2
  4. exit 129
  5. fi
  6. ancestor_path=$1
  7. current_path=$2
  8. other_path=$3
  9. meta_path=$4
  10. driver_directory=$(CDPATH= cd -P "$(dirname "$0")" && pwd) || exit 129
  11. driver_path=$driver_directory/merge-translation-pairing.ts
  12. if command -v node >/dev/null 2>&1 \
  13. && node --import tsx/esm "$driver_path" --probe >/dev/null 2>&1; then
  14. exec node --import tsx/esm "$driver_path" \
  15. "$ancestor_path" "$current_path" "$other_path" "$meta_path"
  16. fi
  17. echo "merge-translation-pairing: runtime is unavailable; leaving an ordinary text conflict in $meta_path" >&2
  18. git merge-file \
  19. -L "$meta_path:current" \
  20. -L "$meta_path:ancestor" \
  21. -L "$meta_path:other" \
  22. -- "$current_path" "$ancestor_path" "$other_path"
  23. fallback_status=$?
  24. echo 'merge-translation-pairing: restore Node dependencies, then rerun the merge or `pnpm run resolve-translation-pairing-conflicts`; use `git merge --abort` to cancel' >&2
  25. # A clean text merge is still unverified pairing metadata, so the driver must
  26. # leave Git's index stages unresolved until the repository-aware resolver runs.
  27. if [ "$fallback_status" -gt 127 ]; then
  28. exit "$fallback_status"
  29. fi
  30. exit 1