Skip to content

Commit

Permalink
Merge pull request #112 from cb372/remote-url-other-protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg authored Apr 21, 2020
2 parents 3c6fe53 + 18a6bd9 commit b6e352d
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,30 @@ object CiReleasePlugin extends AutoPlugin {
}
}

private def gitHubScmInfo(user: String, repo: String) =
ScmInfo(
url(s"https://github.com/$user/$repo"),
s"scm:git:https://github.com/$user/$repo.git",
Some(s"scm:git:[email protected]:$user/$repo.git")
)

override lazy val buildSettings: Seq[Def.Setting[_]] = List(
dynverSonatypeSnapshots := true,
scmInfo ~= {
case Some(info) => Some(info)
case None =>
import scala.sys.process._
val identifier = """([^\/]+)"""
val GitHubHttps = s"https://github.com/$identifier/$identifier".r
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"[email protected]:$identifier/$identifier(?:\\.git)?".r
try {
val remote = List("git", "ls-remote", "--get-url", "origin").!!.trim()
remote match {
case GitHubHttps(user, repo) =>
Some(
ScmInfo(
url(s"https://github.com/$user/$repo"),
s"scm:git:https://github.com/$user/$repo.git",
Some(s"scm:git:[email protected]:$user/$repo.git")
)
)
case _ =>
None
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
}
} catch {
case NonFatal(_) => None
Expand Down

0 comments on commit b6e352d

Please sign in to comment.