Skip to content

Commit

Permalink
Add support for emojis in labels (#17)
Browse files Browse the repository at this point in the history
* Improve readme

* Add support for emojis in labels
  • Loading branch information
rgomezcasas authored May 5, 2020
1 parent 18be839 commit 417e60a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
m_max_size: '500'
l_max_size: '1000'
fail_if_xl: 'false'
message_if_xl: 'This PR is sooooo big! Please, split it 😊'
message_if_xl: 'This PR is so big! Please, split it 😊'
```
> If you want, you can customize all `*_max_size` with the size that fits in your project.
Expand Down
18 changes: 11 additions & 7 deletions src/github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ github::add_label_to_pr() {

local -r body=$(curl -sSL -H "Authorization: token $GITHUB_TOKEN" -H "$GITHUB_API_HEADER" "$GITHUB_API_URI/repos/$GITHUB_REPOSITORY/pulls/$1")
local labels=$(echo "$body" | jq .labels | jq -r ".[] | .name" | grep -v "size/")
labels+=("$label_to_add")

local -r comma_separated_labels=$(github::format_labels "${labels[@]/#/}")
labels=$(printf "%s\n%s" "$labels" "$label_to_add")
local -r comma_separated_labels=$(github::format_labels "$labels")

log::message "Final labels: $comma_separated_labels"

Expand All @@ -34,11 +33,16 @@ github::add_label_to_pr() {
}

github::format_labels() {
SAVEIFS=$IFS
IFS=$'\n'
local -r labels=($@)
IFS=$SAVEIFS
quoted_labels=()
for label in "${@}"; do
if [ -n "$label" ]; then
quoted_labels+=("$(str::quote "$label")")
fi

for ((i = 0; i < ${#labels[@]}; i++)); do
# echo "Label $i: ${labels[$i]}"
label="${labels[$i]}"
quoted_labels+=("$(str::quote "$label")")
done

coll::join_by "," "${quoted_labels[@]/#/}"
Expand Down

0 comments on commit 417e60a

Please sign in to comment.