Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a git (gitosis) repo where every developer have a main branch. I have a script in post-update hook that rebuild main web site and test websites for every developer on every PUSH.

I want to rebuild only site corresponding to the committed branch, but don't know how to determine committed branch name. Could anyone help?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Each argument to the post-update is the name of a ref which was updated by the push, and a branch is a ref whose name looks like refs/heads/<branch> so a script to do what you want would look something like this:

#!/bin/sh

for ref in "$@"
do
  case "$ref" in
    refs/heads/*) /path/to/rebuild-site `basename $ref`;;
  esac
done
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.