diff -r ea6181255423 -r 671c1c8fbf1c src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt --- a/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sat Jul 22 15:07:23 2023 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/servlet/ProjectServlet.kt Sat Jul 22 22:32:04 2023 +0200 @@ -46,6 +46,7 @@ get("/%project/edit", this::projectForm) get("/-/create", this::projectForm) post("/-/commit", this::projectCommit) + post("/%project/vcs/analyze", this::vcsAnalyze) get("/%project/versions/", this::versions) get("/%project/versions/%version/edit", this::versionForm) @@ -243,6 +244,7 @@ description = http.param("description") ?: "" ordinal = http.param("ordinal")?.toIntOrNull() ?: 0 repoUrl = http.param("repoUrl") ?: "" + vcs = VcsType.valueOf(http.param("vcs") ?: "None") owner = (http.param("owner")?.toIntOrNull() ?: -1).let { if (it < 0) null else dao.findUser(it) } @@ -261,6 +263,26 @@ http.renderCommit("projects/${project.node}") } + private fun vcsAnalyze(http: HttpRequest, dao: DataAccessObject) { + val projectInfo = obtainProjectInfo(http, dao) + if (projectInfo == null) { + http.response.sendError(404) + return + } + + // if analysis is not configured, reject the request + if (projectInfo.project.vcs == VcsType.None) { + http.response.sendError(404) + return + } + + // obtain the list of issues for this project to filter cross-project references + val knownIds = dao.listIssues(projectInfo.project, true).map { it.id } + + // read the provided commit log and merge only the refs that relate issues from the current project + dao.mergeCommitRefs(parseCommitRefs(http.body).filter { knownIds.contains(it.issueId) }) + } + private fun versions(http: HttpRequest, dao: DataAccessObject) { val projectInfo = obtainProjectInfo(http, dao) if (projectInfo == null) { @@ -475,7 +497,8 @@ component, dao.listIssues(project, true), dao.listIssueRelations(issue), - relationError + relationError, + dao.listCommitRefs(issue) ) feedPath = feedPath(projectInfo.project) navigationMenu = activeProjectNavMenu(