[gitlab] Automatically fill in title if there's only 1 commit

GitOrigin-RevId: d87ea6cfe5c0fdf04c0ceb8e6ce05e87acd38f8b
This commit is contained in:
Chris Lemaire
2024-08-30 14:08:58 +02:00
committed by intellij-monorepo-bot
parent 49c202d03d
commit e768016c4e

View File

@@ -176,6 +176,20 @@ internal class GitLabMergeRequestCreateViewModelImpl(
_branchState.value = BranchState(baseRepo, baseBranch, baseRepo, currentBranch)
}
cs.launch {
combine(commits, branchState) { commitsResult, branchState ->
val commits = commitsResult?.getOrNull()
if (commits != null && commits.size == 1 && title.value.isEmpty()) {
updateTitle(commits.first().subject.lines().firstOrNull() ?: return@combine)
} else if (title.value.isEmpty()) {
updateTitle(when (val branch = branchState?.headBranch ?: return@combine) {
is GitRemoteBranch -> branch.nameForRemoteOperations
else -> branch.name
})
}
}
}
}
override fun updateTitle(text: String) {