From 75686d9433451b715bb17ac953c8f234650d3067 Mon Sep 17 00:00:00 2001 From: Jamie Willis Date: Fri, 15 Sep 2023 13:23:52 +0100 Subject: [PATCH 1/2] Added version bound check and added slash --- .../typelevel/sbt/TypelevelGitHubPlugin.scala | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala b/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala index 97318a42..78c5060e 100644 --- a/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala +++ b/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala @@ -18,12 +18,12 @@ package org.typelevel.sbt import com.github.sbt.git.SbtGit.git import org.typelevel.sbt.kernel.GitHelper +import org.typelevel.sbt.kernel.V import sbt._ import scala.util.Try import Keys._ -import TypelevelKernelPlugin.autoImport._ object TypelevelGitHubPlugin extends AutoPlugin { @@ -82,19 +82,24 @@ object TypelevelGitHubPlugin extends AutoPlugin { val userRepo = gitHubUserRepo.value val infoOpt = scmInfo.value - if (tlIsScala3.value) - tagOrHash.toSeq flatMap { vh => - userRepo.toSeq flatMap { - case (user, repo) => Seq(s"-source-links:github://${user}/${repo}", "-revision", vh) - } - } - else - tagOrHash.toSeq flatMap { vh => - infoOpt.toSeq flatMap { info => - val path = s"${info.browseUrl}/blob/${vh}€{FILE_PATH}.scala" - Seq("-doc-source-url", path) - } + tagOrHash.toSeq flatMap { vh => + scalaVersion.value match { + case V(V(3, _, _, _)) => + userRepo.toSeq flatMap { + case (user, repo) => + Seq(s"-source-links:github://${user}/${repo}", "-revision", vh) + } + case (V(V(2, minor, patch, _))) => + infoOpt.toSeq flatMap { info => + val path = + // see https://github.com/scala/bug/issues/12867#issuecomment-1718481858 + if (minor > 13 || minor == 13 && patch.exists(_ >= 12)) + s"${info.browseUrl}/blob/${vh}/€{FILE_PATH}.scala" + else s"${info.browseUrl}/blob/${vh}€{FILE_PATH}.scala" + Seq("-doc-source-url", path) + } } + } } ) From f5e0b2ffd80c2b2f4ffb2edee05f1f84a0b18aa9 Mon Sep 17 00:00:00 2001 From: Jamie Willis Date: Fri, 15 Sep 2023 19:09:04 +0100 Subject: [PATCH 2/2] Update github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala Added slash on not specified --- .../main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala b/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala index 78c5060e..f15a1a7d 100644 --- a/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala +++ b/github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala @@ -93,7 +93,7 @@ object TypelevelGitHubPlugin extends AutoPlugin { infoOpt.toSeq flatMap { info => val path = // see https://github.com/scala/bug/issues/12867#issuecomment-1718481858 - if (minor > 13 || minor == 13 && patch.exists(_ >= 12)) + if (minor > 13 || minor == 13 && patch.forall(_ >= 12)) s"${info.browseUrl}/blob/${vh}/€{FILE_PATH}.scala" else s"${info.browseUrl}/blob/${vh}€{FILE_PATH}.scala" Seq("-doc-source-url", path)