All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.octopusden.octopus.vcsfacade.service.VcsService.kt Maven / Gradle / Ivy

The newest version!
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.CreateTag
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('/')
    protected val host = httpUrl.replace("^(https|http)://".toRegex(), "")

    protected abstract val sshUrlRegex: Regex
    fun isSupport(sshUrl: String) = sshUrlRegex.matches(sshUrl.lowercase())
    fun parse(sshUrl: String) =
        sshUrlRegex.find(sshUrl.lowercase())!!.destructured.let { it.component1().trimEnd('/') to it.component2() }

    abstract fun getBranches(group: String, repository: String): Sequence
    abstract fun getTags(group: String, repository: String): Sequence
    abstract fun createTag(group: String, repository: String, createTag: CreateTag): Tag
    abstract fun getTag(group: String, repository: String, name: String): Tag
    abstract fun deleteTag(group: String, repository: String, name: String)
    abstract fun getCommits(group: String, repository: String, from: HashOrRefOrDate?, toHashOrRef: String): Sequence
    abstract fun getCommitsWithFiles(group: String, repository: String, from: HashOrRefOrDate?, toHashOrRef: String): Sequence
    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): Sequence
    abstract fun findPullRequests(group: String, repository: String, indexes: Set): Sequence
    abstract fun findBranches(issueKey: String): Sequence
    abstract fun findCommits(issueKey: String): Sequence
    abstract fun findCommitsWithFiles(issueKey: String): Sequence
    abstract fun findPullRequests(issueKey: String): Sequence
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy