Skip to content

Commit

Permalink
paket install correctly parses HTTP references - references #571
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Feb 6, 2015
1 parent fce21c3 commit 574ef30
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
5 changes: 3 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#### 0.27.0-alpha005 - 03.02.2015
#### 0.27.0-alpha006 - 03.02.2015
* Allow to reference `.props` and `.targets` files - https://github.com/fsprojects/Paket/issues/516
* Create a install function in the api which takes a `paket.dependencies` file as text - https://github.com/fsprojects/Paket/issues/576
* Don't internalize in paket.exe during ILMerge
* Allow to download from pre-authenticated MyGet feed - https://github.com/fsprojects/Paket/issues/466
* BUGFIX: Fix `paket install --hard` for FSharp.Core - https://github.com/fsprojects/Paket/issues/579
* BUGFIX: `paket convert-from-nuget]`` ignore case when looking for nuget.targets - https://github.com/fsprojects/Paket/issues/580
* BUGFIX: `paket convert-from-nuget` ignores casing when looking for nuget.targets - https://github.com/fsprojects/Paket/issues/580
* BUGFIX: `paket install` correctly parses HTTP references - https://github.com/fsprojects/Paket/pull/571
* COSMETICS: Prerelease strings are checked if they contain operators

#### 0.26.0 - 31.01.2015
Expand Down
27 changes: 20 additions & 7 deletions src/Paket.Core/LockFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,22 @@ module LockFileParser =
| HttpLink x ->
match state.RemoteUrl |> Option.map(fun s -> s.Split '/' |> Array.toList) with
| Some [ protocol; _; domain; ] ->
let name, path =
match details.Split ' ' with
| [| filePath; path |] -> filePath, path |> removeBrackets
| _ -> failwith "invalid file source details."

let sourceFile =
{ Commit = String.Empty
Owner = domain
Origin = HttpLink(state.RemoteUrl.Value + path)
Project = domain
Dependencies = Set.empty
Name = name }

{ state with
LastWasPackage = false
SourceFiles = { Commit = String.Empty
Owner = domain
Origin = HttpLink(state.RemoteUrl.Value)
Project = domain
Dependencies = Set.empty
Name = details } :: state.SourceFiles }
SourceFiles = sourceFile :: state.SourceFiles }
| Some [ protocol; _; domain; project ] ->
{ state with
LastWasPackage = false
Expand Down Expand Up @@ -358,7 +366,12 @@ type LockFile(fileName:string,options,resolution:PackageResolution,remoteFiles:R
/// Parses a paket.lock file from lines
static member Parse(lockFileName,lines) : LockFile =
LockFileParser.Parse lines
|> fun state -> LockFile(lockFileName, state.Options ,state.Packages |> Seq.fold (fun map p -> Map.add (NormalizedPackageName p.Name) p map) Map.empty, List.rev state.SourceFiles)
|> fun state ->
LockFile(
lockFileName,
state.Options,
state.Packages |> Seq.fold (fun map p -> Map.add (NormalizedPackageName p.Name) p map) Map.empty,
List.rev state.SourceFiles)

member this.GetPackageHull(referencesFile:ReferencesFile) =
let usedPackages = Dictionary<_,_>()
Expand Down
37 changes: 35 additions & 2 deletions tests/Paket.Tests/Lockfile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,31 @@ let ``should parse simple http reference``() =
references.[0].Name |> shouldEqual "ikvmbin-8.0.5449.0.zip"
references.[0].Origin |> shouldEqual (SingleSourceFileOrigin.HttpLink("http://www.frijters.net/ikvmbin-8.0.5449.0.zip"))


let lockFileForStanfordNLPdotNET = """HTTP
remote: http://www.frijters.net
specs:
ikvmbin-8.0.5449.0.zip (/ikvmbin-8.0.5449.0.zip)
remote: http://nlp.stanford.edu
specs:
stanford-corenlp-full-2014-10-31.zip (/software/stanford-corenlp-full-2014-10-31.zip)
stanford-ner-2014-10-26.zip (/software/stanford-ner-2014-10-26.zip)
stanford-parser-full-2014-10-31.zip (/software/stanford-parser-full-2014-10-31.zip)
stanford-postagger-full-2014-10-26.zip (/software/stanford-postagger-full-2014-10-26.zip)
stanford-segmenter-2014-10-26.zip (/software/stanford-segmenter-2014-10-26.zip)"""

[<Test>]
let ``should parse lock file for http Stanford.NLP.NET project``() =
let lockFile = LockFileParser.Parse(toLines lockFileForStanfordNLPdotNET)
let references = lockFile.SourceFiles

references.Length |> shouldEqual 6

references.[0].Origin |> shouldEqual (SingleSourceFileOrigin.HttpLink("http://nlp.stanford.edu/software/stanford-segmenter-2014-10-26.zip"))
references.[0].Name |> shouldEqual "stanford-segmenter-2014-10-26.zip"

()

let realWorldHTTP = """
NUGET
remote: https://nuget.org/api/v2
Expand Down Expand Up @@ -308,12 +333,20 @@ HTTP
remote: http://www.w3.org/2013/N-QuadsTests/TESTS.zip
specs:
TESTS.zip
remote: https://gist.githubusercontent.com
specs:
paket.txt (/JonCanning/37769e635aaece6dcef3/raw/adffa54dd02f94e5b06667700ef44e1a5feded73/paket.txt)
"""

[<Test>]
let ``should parse real world http reference``() =
let lockFile = LockFileParser.Parse(toLines realWorldHTTP)
let references = lockFile.SourceFiles

references.[0].Name |> shouldEqual "TESTS.zip"
references.[0].Origin |> shouldEqual (SingleSourceFileOrigin.HttpLink("http://www.w3.org/2013/N-QuadsTests/TESTS.zip"))
references.Length |> shouldEqual 3

references.[0].Origin |> shouldEqual (SingleSourceFileOrigin.HttpLink("https://gist.githubusercontent.com/JonCanning/37769e635aaece6dcef3/raw/adffa54dd02f94e5b06667700ef44e1a5feded73/paket.txt"))
references.[0].Name |> shouldEqual "paket.txt"

references.[1].Name |> shouldEqual "TESTS.zip"
references.[1].Origin |> shouldEqual (SingleSourceFileOrigin.HttpLink("http://www.w3.org/2013/N-QuadsTests/TESTS.zip"))

0 comments on commit 574ef30

Please sign in to comment.