Skip to content

Commit

Permalink
feat: maintainer merge?/maintainer delegate? switch for spoiler (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
adomani committed Nov 20, 2024
1 parent 25b91b6 commit 0e836d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/maintainer_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ jobs:
printf 'Comment:"%s"\n' "${COMMENT}"
m_or_d="$(printf '%s' "${COMMENT}" |
sed -n 's=^maintainer *\(merge\|delegate\) *$=\1=p' | head -1)"
# captures `maintainer merge/delegate` as well as an optional `?`, ignoring subsequent spaces
sed -n 's=^maintainer *\(merge\|delegate\)\(?\?\) *$=\1\2=p' | head -1)"
printf $'"maintainer delegate" or "maintainer merge" found? \'%s\'\n' "${m_or_d}"
Expand Down
17 changes: 12 additions & 5 deletions scripts/maintainer_merge_message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ esac
>&2 echo "EVENT_NAME: '${EVENT_NAME}'"
>&2 printf 'COMMENT\n%s\nEND COMMENT\n' "${PR_COMMENT}"

# replace backticks in the title with single quotes
unbacktickedTitle="${PR_TITLE//\`/\'}"
printf '%s requested a maintainer **%s** from %s on PR [#%s](%s):\n' "${AUTHOR}" "${M_or_D/$'?'/}" "${SOURCE}" "${PR}" "${URL}"
# if `maintainer merge/delegate` is followed by `?`, then print a `spoiler` with the full comment
if [ ${M_or_D: -1} == $'?' ]
then
# replace backticks in the title with single quotes
unbacktickedTitle="${PR_TITLE//\`/\'}"

>&2 echo "neat title: '${unbacktickedTitle}'"
>&2 echo "neat title: '${unbacktickedTitle}'"

printf '%s requested a maintainer **%s** from %s on PR [#%s](%s):\n' "${AUTHOR}" "${M_or_D}" "${SOURCE}" "${PR}" "${URL}"
printf '```spoiler %s\n%s\n```\n' "${unbacktickedTitle}" "${PR_COMMENT}"
printf '```spoiler %s\n%s\n```\n' "${unbacktickedTitle}" "${PR_COMMENT}"
# otherwise, just print the title of the PR
else
printf '> %s\n' "${PR_TITLE}"
fi

0 comments on commit 0e836d6

Please sign in to comment.