Skip to content

Commit adc6a47

Browse files
xgopilotphantom5099
andcommitted
fix(scripts): trim whitespace in issue labels
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: phantom5099 <245659304+phantom5099@users.noreply.github.com>
1 parent d337823 commit adc6a47

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

scripts/create_issue.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ title_prefix() {
4343
esac
4444
}
4545

46+
# trim_label 用于去除标签参数的首尾空白字符,避免传递无效标签值。
47+
trim_label() {
48+
printf '%s' "$1" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
49+
}
50+
4651
create_body_file() {
4752
type="$1"
4853
out="$2"
@@ -221,7 +226,10 @@ if [ -n "$LABELS" ]; then
221226
OLD_IFS=$IFS
222227
IFS=','
223228
for label in $LABELS; do
224-
set -- "$@" --label "$label"
229+
trimmed_label="$(trim_label "$label")"
230+
if [ -n "$trimmed_label" ]; then
231+
set -- "$@" --label "$trimmed_label"
232+
fi
225233
done
226234
IFS=$OLD_IFS
227235
fi

0 commit comments

Comments
 (0)