Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added version bound check and added slash #643

Merged
merged 2 commits into from
Sep 15, 2023
Merged
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
31 changes: 18 additions & 13 deletions github/src/main/scala/org/typelevel/sbt/TypelevelGitHubPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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.forall(_ >= 12))
s"${info.browseUrl}/blob/${vh}/€{FILE_PATH}.scala"
else s"${info.browseUrl}/blob/${vh}€{FILE_PATH}.scala"
Comment on lines +97 to +98
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb question: what if we just always put the slash? Does it work with 2.12, old 2.13s?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered about this, then I didn't want to play with 🔥

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conclusion is, while it does double the slash in the link, this appears to be benign and the link still gets to github ok. However, that feels dodgy to me

Seq("-doc-source-url", path)
}
}
}
}
)

Expand Down