Skip to content

Instantly share code, notes, and snippets.

@SuperY
Last active August 26, 2016 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SuperY/9875014 to your computer and use it in GitHub Desktop.
Save SuperY/9875014 to your computer and use it in GitHub Desktop.
编译把Git的提交次数作为小版本号
#Git 版本数
VERSION_NUMBER=`git rev-list head | sort | wc -l | awk '{print $1}'`
#VERSION_HASH=`git rev-list head | head -1`
echo $VERSION_NUMBER
#echo $VERSION_HASH
##加入版本号
##Add Version Num
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${VERSION_NUMBER}" "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
@wonderffee
Copy link

一般这样做是把当前的最新提交次数作为版本号的,但是反过来,如果知道了版本号,如何知道它对应哪个Git记录呢?比如有这样的一种情况,发现某个历史版本有崩溃问题,想回退到那个历史版本进行定位,只知道版本号,反向查出git记录好像是个问题

@wangyoucao577
Copy link

一般做法是git的提交次数加上 hash的前7位一起作为revision, 比如 82(exjdjsx) 这样, 通过hash就可以找到对应版本了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment