Skip to content

Instantly share code, notes, and snippets.

@mybuddymichael
Created June 27, 2013 22:42
Show Gist options
  • Save mybuddymichael/5881064 to your computer and use it in GitHub Desktop.
Save mybuddymichael/5881064 to your computer and use it in GitHub Desktop.
Send a POST to a server with commit information.
#!/usr/bin/env bash
# Sends a POST request to a listening server with commit info.
set -e
user_name=$(git log -1 --pretty=%cn)
repo=$(basename "$(git rev-parse --show-toplevel)")
branch=$(git symbolic-ref HEAD 2> /dev/null | sed 's/refs\/heads\///g')
commit_message=$(git log -1 --pretty=%s)
sha=$(git log -1 --pretty=%h)
# Exit if rebasing.
if [ -z $branch ]; then
exit 0
fi
(curl -sS \
--data-urlencode user-name="$user_name" \
--data-urlencode repo="$repo" \
--data-urlencode branch="$branch" \
--data-urlencode commit-message="$commit_message" \
--data-urlencode sha="$sha" \
http://localhost:8080 &) \
> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment