Create a gist now

Instantly share code, notes, and snippets.

Embed
# !/bin/sh
set -e
target_dir="${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
mkdir -p $target_dir
last_commit_log=`git --git-dir ${SRCROOT}/.git log HEAD --oneline -n 1`
current_branch=`git --git-dir ${SRCROOT}/.git rev-parse --abbrev-ref HEAD 2> /dev/null`
last_commit_hash=`git --git-dir ${SRCROOT}/.git rev-parse HEAD`
json_file="build_info.json"
json_path="${target_dir}/${json_file}"
echo "Generate to ${json_path}"
touch $json_path
cat << EOM > ${json_path}
{
"current_branch" : "$current_branch",
"last_commit_hash" : "$last_commit_hash",
"last_commit_log" : "$last_commit_log",
"build_configuration" : "$CONFIGURATION",
"built_at" : "`date '+%Y/%m/%d %r'`"
}
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment