-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support SSH and Git protocol remote URLs
When extracting the SCM info from the git remote URL: * Support HTTPS, SSH and git protocols * Support URLs with the optional `.git` suffix
- Loading branch information
Showing
1 changed file
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|