-
Notifications
You must be signed in to change notification settings - Fork 50
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
Extract out a GitHub plugin #31
Changes from all commits
590926a
f59b4f7
8f0968c
81cd145
c10ea43
a7287fb
ba2c0b9
b427520
3f83032
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.typelevel.sbt | ||
|
||
import sbt._, Keys._ | ||
|
||
import scala.util.Try | ||
|
||
object TypelevelGitHubPlugin extends AutoPlugin { | ||
|
||
override def trigger = allRequirements | ||
override def requires = TypelevelKernelPlugin | ||
|
||
object autoImport { | ||
|
||
/** | ||
* Helper to create a `Developer` entry from a GitHub username. | ||
*/ | ||
def tlGitHubDev(user: String, fullName: String): Developer = { | ||
Developer(user, fullName, s"@$user", url(s"https://github.com/$user")) | ||
} | ||
} | ||
|
||
override def buildSettings = Seq( | ||
scmInfo := getScmInfo(), | ||
homepage := homepage.value.orElse(scmInfo.value.map(_.browseUrl)) | ||
) | ||
|
||
def getScmInfo(): Option[ScmInfo] = { | ||
import scala.sys.process._ | ||
|
||
def gitHubScmInfo(user: String, repo: String) = | ||
ScmInfo( | ||
url(s"https://github.com/$user/$repo"), | ||
s"scm:git:https://github.com/$user/$repo.git", | ||
s"scm:git:git@github.com:$user/$repo.git" | ||
) | ||
|
||
val identifier = """([^\/]+?)""" | ||
val GitHubHttps = s"https://github.com/$identifier/$identifier(?:\\.git)?".r | ||
val GitHubGit = s"git://github.com:$identifier/$identifier(?:\\.git)?".r | ||
val GitHubSsh = s"git@github.com:$identifier/$identifier(?:\\.git)?".r | ||
Try { | ||
val remote = List("git", "ls-remote", "--get-url", "origin").!!.trim() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth calling out this is how it works. Not everybody calls origin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. I was mostly concerned with what the CI runners do, since you want to get this right on publish. |
||
remote match { | ||
case GitHubHttps(user, repo) => Some(gitHubScmInfo(user, repo)) | ||
case GitHubGit(user, repo) => Some(gitHubScmInfo(user, repo)) | ||
case GitHubSsh(user, repo) => Some(gitHubScmInfo(user, repo)) | ||
case _ => None | ||
} | ||
}.toOption.flatten | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../github/build.sbt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../github/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.8.0") | ||
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.2") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to be careful with our versioning strategy here. I'm rolling this back from 1.8 because otherwise I can't use it with http4s-dom which is currently blocked by upstream issues with 1.8, see http4s/http4s-dom#60 (comment).