Compare commits

..

4 Commits

2 changed files with 18 additions and 3 deletions

View File

@ -3,6 +3,8 @@ package project
import (
"log"
"net/url"
"os"
"strings"
"github.com/pkg/errors"
"gopkg.in/src-d/go-billy.v4"
@ -15,6 +17,8 @@ import (
)
const GitScheme = "git"
const HTTPScheme = "http"
const HTTPSScheme = "https"
type GitFetcher struct{}
@ -53,6 +57,7 @@ func (f *GitFetcher) Fetch(url *url.URL) (billy.Filesystem, error) {
URL: url.String(),
Auth: auth,
ReferenceName: branchName,
Progress: os.Stdout,
})
if err != nil {
if err == transport.ErrRepositoryNotFound {
@ -85,6 +90,10 @@ func (f *GitFetcher) Match(url *url.URL) bool {
return true
}
if (url.Scheme == HTTPSScheme || url.Scheme == HTTPScheme) && strings.HasSuffix(url.Path, ".git") {
return true
}
isFilesystemPath := isFilesystemPath(url.Path)
if url.Scheme == "" && !isFilesystemPath {
return true

View File

@ -4,6 +4,8 @@ import (
"net/url"
"strings"
"gopkg.in/src-d/go-billy.v4/osfs"
"gopkg.in/src-d/go-billy.v4"
)
@ -13,7 +15,7 @@ const FileScheme = "file"
type LocalFetcher struct{}
func (f *LocalFetcher) Fetch(url *url.URL) (billy.Filesystem, error) {
return nil, nil
return osfs.New(url.Path), nil
}
func (f *LocalFetcher) Match(url *url.URL) bool {
@ -21,7 +23,11 @@ func (f *LocalFetcher) Match(url *url.URL) bool {
return true
}
return isFilesystemPath(url.Path)
if url.Scheme == "" && isFilesystemPath(url.Path) {
return true
}
return false
}
func NewLocalFetcher() *LocalFetcher {
@ -29,5 +35,5 @@ func NewLocalFetcher() *LocalFetcher {
}
func isFilesystemPath(path string) bool {
return strings.HasPrefix(path, "./") || strings.HasPrefix(path, "/")
return strings.HasPrefix(path, ".") || strings.HasPrefix(path, "/")
}