Skip to content

Commit 009e32b

Browse files
authored
Merge pull request #43 from cyberark/cyberark-bash-lib-42
Return single issue number
2 parents d93d743 + ae6e24f commit 009e32b

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.0.4] - 2020-09-25
10+
### Changed
11+
- bl_hub_issue_number_for_title now returns the first matching issue number only, instead of all matching issue numbers separated by newlines.
12+
913
## [2.0.3] - 2020-03-13
1014
### Added
1115
- bl_validate_changelog: Validate a changelog against keepachangelog.com format.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ files within it's directory.
146146
<li><b>bl_hub_creds_available</b>: True if hub creds are available (file or env vars)</li>
147147
<li><b>bl_hub_check</b>: Preflight check for hub, true if git installed, in git repo, hub installed and hub creds are available</li>
148148
<li><b>bl_hub_download_latest</b>: Download latest hub binary from github and install to ~/bin or specified path</li>
149-
<li><b>bl_hub_issue_number_for_title</b>: Find the issue number for an issue from its title, searches open issues in the current repo. (current repo = workding directory, repo is found by origin remote)</li>
149+
<li><b>bl_hub_issue_number_for_title</b>: Find the issue number for an issue from its title, searches open issues in the current repo. (current repo = workding directory, repo is found by origin remote). If multiple issues match the supplied title string, only the first is returned.</li>
150150
<li><b>bl_hub_add_issue_comment</b>: Add a comment to an issue</li>
151151
<li><b>bl_hub_comment_or_create_issue</b>: Create issue if an issue matching the title doesn't exist. If a match is found, add a comment to it</li>
152152
</ol>

github/lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function bl_hub_issue_number_for_title(){
6161
bl_hub_check
6262
hub issue \
6363
|grep "${title}" \
64-
|awk -F'[ #]+' '{print $2}'
64+
|awk -F'[ #]+' '{print $2; exit}'
6565
}
6666

6767
function bl_hub_add_issue_comment(){

tests-for-this-repo/github.bats

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,24 @@ EOF
120120
assert_output "7"
121121
}
122122

123+
@test "bl_hub_issue_number_for_title returns a single issue number" {
124+
bl_hub_check(){ :; }
125+
hub(){
126+
[[ "${1}" == "issue" ]] || bl_die "issue subcommand not specified"
127+
cat <<EOF
128+
#19 Add code coverage to bash-lib kind/quality
129+
#11 Generated Documentation
130+
#12 Duplicate
131+
#13 Duplicate
132+
#7 Clean up
133+
EOF
134+
}
135+
136+
run bl_hub_issue_number_for_title "Duplicate"
137+
assert_success
138+
assert_output "12"
139+
}
140+
123141
@test "bl_hub_add_issue_comment uses the correct URL" {
124142
bl_hub_check(){ :; }
125143
hub(){

0 commit comments

Comments
 (0)