Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

homebrew_formula_pullrequest.bash: sanitize ~ #1007

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions jenkins-scripts/lib/homebrew_formula_pullrequest.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ if [ -z "${SOURCE_TARBALL_SHA}" ]; then
fi
echo '# END SECTION'

# brew does not support ~ in VERSION string, so convert it to -
VERSION_SANITIZED=$(echo "${VERSION}" | tr '~' '-')
echo Sanitizing version string ${VERSION} to ${VERSION_SANITIZED}

[email protected]:osrfbuild/homebrew-simulation.git

. ${SCRIPT_LIBDIR}/_homebrew_github_setup.bash
Expand All @@ -48,7 +52,7 @@ echo
VERSION_LINE=$(awk \
"/^ version ['\"]/ {print FNR}" ${FORMULA_PATH} | head -1)
# check if version can be correctly auto-detected from url
if ${BREW} ruby -e "exit Version.parse(\"${SOURCE_TARBALL_URI}\").to_s == \"${VERSION}\""
if ${BREW} ruby -e "exit Version.parse(\"${SOURCE_TARBALL_URI}\").to_s == \"${VERSION_SANITIZED}\""
then
echo Version can be correctly auto-detected from URL
if [ -n "${VERSION_LINE}" ]; then
Expand All @@ -59,12 +63,12 @@ else
if [ -z "${VERSION_LINE}" ]; then
# Need to insert explicit version tag after url
echo Adding explicit version tag after URL
sed -i -e "${URI_LINE}a\ version \"${VERSION}\"" ${FORMULA_PATH}
sed -i -e "${URI_LINE}a\ version \"${VERSION_SANITIZED}\"" ${FORMULA_PATH}
else
echo Changing version to
echo ${VERSION}
echo ${VERSION_SANITIZED}
echo on line number ${VERSION_LINE}
sed -i -e "${VERSION_LINE}c\ version \"${VERSION}\"" ${FORMULA_PATH}
sed -i -e "${VERSION_LINE}c\ version \"${VERSION_SANITIZED}\"" ${FORMULA_PATH}
fi
fi

Expand Down Expand Up @@ -104,6 +108,6 @@ if [ "$FORMULA_REVISION" -gt 0 ]; then
fi

# create branch with name and sanitized version string
PULL_REQUEST_BRANCH="${PACKAGE_ALIAS}_`echo ${VERSION} | tr ' ~:^?*[' '_'`"
PULL_REQUEST_BRANCH="${PACKAGE_ALIAS}_`echo ${VERSION_SANITIZED} | tr ' ~:^?*[' '_'`"

. ${SCRIPT_LIBDIR}/_homebrew_github_commit.bash