fix url stuff

This commit is contained in:
Cloudburst 2022-08-31 10:26:20 +02:00
parent 2448a204df
commit a52375b346
2 changed files with 18 additions and 15 deletions

View file

@ -16,6 +16,8 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
var repository: Repo? = null var repository: Repo? = null
internal set internal set
var buildBranch: String = "builds"
fun overrideUrlPrefix(url: String) { fun overrideUrlPrefix(url: String) {
if (apkinfo == null) { if (apkinfo == null) {
@ -43,31 +45,32 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
} }
} }
fun setRepo(url: String) { fun setRepo(url: String) {
when { var type: String? = null
url.startsWith("https://github.com") -> {
val split = url var split = when {
url.startsWith("https://github.com") -> {
type = "github"
url
.removePrefix("https://") .removePrefix("https://")
.removePrefix("github.com") .removePrefix("github.com")
.removeSurrounding("/")
.split("/")
setRepo(split[0], split[1], "github")
} }
url.startsWith("https://gitlab.com") -> { url.startsWith("https://gitlab.com") -> {
val split = url type = "gitlab"
url
.removePrefix("https://") .removePrefix("https://")
.removePrefix("gitlab.com") .removePrefix("gitlab.com")
.removeSurrounding("/")
.split("/")
setRepo(split[0], split[1], "gitlab")
} }
!url.startsWith("https://") -> { // assume default as github !url.startsWith("https://") -> { // assume default as github
val split = url type = "github"
.removeSurrounding("/") url
.split("/")
setRepo(split[0], split[1], "github")
} }
else -> throw IllegalArgumentException("Unknown domain, please set repository via setRepo(user, repo, type)") else -> throw IllegalArgumentException("Unknown domain, please set repository via setRepo(user, repo, type)")
} }
.removePrefix("/")
.removeSuffix("/")
.split("/")
setRepo(split[0], split[1], type)
} }
internal var pluginClassName: String? = null internal var pluginClassName: String? = null

View file

@ -36,7 +36,7 @@ fun Project.makePluginEntry(): PluginEntry {
val repo = extension.repository val repo = extension.repository
return PluginEntry( return PluginEntry(
url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", "builds")), url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", extension.buildBranch)),
status = extension.status, status = extension.status,
version = version ?: -1, version = version ?: -1,
name = this.name, name = this.name,