【发布时间】:2021-12-07 03:52:35
【问题描述】:
在我的 shell 脚本中,我得到了提交数和发布号。 但是我想知道在归档应用程序之前是否有任何方法可以知道是否有任何提交要做,如果有任何提交要做,那么不要归档应用程序显示错误消息。 这是我的shell脚本:
git=$(sh /etc/profile; which git)
number_of_commits=$("$git" rev-list HEAD --count)
git_release_version=$("$git" describe --tags --always --abbrev=0)
target_plist="$TARGET_BUILD_DIR/$INFOPLIST_PATH"
dsym_plist="$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist"
for plist in "$target_plist" "$dsym_plist"; do
if [ -f "$plist" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $number_of_commits" "$plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString ${git_release_version#*v}" "$plist"
fi
done
【问题讨论】:
-
能否请您定义您所说的“承诺做”是什么意思?这是否意味着更改提交或提交拉/推?
-
嗨@Reda,我的意思是更改提交
-
$(sh /etc/profile; which git)包含一个无用的sh /etc/profile步骤。它运行一个 shell,它在子 shell 中读取 /etc/profile,然后丢弃读取 /etc/profile 的结果。主 shell 完全丢弃了子 shell 的结果,然后运行which git。所以git=$(which git)就足够了。但是,which git只是说明主 shell 将使用哪个 Git,即运行git将获得的 Git,因此在此处设置$git没有意义。 -
也许写这个脚本的人意味着运行
git=$(. /etc/profile; which git),这将启动一个子shell sources/etc/profile——可能改变shell的@ 987654331@–然后运行 which git并进行潜在的更改。 那将解释设置变量git。但是“修复”这个“错误”可能会破坏事情。您应该确定正确的调用是什么,或者完全删除$git的使用——只需运行git——或者在此处修复$git的设置。 -
嗨@torek 你能解释一下,你的意思是最好删除$git吗?改为添加 git。
标签: xcode git github sh script