Skip to content
Snippets Groups Projects
Commit ebdf250d authored by Recolic K's avatar Recolic K
Browse files

use pkgVerHint while generating pkgPath

parent 686b3062
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,7 @@ func SyncPackages(nugetConfigPath, localRepoPath string, allDeps []dependencyIte ...@@ -64,7 +64,7 @@ func SyncPackages(nugetConfigPath, localRepoPath string, allDeps []dependencyIte
// | // |
// The pkgName is case in-sensitive. // The pkgName is case in-sensitive.
func GetPackagePathFromName(localRepoPath, pkgName, targetNetVer string) (pkgPath string, err error) { func GetPackagePathFromName(localRepoPath, pkgName, targetNetVer string) (pkgPath string, err error) {
realPkgName, _ := extractPostfixPkgVerFromPkgName(pkgName) // pkgName with pkgVer would be discarded, and be guessed again. realPkgName, pkgVerHint := extractPostfixPkgVerFromPkgName(pkgName) // pkgName with pkgVer should be discarded.
guessBase := localRepoPath + string(os.PathSeparator) + strings.ToLower(realPkgName) guessBase := localRepoPath + string(os.PathSeparator) + strings.ToLower(realPkgName)
files, err := ioutil.ReadDir(guessBase + string(os.PathSeparator)) files, err := ioutil.ReadDir(guessBase + string(os.PathSeparator))
if err != nil { if err != nil {
...@@ -74,6 +74,10 @@ func GetPackagePathFromName(localRepoPath, pkgName, targetNetVer string) (pkgPat ...@@ -74,6 +74,10 @@ func GetPackagePathFromName(localRepoPath, pkgName, targetNetVer string) (pkgPat
maxVersion := "" maxVersion := ""
for _, f := range files { for _, f := range files {
if f.IsDir() && pathIsDir(guessBase + string(os.PathSeparator) + f.Name() + string(os.PathSeparator) + "lib" + string(os.PathSeparator) + targetNetVer) { if f.IsDir() && pathIsDir(guessBase + string(os.PathSeparator) + f.Name() + string(os.PathSeparator) + "lib" + string(os.PathSeparator) + targetNetVer) {
if strings.HasPrefix(maxVersion, pkgVerHint) && ! strings.HasPrefix(f.Name(), pkgVerHint) {
// If he matches pkgVerHint but you don't, you have no chance to be a candidate.
continue
}
if version.CompareSimple(f.Name(), maxVersion) >= 0 { if version.CompareSimple(f.Name(), maxVersion) >= 0 {
maxVersion = f.Name() maxVersion = f.Name()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment