win_svn_dialog 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env bash
  2. # win_tortoisesvn.sh
  3. # Usage:
  4. # ./win_tortoisesvn.sh commit /path/to/workingcopy "Your commit message"
  5. set -euo pipefail
  6. if [[ $# -ne 3 ]]; then
  7. echo "Usage: $0 commit <linux_path> <commit_message>" >&2
  8. exit 1
  9. fi
  10. CMD="$1"
  11. WC_LINUX="$2"
  12. LOGMSG="$3"
  13. if [[ "$CMD" != "commit" ]]; then
  14. echo "Error: only the 'commit' command is supported." >&2
  15. exit 1
  16. fi
  17. # Validate path
  18. if [[ ! -e "$WC_LINUX" ]]; then
  19. echo "Error: path '$WC_LINUX' does not exist." >&2
  20. exit 1
  21. fi
  22. # Resolve absolute linux path and convert to Windows
  23. if command -v readlink >/dev/null 2>&1; then
  24. WC_LINUX="$(readlink -f "$WC_LINUX")"
  25. fi
  26. if ! command -v wslpath >/dev/null 2>&1; then
  27. echo "Error: wslpath not found." >&2
  28. exit 1
  29. fi
  30. WC_WIN="$(wslpath -w "$WC_LINUX")"
  31. # Write commit message to a temporary file and convert its path
  32. LOGFILE_LINUX="$(mktemp /tmp/tsvn-commit.XXXXXX.txt)"
  33. printf "%s" "$LOGMSG" > "$LOGFILE_LINUX"
  34. LOGFILE_WIN="$(wslpath -w "$LOGFILE_LINUX")"
  35. # Paths
  36. POWERSHELL="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
  37. TSVN_EXE="C:\\Program Files\\TortoiseSVN\\bin\\TortoiseProc.exe"
  38. # Build TortoiseProc arguments:
  39. # /command:commit — open Commit dialog
  40. # /path:"<path>" — the working copy path
  41. # /logmsgfile:"<file>" — prefill commit message (safer than /logmsg for quotes/newlines)
  42. # /closeonend:0 — keep dialog; don't auto-close
  43. PS_CMD="
  44. Start-Process -FilePath '$TSVN_EXE' -ArgumentList @(
  45. '/command:commit',
  46. '/path:$WC_WIN',
  47. '/logmsgfile:$LOGFILE_WIN',
  48. '/closeonend:0'
  49. )
  50. "
  51. # Launch (non-blocking; remove Start-Process and call directly if you want to block)
  52. "$POWERSHELL" -NoProfile -Command "$PS_CMD"
  53. # Optional: keep temp file (useful if you want to reuse); otherwise uncomment to auto-clean
  54. # rm -f \"$LOGFILE_LINUX\"
  55. echo "Opened TortoiseSVN Commit dialog for: $WC_LINUX"