diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-01-16 14:14:55 +0200 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-01-16 14:23:06 +0200 |
commit | 9ab6fd592ef24cb833462785c3c201360d750421 (patch) | |
tree | cfdd15d52f6a6d71b9f325b8c882278747986f28 /misc/hooks/pre-commit-clang-format | |
parent | 0f0b853c988f2c3ff322d8eaf97dd4f8d5de46c8 (diff) |
[Git hooks] Add AppleScript dialog script for macOS.
Diffstat (limited to 'misc/hooks/pre-commit-clang-format')
-rwxr-xr-x | misc/hooks/pre-commit-clang-format | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format index 9570d5120b..fd0213c175 100755 --- a/misc/hooks/pre-commit-clang-format +++ b/misc/hooks/pre-commit-clang-format @@ -47,6 +47,9 @@ XMSG=`which xmessage 2>/dev/null` # Path to powershell (Windows only) PWSH=`which powershell 2>/dev/null` +# Path to osascript (macOS only) +OSA=`which osascript 2>/dev/null` + ################################################################## # There should be no need to change anything below this line. @@ -89,6 +92,10 @@ if [ ! -x "$CLANG_FORMAT" ] ; then elif [ -x "$XMSG" ] ; then $XMSG -center -title "Error" "$message" exit 1 + elif [ -x "$OSA" ] ; then + asmessage="$(canonicalize_filename "$(dirname -- "$0")/asmessage.applescript")" + $OSA "$asmessage" -center -title "Error" --text "$message" + exit 1 elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -center -title "Error" --text "$message" @@ -199,6 +206,16 @@ while true; do else yn="N" fi + elif [ -x "$OSA" ] ; then + asmessage="$(canonicalize_filename "$(dirname -- "$0")/asmessage.applescript")" + choice=`$OSA "$asmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?"` + if [ "$choice" = "100" ] ; then + yn="Y" + elif [ "$choice" = "200" ] ; then + yn="S" + else + yn="N" + fi elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" @@ -211,7 +228,7 @@ while true; do yn="N" fi else - printf "Error: zenity, xmessage, or powershell executable not found.\n" + printf "Error: zenity, xmessage, osascript, or powershell executable not found.\n" exit 1 fi else |