Reputation: 1175
This has been asked a lot of times and I went through countless threads and Google pages, but none seem to be able to fix my issue. Perhaps I am not doing it the standard way, but it should still work.
I have a remote server that has a git repo
I push to it from local via ssh:
git add Y:\NetBeansProjects\pics\pics-client-branding\src\main\java\com\waudware\pics\viewer\TypeTopComponent.java
git commit -m Testing GIT Friday 8 Y:\NetBeansProjects\pics\pics-client-branding\src\main\java\com\waudware\pics\viewer\TypeTopComponent.java
Commit Log
revision : b2d7fd5cbafbfddfccf8d3c8ac75614c4b357887
author : Denis <[email protected]>
date : Jun 21, 2013 3:21:47 PM
summary : Testing GIT Friday 8
INFO: End of Commit
==[IDE]== Jun 21, 2013 3:21:48 PM Committing... finished.
==[IDE]== Jun 21, 2013 3:21:52 PM Pushing
git push ssh://wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git +refs/heads/master:refs/heads/master
Remote Repository Updates
Branch : master
Old Id : e51af3dbc01ee2372f9c92bb8070cb1100bef220
New Id : b2d7fd5cbafbfddfccf8d3c8ac75614c4b357887
Result : OK
Local Repository Updates
Branch : origin/master
Old Id : e51af3dbc01ee2372f9c92bb8070cb1100bef220
New Id : b2d7fd5cbafbfddfccf8d3c8ac75614c4b357887
Result : FAST_FORWARD
==[IDE]== Jun 21, 2013 3:21:56 PM Pushing finished.
Pushing works fine and the remote repository gets updated. I can easily check that using putty and running git show
. However, the post-receive hook that I wrote - doesn't run. The remote git project folder is: wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git and the hook is in wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git/hooks/post-receive
The contents of post-receive are:
#!bin/sh
touch worked.txt
SMTPSERVER=10.0.0.2
[email protected]
[email protected]
SUBJECT="Subject: GIT [commit] $(date +"%m-%d-%Y")"
LOGFILE="commit-$(date +"%m-%d-%Y").log"
DIFF=1
SHORTLOG=1
echo "$SUBJECT" > ../logs/"$LOGFILE"
echo >> ../logs/"$LOGFILE"
git log --since=yesterday >> ../logs/"$LOGFILE"
if [ "$DIFF" == "1" ]; then
git show --pretty >> ../logs/"$LOGFILE"
fi
git send-email --smtp-server "$SMTPSERVER" --to "$TO" --from "$FROM" ../logs/"$LOGFILE"
I must note that executing that file manually sends the email as expected. But never triggers as a hook. Not even the touch
. Any hints on what you think the cause of this may be is apprecaited!
P.S. ls -la
on the hooks folder:
WAUDWARE\denis@WWBert /cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/pics.git/hooks
$ ls -la
total 38
drwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 4096 2013-06-21 15:20 .
drwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 4096 2013-06-21 14:48 ..
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 452 2013-04-23 10:02 applypatch-msg.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 896 2013-04-23 10:02 commit-msg.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 160 2013-04-23 10:02 post-commit.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 514 2013-06-21 16:08 post-receive
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 552 2013-04-23 10:02 post-receive.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 189 2013-04-23 10:02 post-update.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 398 2013-04-23 10:02 pre-applypatch.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 1578 2013-04-23 10:02 pre-commit.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 4951 2013-04-23 10:02 pre-rebase.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 1239 2013-04-23 10:02 prepare-commit-msg.sample
-rwxr-x--- 1 WAUDWARE\denis WAUDWARE\12513 3611 2013-04-23 10:02 update.sample
Edit: I had progress. Instead of pushing from NetBeans IDE, I used Git GUI to see a more detailed output. Here is what happened when I pushed to remote: remote: fatal: cannot exec 'hooks/post-receive': Permission denied[K
To ssh://WAUDWARE\denis@wwbert/cygdrive/d/Shared_Data/Development/dev_NetBeans/Projects/PICS.git
ab6ddef..a5644e8 master -> master
. You can see my permissions in the post. Is there anything wrong with them? Are there some other permissions that can prevent execution of post-receive?
Upvotes: 4
Views: 5453
Reputation: 416
You are missing the leading / on the hash-bang (1st) line of your script.
Here's some other debugging tips:
Note that you can use $GIT_DIR to locate stuff relative to the repo.
Another idea is to turn on echo in the shell.
#!/bin/bash -x
Then the remote should show you exactly which line is causing you grief.
Finally, I think there's a problem with your nested quotes on the SUBJECT= line. You could use single quotes for the inner quotes. LOGFILE has the same problem.
Upvotes: 5