Home > OS >  Before Archiving check If there is any commit to do?
Before Archiving check If there is any commit to do?

Time:10-21

In my shell script I get the number of commit and release number. But I would like to know if there is any way before archiving the app to know if there is any commit to do, if there is any commit to do, then don't archive the app show error message. Here my shell script:

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

CodePudding user response:

I think the condition you are looking for is :

git diff --name-status | wc -l

It should give you the number of files changed since the last commit.

  • Related