@@ -121,30 +121,32 @@ object SbtGit {
121121 gitCurrentTags := gitReader.value.withGit(_.currentTags),
122122 gitCurrentBranch := Option (gitReader.value.withGit(_.branch)).getOrElse(" " ),
123123 gitUncommittedChanges in ThisBuild := gitReader.value.withGit(_.hasUncommittedChanges),
124- scmInfo := {
125- val user = """ (?:[^@\/]+@)?"""
126- val domain = """ ([^\/]+)"""
127- val gitPath = """ (.*)(?:\.git)?\/?"""
128- val unauthenticated = raw """ (?:git|https?|ftps?)\:\/\/ $domain\/ $gitPath""" .r
129- val ssh = raw """ ssh\:\/\/ $user$domain\/ $gitPath""" .r
130- val headlessSSH = raw """ $user$domain: $gitPath""" .r
131-
132- def buildScmInfo (domain : String , repo : String ) = Option (
133- ScmInfo (
134- url(s " https:// $domain/ $repo" ),
135- s " scm:git:https:// $domain/ $repo.git " ,
136- Some (s " scm:git:git@ $domain: $repo.git " )
137- )
124+ scmInfo := parseScmInfo(gitReader.value.withGit(_.remoteOrigin))
125+ )
126+ private [sbt] def parseScmInfo (remoteOrigin : String ): Option [ScmInfo ] = {
127+ val user = """ (?:[^@\/]+@)?"""
128+ val domain = """ ([^\/]+)"""
129+ val gitPath = """ (.*?)(?:\.git)?\/?$"""
130+ val unauthenticated = raw """ (?:git|https?|ftps?)\:\/\/ $domain\/ $gitPath""" .r
131+ val ssh = raw """ ssh\:\/\/ $user$domain\/ $gitPath""" .r
132+ val headlessSSH = raw """ $user$domain: $gitPath""" .r
133+
134+ def buildScmInfo (domain : String , repo : String ): Option [ScmInfo ] = Option (
135+ ScmInfo (
136+ url(s " https:// $domain/ $repo" ),
137+ s " scm:git:https:// $domain/ $repo.git " ,
138+ Some (s " scm:git:git@ $domain: $repo.git " )
138139 )
140+ )
139141
140- gitReader.value.withGit(_.remoteOrigin) match {
141- case unauthenticated(domain, repo) => buildScmInfo(domain,repo)
142- case ssh(domain, repo) => buildScmInfo(domain,repo)
143- case headlessSSH(domain, repo) => buildScmInfo(domain,repo)
144- case _ => None
145- }
142+ remoteOrigin match {
143+ case unauthenticated(domain, repo) => buildScmInfo(domain,repo)
144+ case ssh(domain, repo) => buildScmInfo(domain,repo)
145+ case headlessSSH(domain, repo) => buildScmInfo(domain,repo)
146+ case _ => None
146147 }
147- )
148+ }
149+
148150 val projectSettings = Seq (
149151 // Input task to run git commands directly.
150152 commands += GitCommand .command
0 commit comments