Skip to content

Commit

Permalink
Merge pull request #1089 from klettier/master
Browse files Browse the repository at this point in the history
Fix case sensitivity on package name when search references in Paket.lock
  • Loading branch information
forki committed Jan 21, 2016
2 parents 627d687 + a574b27 commit ff46eb1
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions src/app/FakeLib/PaketHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Fake.Paket
open System
open System.IO
open System.Xml.Linq
open System.Text.RegularExpressions

/// Paket pack parameter type
type PaketPackParams =
Expand Down Expand Up @@ -145,33 +146,36 @@ let Push setParams =

/// Returns the dependencies from specified paket.references file
let GetDependenciesForReferencesFile (referencesFile:string) =
let isSingleFile (line: string) = line.StartsWith "File:"
let isGroupLine (line: string) = line.StartsWith "group "
let notEmpty (line: string) = not <| String.IsNullOrWhiteSpace line
let parsePackageName (line: string) =
let parts = line.Split(' ')
parts.[0]

let nugetLines =
File.ReadAllLines(referencesFile)
|> Array.filter notEmpty
|> Array.map (fun s -> s.Trim())
|> Array.filter (isSingleFile >> not)
|> Array.filter (isGroupLine >> not)
|> Array.map parsePackageName

let lockFile =
let rec find dir =
let fi = FileInfo(dir </> "paket.lock")
if fi.Exists then fi.FullName else find fi.Directory.Parent.FullName
find <| FileInfo(referencesFile).Directory.FullName

let lines = File.ReadAllLines(lockFile)

let getVersion package =
let line = lines |> Array.find (fun l -> l.StartsWith(" " + package))
let start = line.Replace(" " + package + " (","")
start.Substring(0,start.IndexOf(")"))

nugetLines
|> Array.map (fun p -> p,getVersion p)
let getReferenceFilePackages =
let isSingleFile (line: string) = line.StartsWith "File:"
let isGroupLine (line: string) = line.StartsWith "group "
let notEmpty (line: string) = not <| String.IsNullOrWhiteSpace line
let parsePackageName (line: string) =
let parts = line.Split(' ')
parts.[0]
File.ReadAllLines
>> Array.filter notEmpty
>> Array.map (fun s -> s.Trim())
>> Array.filter (isSingleFile >> not)
>> Array.filter (isGroupLine >> not)
>> Array.map parsePackageName

let getLockFilePackages =
let getPaketLockFile referencesFile =
let rec find dir =
let fi = FileInfo(dir </> "paket.lock")
if fi.Exists then fi.FullName else find fi.Directory.Parent.FullName
find <| FileInfo(referencesFile).Directory.FullName

let breakInParts (line : string) = match Regex.Match(line,"^[ ]{4}([^ ].+) \((.+)\)") with
| m when m.Success && m.Groups.Count = 3 -> Some (m.Groups.[1].Value, m.Groups.[2].Value)
| _ -> None

getPaketLockFile
>> File.ReadAllLines
>> Array.choose breakInParts

let refLines = getReferenceFilePackages referencesFile

getLockFilePackages referencesFile
|> Array.filter (fun (n, _) -> refLines |> Array.exists (fun pn -> pn.Equals(n, StringComparison.InvariantCultureIgnoreCase)))

0 comments on commit ff46eb1

Please sign in to comment.