Skip to content

Commit

Permalink
Merge pull request #346 from qtzar/BranchSorting
Browse files Browse the repository at this point in the history
Ignore case in branch name comparator
  • Loading branch information
jp7677 committed Oct 25, 2023
2 parents 0c99ab2 + b575e78 commit 8c74654
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,5 @@ class GenerateSiteCommand : Subcommand(
fun branchComparator(defaultBranch: String) = Comparator<String> { a, b ->
if (a == defaultBranch) -1
else if (b == defaultBranch) 1
else a.compareTo(b)
else a.compareTo(b, ignoreCase = true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ import org.junit.jupiter.api.TestFactory
class BranchComparatorTest {
@TestFactory
fun `default branch first then by string`() = listOf(
listOf("a", "b", "main"),
listOf("a", "main", "b"),
listOf("b", "a", "main"),
listOf("b", "main", "a"),
listOf("main", "a", "b"),
listOf("main", "b", "a")
listOf("a", "B", "main"),
listOf("a", "main", "B"),
listOf("B", "a", "main"),
listOf("B", "main", "a"),
listOf("main", "a", "B"),
listOf("main", "B", "a"),
).map { branches ->
DynamicTest.dynamicTest(branches.toString()) {
assertThat(branches.sortedWith(branchComparator("main")))
.containsExactly("main", "a", "b")
.containsExactly("main", "a", "B")
}
}
}

0 comments on commit 8c74654

Please sign in to comment.