Created
July 10, 2013 16:33
-
-
Save johnhaitas/5967857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# insert_git_hash.sh | |
# ToGoOrder | |
# | |
# Created by John Haitas on 7/9/13. | |
# | |
# Location of Info.plist in build product | |
INFOPLISTPATH="${TARGET_BUILD_DIR}/${EXECUTABLE_NAME}.app/Info.plist" | |
# Location of PlistBuddy | |
PLISTBUDDY="/usr/libexec/PlistBuddy" | |
# Get the hash for the current commit | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
# Test if this commit is dirty | |
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then | |
COMMIT_HASH="${COMMIT_HASH}~dirty" | |
fi | |
# The PLIST key | |
GITHASH_PLIST_KEY="GitHash" | |
# Should test if key already exist and add it if it does not or set it if it does | |
# no point in taking the time to do it for now | |
# Add the key | |
echo "Adding key"; | |
ADD_KEY_RESULT=$(${PLISTBUDDY} -c "Add :${GITHASH_PLIST_KEY} string ${COMMIT_HASH}" "${INFOPLISTPATH}") | |
# Set the key to be sure | |
echo "Setting key"; | |
${PLISTBUDDY} -c "Set :${GITHASH_PLIST_KEY} ${COMMIT_HASH}" "${INFOPLISTPATH}"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment