Be slightly less aggressive about using the current directory's "repo"
This commit is contained in:
parent
a0797a5c0b
commit
7d56be63f3
|
|
@ -10,13 +10,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// "dir" is the default "library directory"
|
// "library" is the default "library directory"
|
||||||
// returns the parsed version of (in order):
|
// returns the parsed version of (in order):
|
||||||
// if "repo" is a URL, the remote contents of that URL
|
// if "repo" is a URL, the remote contents of that URL
|
||||||
// the file "repo"
|
// if "repo" is a relative path like "./repo", that file
|
||||||
// the file "dir/repo"
|
// the file "library/repo"
|
||||||
// (repoName, tagName, man, err)
|
// (repoName, tagName, man, err)
|
||||||
func Fetch(dir, repo string) (string, string, *Manifest2822, error) {
|
func Fetch(library, repo string) (string, string, *Manifest2822, error) {
|
||||||
repoName := path.Base(repo)
|
repoName := path.Base(repo)
|
||||||
tagName := ""
|
tagName := ""
|
||||||
if tagIndex := strings.IndexRune(repoName, ':'); tagIndex > 0 {
|
if tagIndex := strings.IndexRune(repoName, ':'); tagIndex > 0 {
|
||||||
|
|
@ -41,10 +41,14 @@ func Fetch(dir, repo string) (string, string, *Manifest2822, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// try file paths
|
// try file paths
|
||||||
for _, fileName := range []string{
|
filePaths := []string{}
|
||||||
repo,
|
if filepath.IsAbs(repo) || strings.IndexRune(repo, filepath.Separator) >= 0 || strings.IndexRune(repo, '/') >= 0 {
|
||||||
filepath.Join(dir, repo),
|
filePaths = append(filePaths, repo)
|
||||||
} {
|
}
|
||||||
|
if !filepath.IsAbs(repo) {
|
||||||
|
filePaths = append(filePaths, filepath.Join(library, repo))
|
||||||
|
}
|
||||||
|
for _, fileName := range filePaths {
|
||||||
f, err := os.Open(fileName)
|
f, err := os.Open(fileName)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return repoName, tagName, nil, err
|
return repoName, tagName, nil, err
|
||||||
|
|
@ -59,5 +63,5 @@ func Fetch(dir, repo string) (string, string, *Manifest2822, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return repoName, tagName, nil, fmt.Errorf("unable to find a manifest named %q (in %q or as a remote URL)", repo, dir)
|
return repoName, tagName, nil, fmt.Errorf("unable to find a manifest named %q (in %q or as a remote URL)", repo, library)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue