Skip to content

Instantly share code, notes, and snippets.

@furkanmustafa
Created July 20, 2013 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furkanmustafa/6045228 to your computer and use it in GitHub Desktop.
Save furkanmustafa/6045228 to your computer and use it in GitHub Desktop.
Shell script to be used in build phases in xCode, so it will inject git revision and stuff into bundle
#!/bin/bash
BUILD_NUMBER=`git rev-parse --short HEAD`
git update-index -q --refresh
CHANGES=$(git diff-index --name-only HEAD --)
if [ ! -z "${CHANGES}" ]; then
BUILD_NUMBER="${BUILD_NUMBER}+"
if [ "${CONFIGURATION}" == "Debug" ]; then
git diff --color | tools/ansi2html.sh --bg=dark > gitdiff.html
cp ${PROJECT_DIR}/gitdiff.html ${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}
fi
fi
/usr/libexec/PlistBuddy -c "Set :GitRevision $BUILD_NUMBER" "${TARGET_BUILD_DIR}"/"${INFOPLIST_PATH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment