Skip to content

Instantly share code, notes, and snippets.

@M1ke
Created October 29, 2012 16:17
Show Gist options
  • Save M1ke/3974575 to your computer and use it in GitHub Desktop.
Save M1ke/3974575 to your computer and use it in GitHub Desktop.
Shell file for hooks on Windows with mysysgit installed (includes curl if in path) and powershell code for systems without curl.
$liveCommitClient = new-object System.Net.WebClient;
$liveCommitMessage = git show --format='%s' --name-only HEAD
$liveCommitClient.DownloadFile("http://dashboard.hackmanchester.com/commits?git&message="+ $liveCommitMessage + "&user=73&secret=4aYGnJ3gKotIeUztieyV&files=" , "c:\tmp\null");
echo 0
#!/bin/sh
#
# name as post-commit in a .git/hooks directory
#
# An example hook script that is called after a successful
# commit is made.
#
# To enable this hook, rename this file to "post-commit".
curl -d "output=`git show --format='git&message=%s&user=73&secret=4aYGnJ3gKotIeUztieyV&files=' --name-only HEAD`" http://dashboard.hackmanchester.com/commits
@M1ke
Copy link
Author

M1ke commented Oct 29, 2012

Crucially, placing the PowerShell code into the post-commit file doesn't seem to work. Without the line #!/bin/sh git will report "error: cannot spawn .git/hooks/post-commit: No such file or directory". So some form of top comment or shebang is needed but I can't work out which. If pasted into powershell whilst inside a git repo the above code will run and update the site.

When using the curl code it is essential that no new lines at the top or tabs are added when saving in Windows.

@seanhandley
Copy link

This is awesome @M1ke! Next step would be for me to get it saveable in the source of the dashboard itself (so it interpolates the right user id and domain etc).

@seanhandley
Copy link

Is it possible to get the Windows temp directory out of the Windows environment? That way we don't need to assume it will be on C: drive and in the tmp folder :)

@M1ke
Copy link
Author

M1ke commented Nov 6, 2012

Windows environment variable $TMP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment