Merge pull request #301 from boxofrad/talksapp-tests

Add integration tests for talks app
diff --git a/gosrc/gosrc.go b/gosrc/gosrc.go
index 9ae9fca..41b41b3 100644
--- a/gosrc/gosrc.go
+++ b/gosrc/gosrc.go
@@ -324,13 +324,17 @@
 		}
 	}
 
-	repo := strings.TrimSuffix(im.repo, "."+im.vcs)
-	i := strings.Index(repo, "://")
+	// clonePath is the repo URL from import meta tag, with the "scheme://" prefix removed.
+	// It should be used for cloning repositories.
+	// repo is the repo URL from import meta tag, with the "scheme://" prefix removed, and
+	// a possible ".vcs" suffix trimmed.
+	i := strings.Index(im.repo, "://")
 	if i < 0 {
 		return nil, NotFoundError{Message: "bad repo URL: " + im.repo}
 	}
-	proto := repo[:i]
-	repo = repo[i+len("://"):]
+	proto := im.repo[:i]
+	clonePath := im.repo[i+len("://"):]
+	repo := strings.TrimSuffix(clonePath, "."+im.vcs)
 	dirName := importPath[len(im.projectRoot):]
 
 	resolvedPath := repo + dirName
@@ -340,6 +344,7 @@
 		match := map[string]string{
 			"dir":        dirName,
 			"importPath": importPath,
+			"clonePath":  clonePath,
 			"repo":       repo,
 			"scheme":     proto,
 			"vcs":        im.vcs,
diff --git a/gosrc/path.go b/gosrc/path.go
index 6575df8..8219d68 100644
--- a/gosrc/path.go
+++ b/gosrc/path.go
@@ -26,11 +26,6 @@
 
 	parts := strings.Split(importPath, "/")
 
-	if len(parts) <= 1 {
-		// Import path must contain at least one "/".
-		return false
-	}
-
 	if !validTLDs[path.Ext(parts[0])] {
 		return false
 	}
diff --git a/gosrc/path_test.go b/gosrc/path_test.go
index 5b4ec96..965b75b 100644
--- a/gosrc/path_test.go
+++ b/gosrc/path_test.go
@@ -20,6 +20,7 @@
 	"launchpad.net/~user/foo/trunk",
 	"launchpad.net/~user/+junk/version",
 	"github.com/user/repo/_ok/x",
+	"exampleproject.com",
 }
 
 var badImportPaths = []string{
@@ -27,7 +28,6 @@
 	"foo.",
 	".bar",
 	"favicon.ico",
-	"exmpple.com",
 	"github.com/user/repo/.ignore/x",
 }
 
diff --git a/gosrc/vcs.go b/gosrc/vcs.go
index ce872f9..db0c083 100644
--- a/gosrc/vcs.go
+++ b/gosrc/vcs.go
@@ -101,7 +101,7 @@
 
 type vcsCmd struct {
 	schemes  []string
-	download func([]string, string, string) (string, string, error)
+	download func(schemes []string, clonePath, repo, savedEtag string) (tag, etag string, err error)
 }
 
 var vcsCmds = map[string]*vcsCmd{
@@ -117,11 +117,11 @@
 
 var lsremoteRe = regexp.MustCompile(`(?m)^([0-9a-f]{40})\s+refs/(?:tags|heads)/(.+)$`)
 
-func downloadGit(schemes []string, repo, savedEtag string) (string, string, error) {
+func downloadGit(schemes []string, clonePath, repo, savedEtag string) (string, string, error) {
 	var p []byte
 	var scheme string
 	for i := range schemes {
-		cmd := exec.Command("git", "ls-remote", "--heads", "--tags", schemes[i]+"://"+repo)
+		cmd := exec.Command("git", "ls-remote", "--heads", "--tags", schemes[i]+"://"+clonePath)
 		log.Println(strings.Join(cmd.Args, " "))
 		var err error
 		p, err = outputWithTimeout(cmd, lsRemoteTimeout)
@@ -158,7 +158,7 @@
 		if err := os.MkdirAll(dir, 0777); err != nil {
 			return "", "", err
 		}
-		cmd := exec.Command("git", "clone", scheme+"://"+repo, dir)
+		cmd := exec.Command("git", "clone", scheme+"://"+clonePath, dir)
 		log.Println(strings.Join(cmd.Args, " "))
 		if err := runWithTimeout(cmd, cloneTimeout); err != nil {
 			return "", "", err
@@ -183,12 +183,12 @@
 	return tag, etag, nil
 }
 
-func downloadSVN(schemes []string, repo, savedEtag string) (string, string, error) {
+func downloadSVN(schemes []string, clonePath, repo, savedEtag string) (string, string, error) {
 	var scheme string
 	var revno string
 	for i := range schemes {
 		var err error
-		revno, err = getSVNRevision(schemes[i] + "://" + repo)
+		revno, err = getSVNRevision(schemes[i] + "://" + clonePath)
 		if err == nil {
 			scheme = schemes[i]
 			break
@@ -212,7 +212,7 @@
 		if err := os.MkdirAll(dir, 0777); err != nil {
 			return "", "", err
 		}
-		cmd := exec.Command("svn", "checkout", scheme+"://"+repo, "-r", revno, dir)
+		cmd := exec.Command("svn", "checkout", scheme+"://"+clonePath, "-r", revno, dir)
 		log.Println(strings.Join(cmd.Args, " "))
 		if err := runWithTimeout(cmd, cloneTimeout); err != nil {
 			return "", "", err
@@ -271,7 +271,7 @@
 
 	// Download and checkout.
 
-	tag, etag, err := cmd.download(schemes, match["repo"], etagSaved)
+	tag, etag, err := cmd.download(schemes, match["clonePath"], match["repo"], etagSaved)
 	if err != nil {
 		return nil, err
 	}