Skip to content

Commit

Permalink
Fix casing for autocomplete of local NuGet feeds - references #1298
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 18, 2016
1 parent 4889818 commit 38214c6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 2.44.6 - 18.01.2016
* BUGFIX: Fix casing for autocomplete of local NuGet feeds - https://github.com/fsprojects/Paket/issues/1298

#### 2.44.5 - 17.01.2016
* Initial support for autocomplete of local NuGet feeds - https://github.com/fsprojects/Paket/issues/1298

Expand Down
5 changes: 4 additions & 1 deletion integrationtests/Paket.IntegrationTests/AutocompleteSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ let ``#1298 should autocomplete for msu on local teamcity``() =
let ``#1298 should autocomplete for dapper on local feed``() =
let result = Dependencies.FindPackagesByName([PackageSource.LocalNuGet(Path.Combine(originalScenarioPath "i001219-props-files", "nuget_repo"))],"dapp")
result |> shouldContain "Dapper"
result |> shouldNotContain "dapper"

[<Test>]
let ``#1298 should autocomplete for fake on local feed``() =
let result = Dependencies.FindPackagesByName([PackageSource.LocalNuGet(Path.Combine(originalScenarioPath "i001219-props-files", "nuget_repo"))],"fake")
result |> shouldContain "fake.core"
result |> shouldContain "FAKE.Core"
result |> shouldNotContain "Dapper"
result |> shouldNotContain "dapper"
Binary file not shown.
16 changes: 14 additions & 2 deletions src/Paket.Core/NuGetV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,20 @@ let findLocalPackage directory (packageName:PackageName) (version:SemVerInfo) =
| None -> failwithf "The package %O %O can't be found in %s.%sPlease check the feed definition in your paket.dependencies file." packageName version directory Environment.NewLine
| Some x -> x

/// Reads package name from a nupkg file
let getPackageNameFromLocalFile fileName =
fixArchive fileName
use zipToCreate = new FileStream(fileName, FileMode.Open, FileAccess.Read)
use zip = new ZipArchive(zipToCreate, ZipArchiveMode.Read)
let zippedNuspec = zip.Entries |> Seq.find (fun f -> f.FullName.EndsWith ".nuspec")
let fileName = FileInfo(Path.Combine(Path.GetTempPath(), zippedNuspec.Name)).FullName
zippedNuspec.ExtractToFile(fileName, true)
let nuspec = Nuspec.Load fileName
File.Delete(fileName)
nuspec.OfficialName

/// Reads direct dependencies from a nupkg file
let getDetailsFromLocalFile root localNugetPath (packageName:PackageName) (version:SemVerInfo) =
let getDetailsFromLocalNuGetPackage root localNugetPath (packageName:PackageName) (version:SemVerInfo) =
async {
let localNugetPath = Utils.normalizeLocalPath localNugetPath
let di = getDirectoryInfo localNugetPath root
Expand Down Expand Up @@ -477,7 +489,7 @@ let GetPackageDetails root force (sources:PackageSource list) packageName (versi
let! result = NuGetV3.GetPackageDetails force nugetSource packageName version
return Some(source,result)
| LocalNuGet path ->
let! result = getDetailsFromLocalFile root path packageName version
let! result = getDetailsFromLocalNuGetPackage root path packageName version
return Some(source,result)
with e ->
verbosefn "Source '%O' exception: %O" source e
Expand Down
12 changes: 5 additions & 7 deletions src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,15 @@ type Dependencies(dependenciesFileName: string) =
| NuGetV3 s -> Some(NuGetV3.FindPackages(s.Authentication, s.Url, searchTerm, maxResults))
| LocalNuGet s ->
Some(async {
let a =
return
Fake.Globbing.search s (sprintf "**/*%s*" searchTerm)
|> List.map (fun s ->
|> List.distinctBy (fun s ->
let parts = FileInfo(s).Name.Split('.')
let nameParts = parts |> Seq.takeWhile (fun x -> x <> "nupkg" && System.Int32.TryParse x |> fst |> not)
String.Join(".",nameParts))
String.Join(".",nameParts).ToLower())
|> List.map NuGetV2.getPackageNameFromLocalFile
|> List.toArray

return a
})
| _ -> None)
}))

static member FindPackagesByName(sources:PackageSource seq,searchTerm,?maxResults) =
let maxResults = defaultArg maxResults 1000
Expand Down

0 comments on commit 38214c6

Please sign in to comment.