Skip to content

Commit

Permalink
When multiple branches or all branches are specified, the list of bra…
Browse files Browse the repository at this point in the history
…nches will be sorted and the default branch moved to the top of the list.
  • Loading branch information
qtzar committed Oct 13, 2023
1 parent 5d302c4 commit abb4d85
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class GenerateSiteCommand : Subcommand(
refreshLocalClone()
}

val branchNames = if (allBranches)
val branchNames: List<String> = if (allBranches)
clonedRepository.getBranchNames(excludeBranches.split(","))
else
branches.split(",")
Expand All @@ -109,7 +109,12 @@ class GenerateSiteCommand : Subcommand(
throw Exception("$defaultBranch does not contain a valid structurizr workspace. Site generation halted.")
}

branchesToGenerate.forEach { branch ->
val sortedBranchNames = branchesToGenerate.toMutableList()
sortedBranchNames.sorted()
sortedBranchNames.remove(defaultBranch)
sortedBranchNames.add(0,defaultBranch)

sortedBranchNames.forEach { branch ->
println("Generating site for branch $branch")
clonedRepository.checkoutBranch(branch)

Expand All @@ -120,7 +125,7 @@ class GenerateSiteCommand : Subcommand(
workspace,
assetsDir?.let { File(cloneDir, it) },
siteDir,
branchesToGenerate,
sortedBranchNames,
branch
)
}
Expand Down

0 comments on commit abb4d85

Please sign in to comment.