Use 2-space indentation in update_version.sh.

This commit is contained in:
levlam 2023-03-06 15:46:22 +03:00
parent 6692f9c918
commit 36701d3acd

View File

@ -15,42 +15,42 @@ OLD_TDLIB_VERSION=$(echo "${GIT_DIFF}" | sed -nr "s/\-$SED_REGEX/\1/p")
NEW_TDLIB_VERSION=$(echo "${GIT_DIFF}" | sed -nr "s/\+$SED_REGEX/\1/p") NEW_TDLIB_VERSION=$(echo "${GIT_DIFF}" | sed -nr "s/\+$SED_REGEX/\1/p")
if [ ! -z "${OLD_TDLIB_VERSION}" ] && [ ! -z "${NEW_TDLIB_VERSION}" ] && if [ ! -z "${OLD_TDLIB_VERSION}" ] && [ ! -z "${NEW_TDLIB_VERSION}" ] &&
[ "${OLD_TDLIB_VERSION}" != "${NEW_TDLIB_VERSION}" ] ; then [ "${OLD_TDLIB_VERSION}" != "${NEW_TDLIB_VERSION}" ] ; then
for arg in "$@" ; do for arg in "$@" ; do
if [[ "$arg" == "-i" ]] ; then if [[ "$arg" == "-i" ]] ; then
continue continue
elif [ -e "$arg" ] ; then elif [ -e "$arg" ] ; then
if [[ "$COMMIT_FILES" == "" ]] ; then if [[ "$COMMIT_FILES" == "" ]] ; then
COMMIT_FILES="$arg" COMMIT_FILES="$arg"
else
COMMIT_FILES="$COMMIT_FILES $arg"
fi
else else
echo "$arg: No such file or directory"; exit 1 COMMIT_FILES="$COMMIT_FILES $arg"
fi fi
done else
echo "$arg: No such file or directory"; exit 1
fi
done
if [[ "$COMMIT_FILES" == "" ]] ; then if [[ "$COMMIT_FILES" == "" ]] ; then
echo "No files to update."; exit 1 echo "No files to update."; exit 1
fi fi
# Replace all matches # Replace all matches
sed --binary -i "s/${OLD_TDLIB_VERSION//./\\.}/${NEW_TDLIB_VERSION}/g" $COMMIT_FILES || exit 1 sed --binary -i "s/${OLD_TDLIB_VERSION//./\\.}/${NEW_TDLIB_VERSION}/g" $COMMIT_FILES || exit 1
git --no-pager diff CMakeLists.txt $COMMIT_FILES git --no-pager diff CMakeLists.txt $COMMIT_FILES
echo -e "\n\n" echo -e "\n\n"
read -p "Commit \"Update version to ${NEW_TDLIB_VERSION}.\" (y/n)? " answer read -p "Commit \"Update version to ${NEW_TDLIB_VERSION}.\" (y/n)? " answer
if [[ "${answer}" == "Y" ]] || [[ "${answer}" == "y" ]] ; then if [[ "${answer}" == "Y" ]] || [[ "${answer}" == "y" ]] ; then
git commit --quiet -n CMakeLists.txt $COMMIT_FILES -m "Update version to ${NEW_TDLIB_VERSION}."; echo git commit --quiet -n CMakeLists.txt $COMMIT_FILES -m "Update version to ${NEW_TDLIB_VERSION}."; echo
git --no-pager log --stat -n 1 git --no-pager log --stat -n 1
else else
# Undo sed changes # Undo sed changes
sed --binary -i "s/${NEW_TDLIB_VERSION//./\\.}/${OLD_TDLIB_VERSION}/g" $COMMIT_FILES || exit 1 sed --binary -i "s/${NEW_TDLIB_VERSION//./\\.}/${OLD_TDLIB_VERSION}/g" $COMMIT_FILES || exit 1
echo "Aborted."; exit 1 echo "Aborted."; exit 1
fi fi
else else
echo "Couldn't find new TDLib version." echo "Couldn't find new TDLib version."
fi fi