Simple script to capture the last commit SHHA into plist
.
This script gets ignored if the code is not under git
- Select Target > Build Phases
+
>New Run Script Phase
- copy and paste this script in the script area.
GIT=$(which git) | |
GITOPTIONS="--pretty=oneline --abbrev-commit" | |
CUT=$(which cut) | |
SHA=`$GIT log -1 $GITOPTIONS | \$CUT -c1-7` | |
LOG=`$GIT log -1` | |
BRANCH=`$GIT rev-parse --abbrev-ref HEAD` | |
/usr/libexec/PlistBuddy -c "Set :GITCommitBranch $BRANCH" "${INFOPLIST_FILE}" | |
/usr/libexec/PlistBuddy -c "Set :GITCommitSHA $SHA" "${INFOPLIST_FILE}" | |
/usr/libexec/PlistBuddy -c "Set :GITCommitLog $LOG" "${INFOPLIST_FILE}" |