0

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?

2

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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