Skip to content

Commit

Permalink
Whitespace regex, remove validation that is likely unecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
crobert-1 committed Dec 12, 2023
1 parent 4953839 commit 7b0b268
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/scripts/get-codeowners.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ get_component_type() {
}

get_codeowners() {
echo "$((grep -m 1 "^${1}/ " .github/CODEOWNERS || true) | \
echo "$((grep -m 1 "^${1}/\s" .github/CODEOWNERS || true) | \
sed 's/ */ /g' | \
cut -f3- -d ' ')"
}
Expand All @@ -24,16 +24,6 @@ if [[ -z "${COMPONENT:-}" ]]; then
exit 1
fi
COMPONENT_TYPE=$(get_component_type "${COMPONENT}")
CUR_DIRECTORY=$(dirname "$0")
VALID_COMPONENT=$(bash "${CUR_DIRECTORY}/get-components.sh" | grep -x "${COMPONENT}" || true)
VALID_COMPONENT_WITH_TYPE=$(bash "${CUR_DIRECTORY}/get-components.sh" | grep -x "${COMPONENT}${COMPONENT_TYPE}" || true)
if [[ -z "${VALID_COMPONENT:-}" ]] && [[ -z "${VALID_COMPONENT_WITH_TYPE:-}" ]]; then
echo ""
exit 0
fi
# grep exits with status code 1 if there are no matches,
# so we manually set RESULT to 0 if nothing is found.
RESULT=$(grep -c "${COMPONENT}" .github/CODEOWNERS || true)
Expand All @@ -42,6 +32,7 @@ RESULT=$(grep -c "${COMPONENT}" .github/CODEOWNERS || true)
# if so, try to narrow things down by appending the component
# or a forward slash to the label.
if [[ ${RESULT} != 1 ]]; then
COMPONENT_TYPE=$(get_component_type "${COMPONENT}")
OWNERS="$(get_codeowners "${COMPONENT}${COMPONENT_TYPE}")"
fi
Expand Down

0 comments on commit 7b0b268

Please sign in to comment.