Commit e8909be0 authored by Joshua Gutow's avatar Joshua Gutow

ops: Fix unbound variable in check_changed script

parent 0a86b91c
---
'@eth-optimism/ci-builder': minor
---
Fix unbound variable in check_changed script
This now uses -z to check if a variable is unbound instead of -n.
This should fix the error when the script is being ran on develop.
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
echoerr() { echo "$@" 1>&2; } echoerr() { echo "$@" 1>&2; }
# Check if this is a CircleCI PR. # Check if this is a CircleCI PR.
if [[ -n $CIRCLE_PULL_REQUEST ]]; then if [[ -z ${CIRCLE_PULL_REQUEST+x} ]]; then
# CIRCLE_PULL_REQUEST is unbound here
# Non-PR builds always require a rebuild.
echoerr "Not a PR build, requiring a total rebuild."
echo "TRUE"
else
# CIRCLE_PULL_REQUEST is bound here
PACKAGE=$1 PACKAGE=$1
# Craft the URL to the GitHub API. The access token is optional for the monorepo since it's an open-source repo. # Craft the URL to the GitHub API. The access token is optional for the monorepo since it's an open-source repo.
GITHUB_API_URL="https://api.github.com/repos/ethereum-optimism/optimism/pulls/${CIRCLE_PULL_REQUEST/https:\/\/github.com\/ethereum-optimism\/optimism\/pull\//}" GITHUB_API_URL="https://api.github.com/repos/ethereum-optimism/optimism/pulls/${CIRCLE_PULL_REQUEST/https:\/\/github.com\/ethereum-optimism\/optimism\/pull\//}"
...@@ -30,8 +36,4 @@ if [[ -n $CIRCLE_PULL_REQUEST ]]; then ...@@ -30,8 +36,4 @@ if [[ -n $CIRCLE_PULL_REQUEST ]]; then
# Compare HEAD to the PR's base ref, stripping out the change percentages that come with git diff --dirstat. # Compare HEAD to the PR's base ref, stripping out the change percentages that come with git diff --dirstat.
# Pass in the diff pattern to grep, and echo TRUE if there's a match. False otherwise. # Pass in the diff pattern to grep, and echo TRUE if there's a match. False otherwise.
(echo "$DIFF" | sed 's/^[ 0-9.]\+% //g' | grep -q -E "$PACKAGE" && echo "TRUE") || echo "FALSE" (echo "$DIFF" | sed 's/^[ 0-9.]\+% //g' | grep -q -E "$PACKAGE" && echo "TRUE") || echo "FALSE"
else
# Non-PR builds always require a rebuild.
echoerr "Not a PR build, requiring a total rebuild."
echo "TRUE"
fi fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment