How to run shell script as a client side hook script for tortoiseSVN?

1.1k Views Asked by At

I have written the shell script and i am trying to put that script as a client side hook script but not getting the script engine which one i should be using to run .sh file.Usually as i have seen .js file will be used as hook script for SVN unfortunately i don't know much about jscript so please help me how to add and run the script in SVN as client side hook script.I have tried using WScipt and CScirpt but both of them are not working for my shell script.

#!/bin/bash

MAIN_DIR="/cygdrive/e/Trunk/COMMON"
FILE_NAME="/cygdrive/e/Trunk_PRE_COMMIT_HOOK/long_path.txt"



lengthy_path=`find ${MAIN_DIR} -regextype posix-extended -regex '.{500,}'| awk -F'Trunk/' '{print $2}' > ${FILE_NAME}`



if [ -f ${FILE_NAME} ]
  then
   if [ -s ${FILE_NAME} ]
    then
        echo -e "\n\n\nSorry the path of a file exceeds 256 charectors, please make it shorten and try commiting again.You can see the path in $FILE_NAME"
    else
        echo -e "\n\n\nPath is perfect code can be committed..........."
fi
    else
        echo -e "\n\n\nFile not exists............"
fi
1

There are 1 best solutions below

2
Patrick Quirk On

You're trying to execute a bash script on Windows, which means you either need Cygwin installed or can use the new bash shell functionality in Windows 10. I have little experience with either, but hopefully I can get you pointed in the right direction.

  1. If you're using Cygwin, use the following command in the Tortoise hook script configuration dialog (Fig. 4.87 in the documentation):

    C:\cygwin\bin\bash C:\path\to\your_script.sh
    

    (Sourced from this answer)

  2. If you're using the Windows 10 bash shell, use this command:

    bash -c "/mnt/c/path/to/your_script.sh"
    

    (Sourced from this page under "Run Linux Commands From Outside Bash")

Disclaimer: I haven't tested either of these because I don't have the time or means. Try it out, and leave some feedback either way.