Skip to content

Commit

Permalink
echo -n fix
Browse files Browse the repository at this point in the history
  • Loading branch information
led0nk committed Apr 18, 2024
1 parent 703f599 commit bcf6037
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/scripts/add-codeowners-to-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ main () {
# is only available through the API. To cut down on API calls to GitHub,
# we use the latest reviews to determine which users to filter out.
JSON=$(gh pr view "${PR}" --json "files,author,latestReviews" | tr -dc '[:print:]' | sed -E 's/\\[a-z]//g')
AUTHOR=$(echo "${JSON}"| jq -r '.author.login')
FILES=$(echo "${JSON}"| jq -r '.files[].path')
REVIEW_LOGINS=$(echo "${JSON}"| jq -r '.latestReviews[].author.login')
AUTHOR=$(echo -n "${JSON}"| jq -r '.author.login')
FILES=$(echo -n "${JSON}"| jq -r '.files[].path')
REVIEW_LOGINS=$(echo -n "${JSON}"| jq -r '.latestReviews[].author.login')
COMPONENTS=$(bash "${CUR_DIRECTORY}/get-components.sh")
REVIEWERS=""
LABELS=""
Expand Down Expand Up @@ -59,14 +59,14 @@ main () {
# won't be checked against the remaining components in the components
# list. This provides a meaningful speedup in practice.
for FILE in ${FILES}; do
MATCH=$(echo "${FILE}" | grep -E "^${COMPONENT}" || true)
MATCH=$(echo -n "${FILE}" | grep -E "^${COMPONENT}" || true)

if [[ -z "${MATCH}" ]]; then
continue
fi

# If we match a file with a component we don't need to process the file again.
FILES=$(echo "${FILES}" | grep -v "${FILE}")
FILES=$(echo -n "${FILES}" | grep -v "${FILE}")

if [[ -v PROCESSED_COMPONENTS["${COMPONENT}"] ]]; then
continue
Expand All @@ -87,11 +87,11 @@ main () {
if [[ -n "${REVIEWERS}" ]]; then
REVIEWERS+=","
fi
REVIEWERS+=$(echo "${OWNER}" | sed -E 's/@(.+)/"\1"/')
REVIEWERS+=$(echo -n "${OWNER}" | sed -E 's/@(.+)/"\1"/')
done

# Convert the CODEOWNERS entry to a label
COMPONENT_NAME=$(echo "${COMPONENT}" | sed -E 's%^(.+)/(.+)\1%\1/\2%')
COMPONENT_NAME=$(echo -n "${COMPONENT}" | sed -E 's%^(.+)/(.+)\1%\1/\2%')

if (( "${#COMPONENT_NAME}" > 50 )); then
echo "'${COMPONENT_NAME}' exceeds GitHub's 50-character limit on labels, skipping adding label"
Expand Down

0 comments on commit bcf6037

Please sign in to comment.