Skip to content

Commit

Permalink
Merge pull request #4 from TangramFlex/cred-bug
Browse files Browse the repository at this point in the history
Cred bug
  • Loading branch information
listba authored Sep 21, 2022
2 parents a92ffc8 + 4a7e558 commit a1b68f4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 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 @@ -57,7 +57,7 @@ object GitlabPlugin extends AutoPlugin {
.map {
GitlabCredentials(_)
}
}.get
}
}

private def projectRepo(domain: String, projectId: Int): MavenRepository =
Expand All @@ -82,9 +82,10 @@ object GitlabPlugin extends AutoPlugin {
.map(GitlabCredentials("Job-Token", _))
},
headerAuthHandler := {
val cred = gitlabCredentialsHandler.value
val dispatcher = gitlabUrlHandlerDispatcher(gitlabDomain.value, cred)
URLHandlerRegistry.setDefault(dispatcher)
gitlabCredentialsHandler.value.map{ creds =>
val dispatcher = gitlabUrlHandlerDispatcher(gitlabDomain.value, creds)
URLHandlerRegistry.setDefault(dispatcher)
}
},
update := update.dependsOn(headerAuthHandler).value,
updateClassifiers := updateClassifiers.dependsOn(headerAuthHandler).value,
Expand All @@ -98,8 +99,13 @@ object GitlabPlugin extends AutoPlugin {
).flatten,
resolvers ++= gitlabResolvers.value,
// Adds Coursier repository Authentication for each gitlabResolver
csrConfiguration := gitlabResolvers.value.foldRight(csrConfiguration.value){
case (repo, csr) => csr.addRepositoryAuthentication(repo.name, Authentication(Seq(gitlabCredentialsHandler.value.key -> gitlabCredentialsHandler.value.value)))
csrConfiguration := {
gitlabCredentialsHandler.value match {
case Some(creds) => gitlabResolvers.value.foldRight(csrConfiguration.value) {
case (repo, csr) => csr.addRepositoryAuthentication(repo.name, Authentication(Seq(creds.key -> creds.value)))
}
case None => csrConfiguration.value
}
},
publish := publish.dependsOn(headerAuthHandler).value,
// If no publish location is specified then publish to the project id (if set)
Expand Down

0 comments on commit a1b68f4

Please sign in to comment.