Skip to content

Commit

Permalink
3.0.1: Properly format change URL when patch set number is missing
Browse files Browse the repository at this point in the history
If the patch set number was missing, the text "null" was appearing in
the URL rather than "" as was intended. This change addresses that and
also drops the trailing "/" if patch set is missing (which should be
considered equivalent by Gerrit)
  • Loading branch information
Michael Sims committed Feb 2, 2018
1 parent b5edca7 commit 84c0c44
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'sims.michael.gerritslackbot'
version '2.3.1'
version '3.0.1'

buildscript {
ext.kotlin_version = '1.2.20'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ private fun formatGerritBaseUrlUsingHttpUrl(changeUrl: String): String? {
}

fun formatGerritChangeUrl(baseUrl: String, changeNumber: Int, patchSetNumber: Int?): String?
= "$baseUrl/$changeNumber/$patchSetNumber"
= listOfNotNull(baseUrl, changeNumber, patchSetNumber).joinToString("/")
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ class GerritUrlsTest {
fun formatGerritChangeUrl_works_as_expected() {
assertEquals("http://server:8976/1/2", formatGerritChangeUrl("http://server:8976", 1, 2))
}

@Test
fun formatGerritChangeUrl_handles_null_patchSetNumber_as_expected() {
assertEquals("http://server:8976/1", formatGerritChangeUrl("http://server:8976", 1, null))
}
}

0 comments on commit 84c0c44

Please sign in to comment.