@@ -78,12 +78,17 @@ open class GenerateQuestListTask : DefaultTask() {
7878 val questFileContent = file.readText()
7979
8080 val questions = getQuestTitleStringNames(questName, questFileContent).map { strings[it]!! }
81- val wikiOrder = getRepoQuestWikiOrder(questName, questions)
82- val title = if (wikiOrder > - 1 ) wikiQuests[wikiOrder].question else questions.last()
83-
8481 val icon = getQuestIcon(questName, questFileContent)
8582
86- return RepoQuest (questName, file, icon, title, defaultPriority, wikiOrder)
83+ val repoQuest = RepoQuest (questName, file, icon, questions, defaultPriority)
84+
85+ val wikiOrder = getRepoQuestWikiOrder(repoQuest)
86+ if (wikiOrder > - 1 ) {
87+ repoQuest.wikiOrder = wikiOrder
88+ repoQuest.title = wikiQuests[wikiOrder].question
89+ }
90+
91+ return repoQuest
8792 }
8893
8994 private fun getQuestFile (questName : String , questFiles : List <File >): File {
@@ -112,13 +117,20 @@ open class GenerateQuestListTask : DefaultTask() {
112117 return if (filteredStringResourceNames.isEmpty()) stringResourceNames else filteredStringResourceNames
113118 }
114119
115- private fun getRepoQuestWikiOrder (questName : String , questions : List < String > ): Int {
120+ private fun getRepoQuestWikiOrder (repoQuest : RepoQuest ): Int {
116121 // first choose the one with an icon description containing the quest name
117- val wikiOrder = wikiQuests.indexOfFirst { it.icon.contains(Regex (" \\ b$questName \\ b" )) }
122+ var wikiOrder = wikiQuests.indexOfFirst { it.icon.contains(Regex (" \\ b${repoQuest.name} \\ b" )) }
123+ if (wikiOrder > - 1 ) return wikiOrder
124+
125+ // then choose the one with a matching title and package name
126+ wikiOrder = wikiQuests.indexOfFirst {
127+ repoQuest.questions.contains(it.question) &&
128+ it.packageName == repoQuest.file.parentFile.name
129+ }
118130 if (wikiOrder > - 1 ) return wikiOrder
119131
120132 // if not found, choose the one with a matching title
121- return wikiQuests.indexOfFirst { questions.contains(it.question) }
133+ return wikiQuests.indexOfFirst { repoQuest. questions.contains(it.question) }
122134 }
123135
124136 private fun getQuestIcon (questName : String , questFileContent : String ): File {
@@ -201,9 +213,10 @@ private data class RepoQuest(
201213 val name : String ,
202214 val file : File ,
203215 val icon : File ,
204- val title : String ,
216+ val questions : List < String > ,
205217 val defaultPriority : Int ,
206- val wikiOrder : Int ,
218+ var title : String = questions.last(),
219+ var wikiOrder : Int = -1 ,
207220) {
208221 val packageName: String get() =
209222 if (name == noteQuestName) {
@@ -233,7 +246,7 @@ private class WikiQuest(rowCells: List<String>, rowIndex: Int) {
233246 private val notes: String
234247 private val issueNumber: String?
235248 private val prNumber: String?
236- private val packageName: String?
249+ val packageName: String?
237250
238251 init {
239252 val rowCellContents = rowCells.map {
0 commit comments