Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge pull request #4 from ewoutp/gogs-url-fix

Gogs url fix
  • Loading branch information...
sqs committed Nov 14, 2016
2 parents 1e4dda7 + c3c0adc commit 2305ecca26ab74e3f819cb3875cd631f467e0c2b
Showing with 15 additions and 4 deletions.
  1. +6 −3 vcsurl.go
  2. +9 −1 vcsurl_test.go
@@ -48,13 +48,16 @@ func (r *RepoInfo) Link() string {
}
}

var removeDotGit = regexp.MustCompile(`\.git$`)
var (
removeDotGit = regexp.MustCompile(`\.git$`)
gitPreprocessRE = regexp.MustCompile("^git@([a-zA-Z0-9-_\\.]+)\\:(.*)$")
)

// Parses a string that resembles a VCS repository URL. See TestParse for a list of supported URL
// formats.
func Parse(spec string) (info *RepoInfo, err error) {
if strings.HasPrefix(spec, "git@github.com:") {
spec = strings.Replace(spec, "git@github.com:", "git://github.com/", 1)
if parts := gitPreprocessRE.FindStringSubmatch(spec); len(parts) == 3 {
spec = fmt.Sprintf("git://%s/%s", parts[1], parts[2])
}

var parsedURL *url.URL
@@ -1,8 +1,9 @@
package vcsurl

import (
"github.com/kr/pretty"
"testing"

"github.com/kr/pretty"
)

var (
@@ -118,6 +119,13 @@ func TestParse(t *testing.T) {
Name: "foo",
FullName: "git/foo",
}},
{"git@git.private.com:org/repo.git", "git.private.com/org/repo", RepoInfo{
CloneURL: "git://git.private.com/org/repo.git",
VCS: Git,
RepoHost: "git.private.com",
Name: "repo",
FullName: "org/repo",
}},
}

for _, test := range tests {

0 comments on commit 2305ecc

Please sign in to comment.
You can’t perform that action at this time.