File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ function bl_hub_add_issue_comment(){
8585function bl_hub_comment_or_create_issue(){
8686 local title=" ${1} "
8787 local message=" ${2} "
88+ local label=" ${3:- } "
89+ local label_param=" "
8890 local issue_number
8991 local issue_url
9092 local action
@@ -96,10 +98,20 @@ function bl_hub_comment_or_create_issue(){
9698
9799 if [[ -z " ${issue_number} " ]]; then
98100 action=" created"
101+ if [[ -n " ${label} " ]]; then
102+ label_param=" -l ${label} "
103+ fi
104+
99105 # issue doesn't exist create it
106+
107+ # The following prevents a shellcheck warning about label_param
108+ # getting split into multiple words. That is exactly what should
109+ # happen as "-l" and "labelname" should be separate tokens for
110+ # the hub command.
111+ # shellcheck disable=SC2086
100112 issue_url=" $( hub issue create -m " ${title}
101113
102- ${message} " ) "
114+ ${message} " ${label_param} ) "
103115
104116 # Example issue url: https://github.com/{owner}/{repo}/issues/{issue number}"
105117 # To find the issue number, split on / and take the last field
Original file line number Diff line number Diff line change 164164
165165@test " bl_hub_comment_or_create_issue creates issue when it doesnt exist" {
166166 bl_hub_check (){ : ; }
167- bl_hub_ssue_number_for_title (){ : ; }
167+ bl_hub_issue_number_for_title (){ : ; }
168168 bl_github_owner_repo (){ echo " owner/repo" ; }
169169 hub (){
170170 if [[ " ${2:- } " == " create" ]]; then
195195 assert_output --partial " comment"
196196 assert_output --partial " https://github.com/owner/repo/issues/1"
197197}
198+
199+ @test " bl_hub_comment_or_create_issue passes label to hub" {
200+ bl_hub_check (){ : ; }
201+ bl_hub_issue_number_for_title (){ : ; }
202+ bl_github_owner_repo (){ echo " owner/repo" ; }
203+ hub (){
204+ [[ " ${5} " == " -l" ]] || bl_die " expected -l for specifying a label"
205+ [[ " ${6} " == " label" ]] || bl_die " expected 'label' as label name"
206+ echo " https://github.com/owner/repo/issues/1"
207+ }
208+ run bl_hub_comment_or_create_issue title message label
209+ assert_success
210+ assert_output --partial " https://github.com/owner/repo/issues/1"
211+ assert_output --partial " create"
212+ }
You can’t perform that action at this time.
0 commit comments