Skip to content

Instantly share code, notes, and snippets.

Created December 2, 2014 10:59
What would you like to do?
git commit hook ensuring the correct branch URL is set for Travis badges found in README files. Install both as post-commit and post-merge hooks
# Repository settings
# Update a Travis badge URL found in the README to keep it in sync with the branch name
# Badge example:
# [![Build Status]($USER_NAME/$REPOSITORY_NAME/master.svg?style=flat)]($USER_NAME/$REPOSITORY_NAME)
branch_name=`git symbolic-ref --short HEAD`
sed -E -i "" "s|(^.**/$REPOSITORY_NAME/).*(\.svg.*$)|\1$branch_name\2|g" "$README_FILE_NAME"
git commit -m "Update Travis badge for branch $branch_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment