0

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
K.John
  • 13
  • 6
  • 1
    [Client-side hook scripts are only possible when using TortoiseSVN](http://stackoverflow.com/a/8490859/1698557), or when [wrapping/aliasing the `svn` command itself](http://www.pal-blog.de/entwicklung/perl/better-source-svn-client-side-precommit-hooks.html). – Patrick Quirk Nov 15 '16 at 14:21
  • @PatrickQuirk Yes forgot to mention that i am using Tortoise SVN only, Could you please let me know which script engine needs to be used to run .sh script when developer tried to commit the code to the repo.! – K.John Nov 16 '16 at 06:40
  • Post your script. The file extension is for the most part meaningless. – Patrick Quirk Nov 16 '16 at 14:25
  • @PatrickQuirk I have added the code could you please advise how shall i make this to run as hook script in SVN? I will be very much thankful if you could provide me the answer. – K.John Nov 17 '16 at 07:36

1 Answers1

1

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.

Community
  • 1
  • 1
Patrick Quirk
  • 23,334
  • 2
  • 57
  • 88
  • Actually i had already tried the way you above suggested like; C:\cygwin\bin\bash C:\path\to\my_script.sh But unfortunately its returning the below error "FIND: Invalid switch" if it gets resolved i think script will go thru..I have checked that inside the cygwin fInd.exe is also present.. – K.John Nov 18 '16 at 09:30
  • Your script is calling the Windows `find` command instead of cygwin's. Replace `find` with `/bin/find` or `/usr/bin/find`, whichever exists. – Patrick Quirk Nov 18 '16 at 13:40