Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
}

errors.toList match {
case (h @ (_, _, e: Upload.Error.HttpError)) :: _
case (h @ (_, _, e: Upload.Error.HttpError)) :: t
if repoParams0.isSonatype && errors.distinctBy(_._3.getMessage()).size == 1 =>
logger.log(s"Error message: ${e.getMessage}")
val httpCodeRegex = "HTTP (\\d+)\n.*".r
Expand All @@ -1000,9 +1000,10 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
| -> have you registered your organisation yet?
|""".stripMargin
)
case _ => throw new UploadError(::(h, Nil))
value(Left(new UploadError(::(h, t))))
case _ => value(Left(new UploadError(::(h, t))))
}
case _ :: _ if repoParams0.isSonatype && errors.forall {
case h :: t if repoParams0.isSonatype && errors.forall {
case (_, _, _: Upload.Error.Unauthorized) => true
case _ => false
} =>
Expand All @@ -1017,6 +1018,7 @@ object Publish extends ScalaCommand[PublishOptions] with BuildCommandHelpers {
| -> consult publish subcommand documentation
|""".stripMargin
)
value(Left(new UploadError(::(h, t))))
case h :: t =>
value(Left(new UploadError(::(h, t))))
case Nil =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract class PublishTestDefinitions extends ScalaCliSuite with TestScalaVersio
_: TestScalaVersion =>
protected def extraOptions: Seq[String] = scalaVersionArgs ++ TestUtil.extraOptions

private object TestCase {
protected object TestCase {
val expectedMessage = "Hello"
val org = "org.virtuslab.scalacli.test"
val name = "simple"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package scala.cli.integration

import com.eed3si9n.expecty.Expecty.expect

import java.nio.file.Paths

class PublishTestsDefault extends PublishTestDefinitions with TestDefault {
test("Pure Java") {
val testOrg = "test-org.foo"
Expand Down Expand Up @@ -202,4 +204,41 @@ class PublishTestsDefault extends PublishTestDefinitions with TestDefault {
checkCredentialsWarning(okRes.out.text())
}
}

test(s"simple failed upload") {
val secretKey = {
val uri = Thread.currentThread().getContextClassLoader
.getResource("test-keys/key.skr")
.toURI
os.Path(Paths.get(uri))
}

val signingOptions = Seq(
"--secret-key",
s"file:$secretKey",
"--secret-key-password",
"value:1234",
"--signer",
"bc"
)

TestCase.testInputs().fromRoot { root =>
val r = os.proc(
TestUtil.cli,
"--power",
"publish",
extraOptions,
signingOptions,
"project",
"--publish-repository",
"sonatype:central"
).call(
cwd = root,
stdin = os.Inherit,
stdout = os.Inherit,
check = false
)
expect(r.exitCode != 0)
}
}
}