From f6d5486d5f6fb62f3064bd60491b4bbf38e5e8e7 Mon Sep 17 00:00:00 2001 From: Roman Ivanov Date: Mon, 20 May 2024 11:31:22 +0300 Subject: [PATCH] Support retrievement of changed files for commits. (#38) --- .../vcsfacade/client/VcsFacadeClient.kt | 15 ++ .../client/impl/ClassicVcsFacadeClient.kt | 7 + .../vcsfacade/client/common/dto/Commit.kt | 2 +- .../client/common/dto/CommitWithFiles.kt | 8 + .../vcsfacade/client/common/dto/FileChange.kt | 3 + .../client/common/dto/FileChangeType.kt | 5 + .../VcsFacadeFunctionalTestBitbucket.kt | 2 +- .../vcsfacade/VcsFacadeFunctionalTestGitea.kt | 2 +- .../VcsFacadeFunctionalTestGitlab.kt | 2 +- gradle.properties | 2 +- .../controller/RepositoryController.kt | 44 +++++- .../vcsfacade/document/CommitDocument.kt | 3 +- .../vcsfacade/document/FileChangeDocument.kt | 11 ++ .../octopus/vcsfacade/dto/HashOrRefOrDate.kt | 20 +++ .../vcsfacade/service/OpenSearchService.kt | 30 +++- .../octopus/vcsfacade/service/VcsManager.kt | 4 + .../octopus/vcsfacade/service/VcsService.kt | 8 +- .../service/impl/BitbucketService.kt | 98 ++++++++++--- .../service/impl/GiteaIndexerServiceImpl.kt | 5 +- .../vcsfacade/service/impl/GiteaService.kt | 138 ++++++++++-------- .../vcsfacade/service/impl/GitlabService.kt | 72 ++++++--- .../service/impl/OpenSearchServiceImpl.kt | 9 +- .../vcsfacade/service/impl/VcsManagerImpl.kt | 62 +++++--- .../vcs/VcsFacadeUnitTestBitbucket.kt | 2 +- .../vcsfacade/vcs/VcsFacadeUnitTestGitea.kt | 2 +- .../vcsfacade/vcs/VcsFacadeUnitTestGitlab.kt | 2 +- 26 files changed, 414 insertions(+), 144 deletions(-) create mode 100644 common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/CommitWithFiles.kt create mode 100644 common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChange.kt create mode 100644 common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChangeType.kt create mode 100644 server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/FileChangeDocument.kt create mode 100644 server/src/main/kotlin/org/octopusden/octopus/vcsfacade/dto/HashOrRefOrDate.kt diff --git a/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/VcsFacadeClient.kt b/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/VcsFacadeClient.kt index bbc9806..a2af612 100644 --- a/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/VcsFacadeClient.kt +++ b/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/VcsFacadeClient.kt @@ -6,6 +6,7 @@ import feign.RequestLine import java.util.Date import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.SearchIssueInRangesResponse @@ -22,9 +23,20 @@ interface VcsFacadeClient { @Param("toHashOrRef") toHashOrRef: String ): List + @RequestLine("GET rest/api/2/repository/commits/files?sshUrl={sshUrl}&fromHashOrRef={fromHashOrRef}&fromDate={fromDate}&toHashOrRef={toHashOrRef}") + fun getCommitsWithFiles( + @Param("sshUrl") sshUrl: String, + @Param("fromHashOrRef") fromHashOrRef: String?, + @Param("fromDate", expander = DateToISOExpander::class) fromDate: Date?, + @Param("toHashOrRef") toHashOrRef: String + ): List + @RequestLine("GET rest/api/2/repository/commit?sshUrl={sshUrl}&hashOrRef={hashOrRef}") fun getCommit(@Param("sshUrl") sshUrl: String, @Param("hashOrRef") hashOrRef: String): Commit + @RequestLine("GET rest/api/2/repository/commit/files?sshUrl={sshUrl}&hashOrRef={hashOrRef}") + fun getCommitWithFiles(@Param("sshUrl") sshUrl: String, @Param("hashOrRef") hashOrRef: String): CommitWithFiles + @RequestLine("GET rest/api/2/repository/issues?sshUrl={sshUrl}&fromHashOrRef={fromHashOrRef}&fromDate={fromDate}&toHashOrRef={toHashOrRef}") fun getIssuesFromCommits( @Param("sshUrl") sshUrl: String, @@ -53,6 +65,9 @@ interface VcsFacadeClient { @RequestLine("GET rest/api/2/repository/find/{issueKey}/commits") fun findCommitsByIssueKey(@Param("issueKey") issueKey: String): List + @RequestLine("GET rest/api/2/repository/find/{issueKey}/commits/files") + fun findCommitsWithFilesByIssueKey(@Param("issueKey") issueKey: String): List + @RequestLine("GET rest/api/2/repository/find/{issueKey}/pull-requests") fun findPullRequestsByIssueKey(@Param("issueKey") issueKey: String): List } diff --git a/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/impl/ClassicVcsFacadeClient.kt b/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/impl/ClassicVcsFacadeClient.kt index 1efde01..5c0735f 100644 --- a/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/impl/ClassicVcsFacadeClient.kt +++ b/client/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/impl/ClassicVcsFacadeClient.kt @@ -32,8 +32,13 @@ class ClassicVcsFacadeClient( override fun getCommits(sshUrl: String, fromHashOrRef: String?, fromDate: Date?, toHashOrRef: String) = client.getCommits(sshUrl, fromHashOrRef, fromDate, toHashOrRef) + override fun getCommitsWithFiles(sshUrl: String, fromHashOrRef: String?, fromDate: Date?, toHashOrRef: String) = + client.getCommitsWithFiles(sshUrl, fromHashOrRef, fromDate, toHashOrRef) + override fun getCommit(sshUrl: String, hashOrRef: String) = client.getCommit(sshUrl, hashOrRef) + override fun getCommitWithFiles(sshUrl: String, hashOrRef: String) = client.getCommitWithFiles(sshUrl, hashOrRef) + override fun getIssuesFromCommits(sshUrl: String, fromHashOrRef: String?, fromDate: Date?, toHashOrRef: String) = client.getIssuesFromCommits(sshUrl, fromHashOrRef, fromDate, toHashOrRef) @@ -51,6 +56,8 @@ class ClassicVcsFacadeClient( override fun findCommitsByIssueKey(issueKey: String) = client.findCommitsByIssueKey(issueKey) + override fun findCommitsWithFilesByIssueKey(issueKey: String) = client.findCommitsWithFilesByIssueKey(issueKey) + override fun findPullRequestsByIssueKey(issueKey: String) = client.findPullRequestsByIssueKey(issueKey) fun setUrl(apiUrl: String, timeRetryInMillis: Int) { diff --git a/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/Commit.kt b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/Commit.kt index 230d4af..466f8f1 100644 --- a/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/Commit.kt +++ b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/Commit.kt @@ -10,7 +10,7 @@ data class Commit( val parents: List, val link: String, val repository: Repository -) : Comparable { +) : VcsFacadeResponse, Comparable { override fun compareTo(other: Commit) = compareBy(Commit::repository).thenByDescending(Commit::date).compare(this, other) } diff --git a/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/CommitWithFiles.kt b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/CommitWithFiles.kt new file mode 100644 index 0000000..7b2c655 --- /dev/null +++ b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/CommitWithFiles.kt @@ -0,0 +1,8 @@ +package org.octopusden.octopus.vcsfacade.client.common.dto + +data class CommitWithFiles( + val commit: Commit, + val files: List +) : VcsFacadeResponse, Comparable { + override fun compareTo(other: CommitWithFiles) = commit compareTo other.commit +} diff --git a/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChange.kt b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChange.kt new file mode 100644 index 0000000..82b7003 --- /dev/null +++ b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChange.kt @@ -0,0 +1,3 @@ +package org.octopusden.octopus.vcsfacade.client.common.dto + +data class FileChange(val type: FileChangeType, val path: String, val link: String) diff --git a/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChangeType.kt b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChangeType.kt new file mode 100644 index 0000000..093540c --- /dev/null +++ b/common/src/main/kotlin/org/octopusden/octopus/vcsfacade/client/common/dto/FileChangeType.kt @@ -0,0 +1,5 @@ +package org.octopusden.octopus.vcsfacade.client.common.dto + +enum class FileChangeType { + ADD, MODIFY, DELETE +} \ No newline at end of file diff --git a/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestBitbucket.kt b/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestBitbucket.kt index 79c01ce..7d9c8a0 100644 --- a/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestBitbucket.kt +++ b/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestBitbucket.kt @@ -15,7 +15,7 @@ class VcsFacadeFunctionalTestBitbucket : BaseVcsFacadeFunctionalTest( "absent-repo" to "Repository $PROJECT/absent does not exist.", "commitById" to "Commit '$DEFAULT_ID' does not exist in repository '$REPOSITORY'.", "commitsException_1" to "Commit '$DEFAULT_ID' does not exist in repository '$REPOSITORY'.", - "commitsException_2" to "Params 'fromHashOrRef' and 'fromDate' can not be used together", + "commitsException_2" to "'hashOrRef' and 'date' can not be used together", "commitsException_3" to "Cannot find commit '${MESSAGE_3.commitId(REPOSITORY)}' in commit graph for commit '${MESSAGE_1.commitId(REPOSITORY)}' in '$PROJECT:$REPOSITORY'", "pr_1" to "Project absent does not exist.", "pr_2" to "Source branch 'absent' not found in '$PROJECT:$REPOSITORY'", diff --git a/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitea.kt b/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitea.kt index 9d45626..fea4b3c 100644 --- a/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitea.kt +++ b/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitea.kt @@ -22,7 +22,7 @@ class VcsFacadeFunctionalTestGitea : BaseVcsFacadeFunctionalTest( "absent-repo" to "The target couldn't be found.", "commitById" to DEFAULT_ID, "commitsException_1" to "object does not exist [id: $DEFAULT_ID, rel_path: ]", - "commitsException_2" to "Params 'fromHashOrRef' and 'fromDate' can not be used together", + "commitsException_2" to "'hashOrRef' and 'date' can not be used together", "commitsException_3" to "Cannot find commit '${MESSAGE_3.commitId(REPOSITORY)}' in commit graph for commit '${ MESSAGE_1.commitId( REPOSITORY diff --git a/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitlab.kt b/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitlab.kt index 9c7a321..7321dcb 100644 --- a/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitlab.kt +++ b/ft/src/ft/kotlin/org/octopusden/octopus/vcsfacade/VcsFacadeFunctionalTestGitlab.kt @@ -21,7 +21,7 @@ class VcsFacadeFunctionalTestGitlab : BaseVcsFacadeFunctionalTest( "absent-repo" to "Repository '$PROJECT:absent' does not exist.", "commitById" to "Commit '$DEFAULT_ID' does not exist in repository '$PROJECT:$REPOSITORY'.", "commitsException_1" to "Commit '$DEFAULT_ID' does not exist in repository '$PROJECT:$REPOSITORY'.", - "commitsException_2" to "Params 'fromHashOrRef' and 'fromDate' can not be used together", + "commitsException_2" to "'hashOrRef' and 'date' can not be used together", "commitsException_3" to "Can't find commit '${MESSAGE_3.commitId(REPOSITORY)}' in graph but it exists in the '$PROJECT:$REPOSITORY'", "pr_1" to "Group 'absent' does not exist.", "pr_2" to "Source branch 'absent' not found in '$PROJECT:$REPOSITORY'", diff --git a/gradle.properties b/gradle.properties index 37488dd..245088e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ bmuschko-docker-plugin.version=9.4.0 docker-compose-plugin.version=0.16.9 spring-data-opensearch.version=1.3.0 springdoc-openapi.version=2.3.0 -external-systems-client.version=2.0.35 +external-systems-client.version=2.0.38 gitlab4j-api.version=6.0.0-rc.4 bitbucket.version=8.14.0-jdk11 gitea.version=1.21.10 diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/controller/RepositoryController.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/controller/RepositoryController.kt index 47b535d..ed3011a 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/controller/RepositoryController.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/controller/RepositoryController.kt @@ -9,6 +9,7 @@ import java.util.concurrent.Future import java.util.concurrent.TimeUnit import org.octopusden.octopus.vcsfacade.client.common.Constants import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.SearchIssuesInRangesRequest @@ -59,13 +60,41 @@ class RepositoryController( RepositoryResponse(vcsManager.getCommits(sshUrl, fromHashOrRef, fromDate, toHashOrRef)) }.data.sorted() + @GetMapping("commits/files", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getCommitsWithFiles( + @RequestParam("sshUrl") sshUrl: String, + @RequestParam("fromHashOrRef", required = false) fromHashOrRef: String?, + @RequestParam("fromDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) fromDate: Date?, + @RequestParam("toHashOrRef") toHashOrRef: String, + @RequestHeader(Constants.DEFERRED_RESULT_HEADER, required = false) requestId: String? + ) = processRequest(requestId ?: UUID.randomUUID().toString()) { + log.info( + "Get commits ({},{}] with files in `{}` repository", + (fromHashOrRef ?: fromDate?.toString()).orEmpty(), + toHashOrRef, + sshUrl + ) + RepositoryResponse(vcsManager.getCommitsWithFiles(sshUrl, fromHashOrRef, fromDate, toHashOrRef)) + }.data.sorted() + @GetMapping("commit", produces = [MediaType.APPLICATION_JSON_VALUE]) fun getCommit( @RequestParam("sshUrl") sshUrl: String, - @RequestParam("hashOrRef") hashOrRef: String - ): Commit { + @RequestParam("hashOrRef") hashOrRef: String, + @RequestHeader(Constants.DEFERRED_RESULT_HEADER, required = false) requestId: String? + ) = processRequest(requestId ?: UUID.randomUUID().toString()) { log.info("Get commit {} in `{}` repository", hashOrRef, sshUrl) - return vcsManager.getCommit(sshUrl, hashOrRef) + vcsManager.getCommit(sshUrl, hashOrRef) + } + + @GetMapping("commit/files", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun getCommitWithFiles( + @RequestParam("sshUrl") sshUrl: String, + @RequestParam("hashOrRef") hashOrRef: String, + @RequestHeader(Constants.DEFERRED_RESULT_HEADER, required = false) requestId: String? + ) = processRequest(requestId ?: UUID.randomUUID().toString()) { + log.info("Get commit {} in `{}` repository", hashOrRef, sshUrl) + vcsManager.getCommitWithFiles(sshUrl, hashOrRef) } @GetMapping("issues", produces = [MediaType.APPLICATION_JSON_VALUE]) @@ -152,6 +181,15 @@ class RepositoryController( RepositoryResponse(vcsManager.findCommits(issueKey)) }.data.sorted() + @GetMapping("find/{issueKey}/commits/files", produces = [MediaType.APPLICATION_JSON_VALUE]) + fun findCommitsWithFilesByIssueKey( + @PathVariable("issueKey") issueKey: String, + @RequestHeader(Constants.DEFERRED_RESULT_HEADER, required = false) requestId: String? + ) = processRequest(requestId ?: UUID.randomUUID().toString()) { + log.info("Find commits with files by issue key {}", issueKey) + RepositoryResponse(vcsManager.findCommitsWithFiles(issueKey)) + }.data.sorted() + @GetMapping("find/{issueKey}/pull-requests", produces = [MediaType.APPLICATION_JSON_VALUE]) fun findPullRequestsByIssueKey( @PathVariable("issueKey") issueKey: String, diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/CommitDocument.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/CommitDocument.kt index ebfeb23..7b40b1f 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/CommitDocument.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/CommitDocument.kt @@ -19,7 +19,8 @@ class CommitDocument( @Field(type = FieldType.Date) val date: Date, @Field(type = FieldType.Object) val author: UserDocument, @Field(type = FieldType.Keyword) val parents: List, - @Field(type = FieldType.Keyword) val link: String + @Field(type = FieldType.Keyword) val link: String, + @Field(type = FieldType.Object) val files: List ) : BaseDocument(id(repository.id, hash)) { override fun toString() = "CommitDocument(id=$id, repository=$repository, hash=$hash, message=$message, date=$date, author=$author, parents=$parents, link=$link)" diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/FileChangeDocument.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/FileChangeDocument.kt new file mode 100644 index 0000000..1b2a5f6 --- /dev/null +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/document/FileChangeDocument.kt @@ -0,0 +1,11 @@ +package org.octopusden.octopus.vcsfacade.document + +import org.octopusden.octopus.vcsfacade.client.common.dto.FileChangeType +import org.springframework.data.elasticsearch.annotations.Field +import org.springframework.data.elasticsearch.annotations.FieldType + +data class FileChangeDocument( + @Field(type = FieldType.Keyword) val type: FileChangeType, + @Field(type = FieldType.Text, analyzer = "classic") val path: String, + @Field(type = FieldType.Keyword) val link: String +) \ No newline at end of file diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/dto/HashOrRefOrDate.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/dto/HashOrRefOrDate.kt new file mode 100644 index 0000000..2e0bb52 --- /dev/null +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/dto/HashOrRefOrDate.kt @@ -0,0 +1,20 @@ +package org.octopusden.octopus.vcsfacade.dto + +import java.util.Date +import org.octopusden.octopus.vcsfacade.client.common.exception.ArgumentsNotCompatibleException + +sealed class HashOrRefOrDate { + class HashOrRefValue(val value: String) : HashOrRefOrDate() + class DateValue(val value: Date) : HashOrRefOrDate() + + companion object { + fun create(hashOrRef: String?, date: Date?) = if (hashOrRef != null) { + if (date != null) { + throw ArgumentsNotCompatibleException("'hashOrRef' and 'date' can not be used together") + } + HashOrRefValue(hashOrRef) + } else if (date != null) { + DateValue(date) + } else null + } +} \ No newline at end of file diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/OpenSearchService.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/OpenSearchService.kt index 30048c0..98d247e 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/OpenSearchService.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/OpenSearchService.kt @@ -2,6 +2,8 @@ package org.octopusden.octopus.vcsfacade.service import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles +import org.octopusden.octopus.vcsfacade.client.common.dto.FileChange import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequestReviewer import org.octopusden.octopus.vcsfacade.client.common.dto.Ref @@ -11,6 +13,7 @@ import org.octopusden.octopus.vcsfacade.client.common.dto.SearchSummary import org.octopusden.octopus.vcsfacade.client.common.dto.Tag import org.octopusden.octopus.vcsfacade.client.common.dto.User import org.octopusden.octopus.vcsfacade.document.CommitDocument +import org.octopusden.octopus.vcsfacade.document.FileChangeDocument import org.octopusden.octopus.vcsfacade.document.PullRequestDocument import org.octopusden.octopus.vcsfacade.document.PullRequestReviewerDocument import org.octopusden.octopus.vcsfacade.document.RefDocument @@ -37,9 +40,9 @@ interface OpenSearchService { fun savePullRequests(pullRequests: List) fun deletePullRequestsByIds(pullRequestsIds: List) fun deletePullRequestsByRepositoryId(repositoryId: String) - fun findBranchesByIssueKey(issueKey: String): List - fun findCommitsByIssueKey(issueKey: String): List - fun findPullRequestsByIssueKey(issueKey: String): List + fun findBranchesByIssueKey(issueKey: String): List + fun findCommitsByIssueKey(issueKey: String): List + fun findPullRequestsByIssueKey(issueKey: String): List fun findByIssueKey(issueKey: String): SearchSummary companion object { @@ -51,12 +54,21 @@ interface OpenSearchService { RefType.TAG -> Tag(name, hash, link, repository.toDto()) } - fun Commit.toDocument(repositoryDocument: RepositoryDocument) = CommitDocument( - repositoryDocument, hash, message, date, author.toDocument(), parents, link + fun CommitWithFiles.toDocument(repositoryDocument: RepositoryDocument) = CommitDocument( + repositoryDocument, + commit.hash, + commit.message, + commit.date, + commit.author.toDocument(), + commit.parents, + commit.link, + files.map { it.toDocument() } ) - fun CommitDocument.toDto() = - Commit(hash, message, date, author.toDto(), parents, link, repository.toDto()) + fun CommitDocument.toDto() = CommitWithFiles( + Commit(hash, message, date, author.toDto(), parents, link, repository.toDto()), + files.map { it.toDto() } + ) fun PullRequest.toDocument(repositoryDocument: RepositoryDocument) = PullRequestDocument( repositoryDocument, @@ -98,6 +110,10 @@ interface OpenSearchService { private fun UserDocument.toDto() = User(name, avatar) + private fun FileChange.toDocument() = FileChangeDocument(type, path, link) + + private fun FileChangeDocument.toDto() = FileChange(type, path, link) + fun RepositoryDocument.toDto() = Repository(sshUrl, link, avatar) } } \ No newline at end of file diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsManager.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsManager.kt index 8884c07..08c69e6 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsManager.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsManager.kt @@ -3,6 +3,7 @@ package org.octopusden.octopus.vcsfacade.service import java.util.Date import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.SearchIssueInRangesResponse @@ -13,11 +14,14 @@ import org.octopusden.octopus.vcsfacade.client.common.dto.Tag interface VcsManager { fun getTags(sshUrl: String): List fun getCommits(sshUrl: String, fromHashOrRef: String?, fromDate: Date?, toHashOrRef: String): List + fun getCommitsWithFiles(sshUrl: String, fromHashOrRef: String?, fromDate: Date?, toHashOrRef: String): List fun getCommit(sshUrl: String, hashOrRef: String): Commit + fun getCommitWithFiles(sshUrl: String, hashOrRef: String): CommitWithFiles fun createPullRequest(sshUrl: String, createPullRequest: CreatePullRequest): PullRequest fun searchIssuesInRanges(searchRequest: SearchIssuesInRangesRequest): SearchIssueInRangesResponse fun findBranches(issueKey: String): List fun findCommits(issueKey: String): List + fun findCommitsWithFiles(issueKey: String): List fun findPullRequests(issueKey: String): List fun find(issueKey: String): SearchSummary } diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsService.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsService.kt index bbde3a7..662a0bb 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsService.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/VcsService.kt @@ -3,10 +3,12 @@ package org.octopusden.octopus.vcsfacade.service import java.util.Date import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.Tag import org.octopusden.octopus.vcsfacade.config.VcsConfig +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate abstract class VcsService(vcsProperties: VcsConfig.VcsProperties) { protected val httpUrl = vcsProperties.host.lowercase().trimEnd('/') @@ -19,14 +21,16 @@ abstract class VcsService(vcsProperties: VcsConfig.VcsProperties) { abstract fun getBranches(group: String, repository: String): List abstract fun getTags(group: String, repository: String): List - abstract fun getCommits(group: String, repository: String, fromHashOrRef: String, toHashOrRef: String): List - abstract fun getCommits(group: String, repository: String, fromDate: Date?, toHashOrRef: String): List + abstract fun getCommits(group: String, repository: String, from: HashOrRefOrDate?, toHashOrRef: String): List + abstract fun getCommitsWithFiles(group: String, repository: String, from: HashOrRefOrDate?, toHashOrRef: String): List abstract fun getCommit(group: String, repository: String, hashOrRef: String): Commit + abstract fun getCommitWithFiles(group: String, repository: String, hashOrRef: String): CommitWithFiles abstract fun createPullRequest(group: String, repository: String, createPullRequest: CreatePullRequest): PullRequest abstract fun getPullRequest(group: String, repository: String, index: Long): PullRequest abstract fun findCommits(group: String, repository: String, hashes: Set): List abstract fun findPullRequests(group: String, repository: String, indexes: Set): List abstract fun findBranches(issueKey: String): List abstract fun findCommits(issueKey: String): List + abstract fun findCommitsWithFiles(issueKey: String): List abstract fun findPullRequests(issueKey: String): List } diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/BitbucketService.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/BitbucketService.kt index a96e966..c7aaf00 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/BitbucketService.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/BitbucketService.kt @@ -10,6 +10,7 @@ import org.octopusden.octopus.infrastructure.bitbucket.client.BitbucketCredentia import org.octopusden.octopus.infrastructure.bitbucket.client.createPullRequestWithDefaultReviewers import org.octopusden.octopus.infrastructure.bitbucket.client.dto.BitbucketBranch import org.octopusden.octopus.infrastructure.bitbucket.client.dto.BitbucketCommit +import org.octopusden.octopus.infrastructure.bitbucket.client.dto.BitbucketCommitChange import org.octopusden.octopus.infrastructure.bitbucket.client.dto.BitbucketPullRequest import org.octopusden.octopus.infrastructure.bitbucket.client.dto.BitbucketPullRequestState import org.octopusden.octopus.infrastructure.bitbucket.client.dto.BitbucketTag @@ -17,11 +18,15 @@ import org.octopusden.octopus.infrastructure.bitbucket.client.dto.BitbucketUser import org.octopusden.octopus.infrastructure.bitbucket.client.exception.NotFoundException import org.octopusden.octopus.infrastructure.bitbucket.client.getBranches import org.octopusden.octopus.infrastructure.bitbucket.client.getCommit +import org.octopusden.octopus.infrastructure.bitbucket.client.getCommitChanges import org.octopusden.octopus.infrastructure.bitbucket.client.getCommits import org.octopusden.octopus.infrastructure.bitbucket.client.getTags import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest +import org.octopusden.octopus.vcsfacade.client.common.dto.FileChange +import org.octopusden.octopus.vcsfacade.client.common.dto.FileChangeType import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequestReviewer import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequestStatus @@ -29,6 +34,7 @@ import org.octopusden.octopus.vcsfacade.client.common.dto.Repository import org.octopusden.octopus.vcsfacade.client.common.dto.Tag import org.octopusden.octopus.vcsfacade.client.common.dto.User import org.octopusden.octopus.vcsfacade.config.VcsConfig +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate import org.octopusden.octopus.vcsfacade.service.VcsService import org.slf4j.LoggerFactory import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -41,7 +47,7 @@ import org.springframework.stereotype.Service class BitbucketService( bitbucketProperties: VcsConfig.BitbucketProperties, ) : VcsService(bitbucketProperties) { - private val bitbucketClient: BitbucketClient = BitbucketClassicClient(object : BitbucketClientParametersProvider { + private val client: BitbucketClient = BitbucketClassicClient(object : BitbucketClientParametersProvider { override fun getApiUrl(): String = httpUrl override fun getAuth(): BitbucketCredentialProvider { @@ -60,43 +66,66 @@ class BitbucketService( override fun getBranches(group: String, repository: String): List { log.trace("=> getBranches({}, {})", group, repository) - return bitbucketClient.getBranches(group, repository).map { it.toBranch(group, repository) }.also { + return client.getBranches(group, repository).map { it.toBranch(group, repository) }.also { log.trace("<= getBranches({}, {}): {}", group, repository, it) } } override fun getTags(group: String, repository: String): List { log.trace("=> getTags({}, {})", group, repository) - return bitbucketClient.getTags(group, repository).map { it.toTag(group, repository) }.also { + return client.getTags(group, repository).map { it.toTag(group, repository) }.also { log.trace("<= getTags({}, {}): {}", group, repository, it) } } - override fun getCommits(group: String, repository: String, fromHashOrRef: String, toHashOrRef: String): List { - log.trace("=> getCommits({}, {}, {}, {})", group, repository, fromHashOrRef, toHashOrRef) - return bitbucketClient.getCommits(group, repository, toHashOrRef, fromHashOrRef).map { it.toCommit(group, repository) }.also { - log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, fromHashOrRef, toHashOrRef, it) + override fun getCommits( + group: String, + repository: String, + from: HashOrRefOrDate?, + toHashOrRef: String + ): List { + log.trace("=> getCommits({}, {}, {}, {})", group, repository, from, toHashOrRef) + val commits = if (from is HashOrRefOrDate.HashOrRefValue) { + client.getCommits(group, repository, toHashOrRef, from.value) + } else { + client.getCommits(group, repository, toHashOrRef, (from as? HashOrRefOrDate.DateValue)?.value) + } + return commits.map { it.toCommit(group, repository) }.also { + log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, from, toHashOrRef, it) } } - override fun getCommits(group: String, repository: String, fromDate: Date?, toHashOrRef: String): List { - log.trace("=> getCommits({}, {}, {}, {})", group, repository, fromDate, toHashOrRef) - return bitbucketClient.getCommits(group, repository, toHashOrRef, fromDate).map { it.toCommit(group, repository) } - .also { log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, fromDate, toHashOrRef, it) } + override fun getCommitsWithFiles( + group: String, + repository: String, + from: HashOrRefOrDate?, + toHashOrRef: String + ): List { + log.trace("=> getCommitsWithFiles({}, {}, {}, {})", group, repository, from, toHashOrRef) + return getCommits(group, repository, from, toHashOrRef).map { + CommitWithFiles(it, getCommitChanges(group, repository, it)) + }.also { log.trace("<= getCommitsWithFiles({}, {}, {}, {}): {}", group, repository, from, toHashOrRef, it) } } override fun getCommit(group: String, repository: String, hashOrRef: String): Commit { log.trace("=> getCommit({}, {}, {})", group, repository, hashOrRef) - return bitbucketClient.getCommit(group, repository, hashOrRef).toCommit(group, repository).also { + return client.getCommit(group, repository, hashOrRef).toCommit(group, repository).also { log.trace("<= getCommit({}, {}, {}): {}", group, repository, hashOrRef, it) } } + override fun getCommitWithFiles(group: String, repository: String, hashOrRef: String): CommitWithFiles { + log.trace("=> getCommitWithFiles({}, {}, {})", group, repository, hashOrRef) + return with(getCommit(group, repository, hashOrRef)) { + CommitWithFiles(this, getCommitChanges(group, repository, this)) + }.also { log.trace("<= getCommitWithFiles({}, {}, {}): {}", group, repository, hashOrRef, it) } + } + override fun createPullRequest( group: String, repository: String, createPullRequest: CreatePullRequest ): PullRequest { log.trace("=> createPullRequest({}, {}, {})", group, repository, createPullRequest) - return bitbucketClient.createPullRequestWithDefaultReviewers( + return client.createPullRequestWithDefaultReviewers( group, repository, createPullRequest.sourceBranch, @@ -110,7 +139,7 @@ class BitbucketService( override fun getPullRequest(group: String, repository: String, index: Long): PullRequest { log.trace("=> getPullRequest({}, {}, {})", group, repository, index) - return bitbucketClient.getPullRequest(group, repository, index).toPullRequest(group, repository).also { + return client.getPullRequest(group, repository, index).toPullRequest(group, repository).also { log.trace("<= getPullRequest({}, {}, {}): {}", group, repository, index, it) } } @@ -119,7 +148,7 @@ class BitbucketService( log.trace("=> findCommits({}, {}, {})", group, repository, hashes) return hashes.mapNotNull { try { - bitbucketClient.getCommit(group, repository, it).toCommit(group, repository) + client.getCommit(group, repository, it).toCommit(group, repository) } catch (e: NotFoundException) { null } @@ -132,7 +161,7 @@ class BitbucketService( log.trace("=> findPullRequests({}, {}, {})", group, repository, indexes) return indexes.mapNotNull { try { - bitbucketClient.getPullRequest(group, repository, it).toPullRequest(group, repository) + client.getPullRequest(group, repository, it).toPullRequest(group, repository) } catch (e: NotFoundException) { null } @@ -148,18 +177,53 @@ class BitbucketService( override fun findCommits(issueKey: String): List { log.trace("=> findCommits({})", issueKey) - return bitbucketClient.getCommits(issueKey).map { + return client.getCommits(issueKey).map { it.toCommit.toCommit(it.repository.project.key.lowercase(), it.repository.slug.lowercase()) }.also { log.trace("<= findCommits({}): {}", issueKey, it) } } + override fun findCommitsWithFiles(issueKey: String): List { + log.trace("=> findCommitsWithFiles({})", issueKey) + return client.getCommits(issueKey).map { + val group = it.repository.project.key.lowercase() + val repository = it.repository.slug.lowercase() + val commit = it.toCommit.toCommit(group, repository) + CommitWithFiles(commit, getCommitChanges(group, repository, commit)) + }.also { log.trace("<= findCommitsWithFiles({}): {}", issueKey, it) } + } + override fun findPullRequests(issueKey: String): List { log.warn("There is no native implementation of findPullRequests") return emptyList() } + private fun getCommitChanges(group: String, repository: String, commit: Commit): List { + log.trace("=> getCommitChanges({}, {}, {})", group, repository, commit) + return client.getCommitChanges(group, repository, commit.hash).flatMap { + val files = mutableListOf( + FileChange( + when (it.type) { + BitbucketCommitChange.BitbucketCommitChangeType.ADD, + BitbucketCommitChange.BitbucketCommitChangeType.COPY, + BitbucketCommitChange.BitbucketCommitChangeType.MOVE -> FileChangeType.ADD + + BitbucketCommitChange.BitbucketCommitChangeType.MODIFY -> FileChangeType.MODIFY + + BitbucketCommitChange.BitbucketCommitChangeType.DELETE -> FileChangeType.DELETE + }, + it.path.value, + "${commit.link}#${it.path.value}" + ) + ) + if (it.type == BitbucketCommitChange.BitbucketCommitChangeType.MOVE) { + files.add(FileChange(FileChangeType.DELETE, it.srcPath!!.value, "${commit.link}#${it.srcPath!!.value}")) + } + files + }.also { log.trace("<= getCommitChanges({}, {}, {}): {}", group, repository, commit, it) } + } + private fun getRepository(project: String, repository: String) = Repository( "ssh://git@$host/$project/$repository.git", "$httpUrl/projects/$project/repos/$repository/browse", diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaIndexerServiceImpl.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaIndexerServiceImpl.kt index 5e4dac7..0adcc06 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaIndexerServiceImpl.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaIndexerServiceImpl.kt @@ -83,7 +83,7 @@ class GiteaIndexerServiceImpl( checkInRepository(repositoryDocument) openSearchService.saveCommits(giteaPushEvent.commits.map { //IMPORTANT: commits in push event does not contain all demanded data, so it is required to get it from gitea directly - giteaService.getCommit(repositoryDocument.group, repositoryDocument.name, it.id) + giteaService.getCommitWithFiles(repositoryDocument.group, repositoryDocument.name, it.id) .toDocument(repositoryDocument) }) log.trace("<= registerGiteaPushEvent({})", giteaPushEvent) @@ -200,7 +200,8 @@ class GiteaIndexerServiceImpl( ) openSearchService.deleteCommitsByIds(orphanedCommitsIds) logIndexActionMessage( - "Save ${commits.size} commits(s) in index for `${repository.fullName()}` $GITEA repository ", commits + "Save ${commits.size} commits(s) in index for `${repository.fullName()}` $GITEA repository ", + commits ) openSearchService.saveCommits(commits) val indexPullRequestsIds = openSearchService.findPullRequestsByRepositoryId(repository.id).map { it.id } diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaService.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaService.kt index ab038ef..7cfeb09 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaService.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GiteaService.kt @@ -1,5 +1,7 @@ package org.octopusden.octopus.vcsfacade.service.impl +import java.math.BigInteger +import java.security.MessageDigest import java.util.Date import org.octopusden.octopus.infrastructure.client.commons.ClientParametersProvider import org.octopusden.octopus.infrastructure.client.commons.CredentialProvider @@ -18,6 +20,7 @@ import org.octopusden.octopus.infrastructure.gitea.client.dto.GiteaUser import org.octopusden.octopus.infrastructure.gitea.client.exception.NotFoundException import org.octopusden.octopus.infrastructure.gitea.client.getBranches import org.octopusden.octopus.infrastructure.gitea.client.getBranchesCommitGraph +import org.octopusden.octopus.infrastructure.gitea.client.getCommit import org.octopusden.octopus.infrastructure.gitea.client.getCommits import org.octopusden.octopus.infrastructure.gitea.client.getOrganizations import org.octopusden.octopus.infrastructure.gitea.client.getPullRequestReviews @@ -26,7 +29,10 @@ import org.octopusden.octopus.infrastructure.gitea.client.getRepositories import org.octopusden.octopus.infrastructure.gitea.client.getTags import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest +import org.octopusden.octopus.vcsfacade.client.common.dto.FileChange +import org.octopusden.octopus.vcsfacade.client.common.dto.FileChangeType import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequestReviewer import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequestStatus @@ -34,6 +40,9 @@ import org.octopusden.octopus.vcsfacade.client.common.dto.Repository import org.octopusden.octopus.vcsfacade.client.common.dto.Tag import org.octopusden.octopus.vcsfacade.client.common.dto.User import org.octopusden.octopus.vcsfacade.config.VcsConfig +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate.DateValue +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate.HashOrRefValue import org.octopusden.octopus.vcsfacade.service.VcsService import org.slf4j.LoggerFactory import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -53,10 +62,11 @@ class GiteaService( val authException by lazy { IllegalStateException("Auth Token or username/password must be specified for Gitea access") } - return giteaProperties.token?.let { StandardBearerTokenCredentialProvider(it) } - ?: StandardBasicCredCredentialProvider( - giteaProperties.username ?: throw authException, giteaProperties.password ?: throw authException - ) + return giteaProperties.token?.let { + StandardBearerTokenCredentialProvider(it) + } ?: StandardBasicCredCredentialProvider( + giteaProperties.username ?: throw authException, giteaProperties.password ?: throw authException + ) } }) @@ -64,9 +74,8 @@ class GiteaService( fun getRepositories(): List { log.trace("=> getRepositories()") - return client.getOrganizations().flatMap { client.getRepositories(it.name) }.map { toRepository(it) }.also { - log.trace("<= getRepositories(): {}", it) - } + return client.getOrganizations().flatMap { client.getRepositories(it.name) }.map { toRepository(it) } + .also { log.trace("<= getRepositories(): {}", it) } } fun findRepository(group: String, repository: String): Repository? { @@ -75,75 +84,80 @@ class GiteaService( toRepository(client.getRepository(group, repository)) } catch (e: NotFoundException) { null - }.also { - log.trace("<= findRepository({}, {}): {}", group, repository, it) - } + }.also { log.trace("<= findRepository({}, {}): {}", group, repository, it) } } fun getRepository(group: String, repository: String): Repository { log.trace("=> getRepository({}, {})", group, repository) - return toRepository(client.getRepository(group, repository)).also { - log.trace("<= getRepository({}, {}): {}", group, repository, it) - } + return toRepository(client.getRepository(group, repository)) + .also { log.trace("<= getRepository({}, {}): {}", group, repository, it) } } override fun getBranches(group: String, repository: String): List { log.trace("=> getBranches({}, {})", group, repository) return with(getRepository(group, repository)) { client.getBranches(group, repository).map { it.toBranch(this) } - }.also { - log.trace("<= getBranches({}, {}): {}", group, repository, it) - } + }.also { log.trace("<= getBranches({}, {}): {}", group, repository, it) } } override fun getTags(group: String, repository: String): List { log.trace("=> getTags({}, {})", group, repository) return with(getRepository(group, repository)) { client.getTags(group, repository).map { it.toTag(this) } - }.also { - log.trace("<= getTags({}, {}): {}", group, repository, it) - } + }.also { log.trace("<= getTags({}, {}): {}", group, repository, it) } } - override fun getCommits(group: String, repository: String, fromHashOrRef: String, toHashOrRef: String): List { - log.trace("=> getCommits({}, {}, {}, {})", group, repository, fromHashOrRef, toHashOrRef) + override fun getCommits( + group: String, repository: String, from: HashOrRefOrDate?, toHashOrRef: String + ): List { + log.trace("=> getCommits({}, {}, {}, {})", group, repository, from, toHashOrRef) return with(getRepository(group, repository)) { - client.getCommits(group, repository, toHashOrRef, fromHashOrRef).map { it.toCommit(this) } - }.also { - log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, fromHashOrRef, toHashOrRef, it) - } + val commits = if (from is HashOrRefValue) { + client.getCommits(group, repository, toHashOrRef, from.value) + } else { + client.getCommits(group, repository, toHashOrRef, (from as? DateValue)?.value) + } + commits.map { it.toCommit(this) } + }.also { log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, from, toHashOrRef, it) } } - override fun getCommits(group: String, repository: String, fromDate: Date?, toHashOrRef: String): List { - log.trace("=> getCommits({}, {}, {}, {})", group, repository, fromDate, toHashOrRef) + override fun getCommitsWithFiles( + group: String, repository: String, from: HashOrRefOrDate?, toHashOrRef: String + ): List { + log.trace("=> getCommitsWithFiles({}, {}, {}, {})", group, repository, from, toHashOrRef) return with(getRepository(group, repository)) { - client.getCommits(group, repository, toHashOrRef, fromDate).map { it.toCommit(this) } - }.also { - log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, fromDate, toHashOrRef, it) - } + val commits = if (from is HashOrRefValue) { + client.getCommits(group, repository, toHashOrRef, from.value, true) + } else { + client.getCommits(group, repository, toHashOrRef, (from as? DateValue)?.value, true) + } + commits.map { it.toCommitWithFiles(this) } + }.also { log.trace("<= getCommitsWithFiles({}, {}, {}, {}): {}", group, repository, from, toHashOrRef, it) } } - fun getBranchesCommitGraph(group: String, repository: String): List { + fun getBranchesCommitGraph(group: String, repository: String): List { log.trace("=> getBranchesCommitGraph({}, {})", group, repository) return with(getRepository(group, repository)) { - client.getBranchesCommitGraph(group, repository).map { it.toCommit(this) } - }.also { - log.trace("<= getBranchesCommitGraph({}, {}): {}", group, repository, it) - } + client.getBranchesCommitGraph(group, repository, true).map { it.toCommitWithFiles(this) } + }.also { log.trace("<= getBranchesCommitGraph({}, {}): {}", group, repository, it) } } override fun getCommit(group: String, repository: String, hashOrRef: String): Commit { log.trace("=> getCommit({}, {}, {})", group, repository, hashOrRef) - return client.getCommit(group, repository, hashOrRef).toCommit(getRepository(group, repository)).also { - log.trace("<= getCommit({}, {}, {}): {}", group, repository, hashOrRef, it) - } + return client.getCommit(group, repository, hashOrRef).toCommit(getRepository(group, repository)) + .also { log.trace("<= getCommit({}, {}, {}): {}", group, repository, hashOrRef, it) } + } + + override fun getCommitWithFiles(group: String, repository: String, hashOrRef: String): CommitWithFiles { + log.trace("=> getCommitWithFiles({}, {}, {})", group, repository, hashOrRef) + return client.getCommit(group, repository, hashOrRef, true).toCommitWithFiles(getRepository(group, repository)) + .also { log.trace("<= getCommitWithFiles({}, {}, {}): {}", group, repository, hashOrRef, it) } } fun getPullRequestReviews(group: String, repository: String, number: Long): List { log.trace("=> getPullRequestReviews({}, {}, {})", group, repository, number) - return client.getPullRequestReviews(group, repository, number).also { - log.trace("<= getPullRequestReviews({}, {}, {}): {}", group, repository, number, it) - } + return client.getPullRequestReviews(group, repository, number) + .also { log.trace("<= getPullRequestReviews({}, {}, {}): {}", group, repository, number, it) } } fun getPullRequests(group: String, repository: String): List { @@ -152,9 +166,7 @@ class GiteaService( client.getPullRequests(group, repository).map { it.toPullRequest(this, getPullRequestReviews(group, repository, it.number)) } - }.also { - log.trace("<= getPullRequests({}, {}): {}", group, repository, it) - } + }.also { log.trace("<= getPullRequests({}, {}): {}", group, repository, it) } } override fun createPullRequest( @@ -172,9 +184,7 @@ class GiteaService( it.toPullRequest( getRepository(group, repository), client.getPullRequestReviews(group, repository, it.number) ) - }.also { - log.trace("<= getPullRequests({}, {}, {}): {}", group, repository, createPullRequest, it) - } + }.also { log.trace("<= getPullRequests({}, {}, {}): {}", group, repository, createPullRequest, it) } } override fun getPullRequest(group: String, repository: String, index: Long): PullRequest { @@ -183,9 +193,7 @@ class GiteaService( it.toPullRequest( getRepository(group, repository), client.getPullRequestReviews(group, repository, it.number) ) - }.also { - log.trace("<= getPullRequest({}, {}, {}): {}", group, repository, index, it) - } + }.also { log.trace("<= getPullRequest({}, {}, {}): {}", group, repository, index, it) } } override fun findCommits(group: String, repository: String, hashes: Set): List { @@ -198,9 +206,7 @@ class GiteaService( null } } - }.also { - log.trace("<= findCommits({}, {}, {}): {}", group, repository, hashes, it) - } + }.also { log.trace("<= findCommits({}, {}, {}): {}", group, repository, hashes, it) } } override fun findPullRequests(group: String, repository: String, indexes: Set): List { @@ -214,9 +220,7 @@ class GiteaService( null } } - }.also { - log.trace("<= findPullRequests({}, {}, {}): {}", group, repository, indexes, it) - } + }.also { log.trace("<= findPullRequests({}, {}, {}): {}", group, repository, indexes, it) } } override fun findBranches(issueKey: String): List { @@ -229,6 +233,11 @@ class GiteaService( return emptyList() } + override fun findCommitsWithFiles(issueKey: String): List { + log.warn("There is no native implementation of findCommitsWithFiles") + return emptyList() + } + override fun findPullRequests(issueKey: String): List { log.warn("There is no native implementation of findPullRequests") return emptyList() @@ -265,6 +274,21 @@ class GiteaService( repository ) + private fun String.sha1() = + BigInteger(1, MessageDigest.getInstance("SHA-1").digest(toByteArray())).toString(16).padStart(32, '0') + + private fun GiteaCommit.toCommitWithFiles(repository: Repository) = with(toCommit(repository)) { + CommitWithFiles(this, files!!.map { + FileChange( + when (it.status) { + GiteaCommit.GiteaCommitAffectedFileStatus.ADDED -> FileChangeType.ADD + GiteaCommit.GiteaCommitAffectedFileStatus.MODIFIED -> FileChangeType.MODIFY + GiteaCommit.GiteaCommitAffectedFileStatus.REMOVED -> FileChangeType.DELETE + }, it.filename, "${this.link}#diff-${it.filename.sha1()}" + ) + }) + } + fun GiteaPullRequest.toPullRequest( repository: Repository, giteaPullRequestReviews: List ): PullRequest { diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GitlabService.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GitlabService.kt index dff0321..6a060ce 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GitlabService.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/GitlabService.kt @@ -12,6 +12,7 @@ import org.gitlab4j.api.models.MergeRequest import org.gitlab4j.api.models.Project import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequestReviewer @@ -21,6 +22,9 @@ import org.octopusden.octopus.vcsfacade.client.common.dto.Tag import org.octopusden.octopus.vcsfacade.client.common.dto.User import org.octopusden.octopus.vcsfacade.client.common.exception.NotFoundException import org.octopusden.octopus.vcsfacade.config.VcsConfig +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate.DateValue +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate.HashOrRefValue import org.octopusden.octopus.vcsfacade.service.VcsService import org.slf4j.LoggerFactory import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -73,34 +77,46 @@ class GitlabService( } } - override fun getCommits(group: String, repository: String, fromHashOrRef: String, toHashOrRef: String): List { - log.trace("=> getCommits({}, {}, {}, {})", group, repository, fromHashOrRef, toHashOrRef) + override fun getCommits( + group: String, + repository: String, + from: HashOrRefOrDate?, + toHashOrRef: String + ): List { + log.trace("=> getCommits({}, {}, {}, {})", group, repository, from, toHashOrRef) val project = getProject(group, repository) - val fromHash = getCommitByHashOrRef(project, fromHashOrRef).id val toHash = getCommitByHashOrRef(project, toHashOrRef).id - if (toHash == fromHash) { - return emptyList() - } - val commits = retryableExecution { - client.commitsApi.getCommits(project.id, toHash, null, null, 100).asSequence().flatten() - .map { it.toCommit(group, repository) }.toList() + val commits = lazy { + retryableExecution { + client.commitsApi.getCommits(project.id, toHash, null, null, 100).asSequence().flatten() + .map { it.toCommit(group, repository) }.toList() + } } - return filterCommitGraph(group, repository, commits, fromHash, null, toHash).also { - log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, fromHashOrRef, toHashOrRef, it) + return if (from is HashOrRefValue) { + val fromHash = getCommitByHashOrRef(project, from.value).id + if (toHash == fromHash) { + emptyList() + } else { + filterCommitGraph(group, repository, commits.value, fromHash, null, toHash).also { + log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, from, toHashOrRef, it) + } + } + } else { + val fromDate = (from as? DateValue)?.value + filterCommitGraph(group, repository, commits.value, null, fromDate, toHash).also { + log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, fromDate, toHashOrRef, it) + } } } - override fun getCommits(group: String, repository: String, fromDate: Date?, toHashOrRef: String): List { - log.trace("=> getCommits({}, {}, {}, {})", group, repository, fromDate, toHashOrRef) - val project = getProject(group, repository) - val toHash = getCommitByHashOrRef(project, toHashOrRef).id - val commits = retryableExecution { - client.commitsApi.getCommits(project.id, toHash, null, null, 100).asSequence().flatten() - .map { it.toCommit(group, repository) }.toList() - } - return filterCommitGraph(group, repository, commits, null, fromDate, toHash).also { - log.trace("<= getCommits({}, {}, {}, {}): {}", group, repository, fromDate, toHashOrRef, it) - } + override fun getCommitsWithFiles( + group: String, + repository: String, + from: HashOrRefOrDate?, + toHashOrRef: String + ): List { + log.warn("There is no native implementation of getCommitsWithFiles") + return getCommits(group, repository, from, toHashOrRef).map { CommitWithFiles(it, emptyList()) } } override fun getCommit(group: String, repository: String, hashOrRef: String): Commit { @@ -110,6 +126,10 @@ class GitlabService( } } + override fun getCommitWithFiles(group: String, repository: String, hashOrRef: String): CommitWithFiles { + log.warn("There is no native implementation of getCommitWithFiles") + return CommitWithFiles(getCommit(group, repository, hashOrRef), emptyList()) + } override fun createPullRequest( group: String, repository: String, createPullRequest: CreatePullRequest @@ -178,6 +198,11 @@ class GitlabService( return emptyList() } + override fun findCommitsWithFiles(issueKey: String): List { + log.warn("There is no native implementation of findCommitsWithFiles") + return emptyList() + } + override fun findPullRequests(issueKey: String): List { log.warn("There is no native implementation of findPullRequests") return emptyList() @@ -186,7 +211,8 @@ class GitlabService( private fun getCommitByHashOrRef(project: Project, hashOrRef: String): GitlabCommit { val shortRefName = hashOrRef.toShortRefName() val hash = retryableExecution { - client.repositoryApi.getBranches(project, shortRefName).firstOrNull { b -> b.name == shortRefName }?.commit?.id + client.repositoryApi.getBranches(project, shortRefName) + .firstOrNull { b -> b.name == shortRefName }?.commit?.id } ?: retryableExecution { client.tagsApi.getTags(project.id).firstOrNull { t -> t.name == shortRefName }?.commit?.id } ?: hashOrRef diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/OpenSearchServiceImpl.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/OpenSearchServiceImpl.kt index 2ae1b95..f3738f2 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/OpenSearchServiceImpl.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/OpenSearchServiceImpl.kt @@ -131,34 +131,31 @@ class OpenSearchServiceImpl( log.trace("<= deletePullRequestsByRepositoryId({})", repositoryId) } - override fun findBranchesByIssueKey(issueKey: String): List { + override fun findBranchesByIssueKey(issueKey: String): List { log.trace("=> findBranchesByIssueKey({})", issueKey) return with(IssueKeyParser.getIssueKeyRegex(issueKey)) { refRepository.searchByTypeAndNameContaining(RefType.BRANCH, issueKey) .filter { containsMatchIn(it.name) } - .map { it.toDto() as Branch } }.also { log.trace("<= findBranchesByIssueKey({}): {}", issueKey, it) } } - override fun findCommitsByIssueKey(issueKey: String): List { + override fun findCommitsByIssueKey(issueKey: String): List { log.trace("=> findCommitsByIssueKey({})", issueKey) return with(IssueKeyParser.getIssueKeyRegex(issueKey)) { commitRepository.searchByMessageContaining(issueKey) .filter { containsMatchIn(it.message) } - .map { it.toDto() } }.also { log.trace("<= findCommitsByIssueKey({}): {}", issueKey, it) } } - override fun findPullRequestsByIssueKey(issueKey: String): List { + override fun findPullRequestsByIssueKey(issueKey: String): List { log.trace("=> findPullRequestsByIssueKey({})", issueKey) return with(IssueKeyParser.getIssueKeyRegex(issueKey)) { pullRequestRepository.searchByTitleContainingOrDescriptionContaining(issueKey, issueKey) .filter { containsMatchIn(it.title) || containsMatchIn(it.description) } - .map { it.toDto() } }.also { log.trace("<= findPullRequestsByIssueKey({}): {}", issueKey, it) } diff --git a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/VcsManagerImpl.kt b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/VcsManagerImpl.kt index 96fcdb2..5bc9ffb 100644 --- a/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/VcsManagerImpl.kt +++ b/server/src/main/kotlin/org/octopusden/octopus/vcsfacade/service/impl/VcsManagerImpl.kt @@ -4,6 +4,7 @@ import java.util.Date import java.util.stream.Collectors import org.octopusden.octopus.vcsfacade.client.common.dto.Branch import org.octopusden.octopus.vcsfacade.client.common.dto.Commit +import org.octopusden.octopus.vcsfacade.client.common.dto.CommitWithFiles import org.octopusden.octopus.vcsfacade.client.common.dto.CreatePullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.PullRequest import org.octopusden.octopus.vcsfacade.client.common.dto.SearchIssueInRangesResponse @@ -12,8 +13,10 @@ import org.octopusden.octopus.vcsfacade.client.common.dto.SearchSummary import org.octopusden.octopus.vcsfacade.client.common.dto.Tag import org.octopusden.octopus.vcsfacade.client.common.exception.ArgumentsNotCompatibleException import org.octopusden.octopus.vcsfacade.config.VcsConfig +import org.octopusden.octopus.vcsfacade.dto.HashOrRefOrDate import org.octopusden.octopus.vcsfacade.issue.IssueKeyParser import org.octopusden.octopus.vcsfacade.service.OpenSearchService +import org.octopusden.octopus.vcsfacade.service.OpenSearchService.Companion.toDto import org.octopusden.octopus.vcsfacade.service.VcsManager import org.octopusden.octopus.vcsfacade.service.VcsService import org.slf4j.LoggerFactory @@ -44,22 +47,27 @@ class VcsManagerImpl( toHashOrRef: String ): List { log.trace("=> getCommits({}, {}, {}, {})", sshUrl, fromHashOrRef, fromDate, toHashOrRef) - val vcsService = getVcsService(sshUrl) - val (group, repository) = vcsService.parse(sshUrl) - val commits = if (fromHashOrRef != null) { - if (fromDate != null) { - throw ArgumentsNotCompatibleException("Params 'fromHashOrRef' and 'fromDate' can not be used together") - } - if (fromHashOrRef == toHashOrRef) { - emptyList() - } else { - vcsService.getCommits(group, repository, fromHashOrRef, toHashOrRef) - } - } else { - vcsService.getCommits(group, repository, fromDate, toHashOrRef) + return getVcsService(sshUrl).run { + val (group, repository) = parse(sshUrl) + getCommits(group, repository, HashOrRefOrDate.create(fromHashOrRef, fromDate), toHashOrRef) + }.also { + log.trace("<= getCommits({}, {}, {}, {}): {}", sshUrl, fromHashOrRef, fromDate, toHashOrRef, it) + } + } + + override fun getCommitsWithFiles( + sshUrl: String, + fromHashOrRef: String?, + fromDate: Date?, + toHashOrRef: String + ): List { + log.trace("=> getCommitsWithFiles({}, {}, {}, {})", sshUrl, fromHashOrRef, fromDate, toHashOrRef) + return getVcsService(sshUrl).run { + val (group, repository) = parse(sshUrl) + getCommitsWithFiles(group, repository, HashOrRefOrDate.create(fromHashOrRef, fromDate), toHashOrRef) + }.also { + log.trace("<= getCommitsWithFiles({}, {}, {}, {}): {}", sshUrl, fromHashOrRef, fromDate, toHashOrRef, it) } - log.trace("<= getCommits({}, {}, {}, {}): {}", sshUrl, fromHashOrRef, fromDate, toHashOrRef, commits) - return commits } override fun getCommit(sshUrl: String, hashOrRef: String): Commit { @@ -72,6 +80,16 @@ class VcsManagerImpl( } } + override fun getCommitWithFiles(sshUrl: String, hashOrRef: String): CommitWithFiles { + log.trace("=> getCommitWithFiles({}, {})", sshUrl, hashOrRef) + return getVcsService(sshUrl).run { + val (group, repository) = parse(sshUrl) + getCommitWithFiles(group, repository, hashOrRef) + }.also { + log.trace("<= getCommitWithFiles({}, {}): {}", sshUrl, hashOrRef, it) + } + } + override fun createPullRequest(sshUrl: String, createPullRequest: CreatePullRequest): PullRequest { log.trace("=> createPullRequest({}, {})", sshUrl, createPullRequest) return getVcsService(sshUrl).run { @@ -106,7 +124,7 @@ class VcsManagerImpl( override fun findBranches(issueKey: String): List { log.trace("=> findBranches({})", issueKey) - val branches = openSearchService?.findBranchesByIssueKey(issueKey) + val branches = openSearchService?.findBranchesByIssueKey(issueKey)?.map { it.toDto() as Branch } ?: vcsServices.flatMap { it.findBranches(issueKey) } log.trace("<= findBranches({}): {}", issueKey, branches) return branches @@ -114,15 +132,23 @@ class VcsManagerImpl( override fun findCommits(issueKey: String): List { log.trace("=> findCommits({})", issueKey) - val commits = openSearchService?.findCommitsByIssueKey(issueKey) + val commits = openSearchService?.findCommitsByIssueKey(issueKey)?.map { it.toDto().commit } ?: vcsServices.flatMap { it.findCommits(issueKey) } log.trace("<= findCommits({}): {}", issueKey, commits) return commits } + override fun findCommitsWithFiles(issueKey: String): List { + log.trace("=> findCommitsWithFiles({})", issueKey) + val commits = openSearchService?.findCommitsByIssueKey(issueKey)?.map { it.toDto() } + ?: vcsServices.flatMap { it.findCommitsWithFiles(issueKey) } + log.trace("<= findCommitsWithFiles({}): {}", issueKey, commits) + return commits + } + override fun findPullRequests(issueKey: String): List { log.trace("=> findPullRequests({})", issueKey) - val pullRequests = openSearchService?.findPullRequestsByIssueKey(issueKey) + val pullRequests = openSearchService?.findPullRequestsByIssueKey(issueKey)?.map { it.toDto() } ?: vcsServices.flatMap { it.findPullRequests(issueKey) } log.trace("<= findPullRequests({}): {}", issueKey, pullRequests) return pullRequests diff --git a/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestBitbucket.kt b/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestBitbucket.kt index cb2470b..18f745b 100644 --- a/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestBitbucket.kt +++ b/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestBitbucket.kt @@ -15,7 +15,7 @@ class VcsFacadeUnitTestBitbucket : BaseVcsFacadeUnitTest( "absent-repo" to "Repository $PROJECT/absent does not exist.", "commitById" to "Commit '$DEFAULT_ID' does not exist in repository '$REPOSITORY'.", "commitsException_1" to "Commit '$DEFAULT_ID' does not exist in repository '$REPOSITORY'.", - "commitsException_2" to "Params 'fromHashOrRef' and 'fromDate' can not be used together", + "commitsException_2" to "'hashOrRef' and 'date' can not be used together", "commitsException_3" to "Cannot find commit '${MESSAGE_3.commitId(REPOSITORY)}' in commit graph for commit '${MESSAGE_1.commitId(REPOSITORY)}' in '$PROJECT:$REPOSITORY'", "pr_1" to "Project absent does not exist.", "pr_2" to "Source branch 'absent' not found in '$PROJECT:$REPOSITORY'", diff --git a/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitea.kt b/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitea.kt index 9f80042..27c3074 100644 --- a/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitea.kt +++ b/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitea.kt @@ -22,7 +22,7 @@ class VcsFacadeUnitTestGitea : BaseVcsFacadeUnitTest( "absent-repo" to "The target couldn't be found.", "commitById" to DEFAULT_ID, "commitsException_1" to "object does not exist [id: $DEFAULT_ID, rel_path: ]", - "commitsException_2" to "Params 'fromHashOrRef' and 'fromDate' can not be used together", + "commitsException_2" to "'hashOrRef' and 'date' can not be used together", "commitsException_3" to "Cannot find commit '${MESSAGE_3.commitId(REPOSITORY)}' in commit graph for commit '${MESSAGE_1.commitId(REPOSITORY)}' in '$PROJECT:$REPOSITORY'", "pr_1" to "GetUserByName", "pr_2" to "Source branch 'absent' not found in '$PROJECT:$REPOSITORY'", diff --git a/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitlab.kt b/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitlab.kt index 867ec59..cf71d34 100644 --- a/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitlab.kt +++ b/server/src/test/kotlin/org/octopusden/octopus/vcsfacade/vcs/VcsFacadeUnitTestGitlab.kt @@ -21,7 +21,7 @@ class VcsFacadeUnitTestGitlab : BaseVcsFacadeUnitTest( "absent-repo" to "Repository '$PROJECT:absent' does not exist.", "commitById" to "Commit '$DEFAULT_ID' does not exist in repository '$PROJECT:$REPOSITORY'.", "commitsException_1" to "Commit '$DEFAULT_ID' does not exist in repository '$PROJECT:$REPOSITORY'.", - "commitsException_2" to "Params 'fromHashOrRef' and 'fromDate' can not be used together", + "commitsException_2" to "'hashOrRef' and 'date' can not be used together", "commitsException_3" to "Can't find commit '${MESSAGE_3.commitId(REPOSITORY)}' in graph but it exists in the '$PROJECT:$REPOSITORY'", "pr_1" to "Group 'absent' does not exist.", "pr_2" to "Source branch 'absent' not found in '$PROJECT:$REPOSITORY'",