Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Scala Steward: Reformat with scalafmt 2.5.3
30bed714ec3cf492505003855b036ea69fb4add5

# Scala Steward: Reformat with scalafmt 2.7.5
749b54033e08c4dbbd31854a6600a449a46d08cf
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 2.5.3
version = 2.7.5
align.preset = more
maxColumn = 80
docstrings = "ScalaDoc"
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ case class GitlabCredentials(key: String, value: String)

object GitlabCredentials {

/**
* Apply method for Private-Token or Job-Token supplied by sbt credentials blob
/** Apply method for Private-Token or Job-Token supplied by sbt credentials blob
* @param directCredentials credentials class
* @return GitlabCredentials
*/
Expand Down
21 changes: 15 additions & 6 deletions src/main/scala/io/github/tangramflex/sbt/gitlab/GitlabPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package io.github.tangramflex.sbt.gitlab

import lmcoursier.definitions.Authentication
import lmcoursier.CoursierConfiguration
import org.apache.ivy.util.url.{URLHandler, URLHandlerDispatcher, URLHandlerRegistry}
import org.apache.ivy.util.url.{
URLHandler,
URLHandlerDispatcher,
URLHandlerRegistry
}

import sbt.Keys.*
import sbt.*
Expand Down Expand Up @@ -71,11 +75,16 @@ object GitlabPlugin extends AutoPlugin {

private val addGitlabRepoAuth = Def.task {
gitlabCredentialsHandler.value match {
case Some(creds) => gitlabResolvers.value.foldRight(csrConfiguration.value) {
case (repo, csr) => csr.withAuthenticationByRepositoryId(
csr.authenticationByRepositoryId :+
(repo.name -> Authentication("","").withHeaders(Seq(creds.key -> creds.value)))
)}
case Some(creds) =>
gitlabResolvers.value.foldRight(csrConfiguration.value) {
case (repo, csr) =>
csr.withAuthenticationByRepositoryId(
csr.authenticationByRepositoryId :+
(repo.name -> Authentication("", "").withHeaders(
Seq(creds.key -> creds.value)
))
)
}
case None => csrConfiguration.value
}
}
Expand Down