Skip to content

Commit

Permalink
Allow to add package when sources are splitted - references fsproject…
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Mar 13, 2017
1 parent aef6573 commit a76c51a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 3.36.2 - 13.03.2017
* BUGFIX: Allow to add package when sources are splitted - https://github.com/fsprojects/Paket.VisualStudio/issues/137

#### 3.36.1 - 03.03.2017
* USABILITY: old bootstrapper did not work

Expand Down
15 changes: 12 additions & 3 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
let packageString = DependenciesFileSerializer.packageString packageName versionRequirement resolverStrategy settings

// Try to find alphabetical matching position to insert the package
let isPackageInLastSource (p:PackageRequirement) =
let isPackageInLastSource =
match groups |> Map.tryFind groupName with
| None -> true
| Some group ->
Expand All @@ -256,12 +256,21 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
let lastSource = Seq.last sources
group.Sources |> Seq.exists (fun s -> s = lastSource)

let sourceCount =
match groups |> Map.tryFind groupName with
| None -> 0
| Some group ->
match group.Sources with
| [] -> 0
| sources -> group.Sources |> Seq.length


let smaller =
match groups |> Map.tryFind groupName with
| None -> []
| Some group ->
group.Packages
|> Seq.takeWhile (fun (p:PackageRequirement) -> p.Name <= packageName || not (isPackageInLastSource p))
|> Seq.takeWhile (fun (p:PackageRequirement) -> p.Name <= packageName || not isPackageInLastSource)
|> List.ofSeq

let list = new System.Collections.Generic.List<_>()
Expand All @@ -287,7 +296,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
list.Insert(pos + 1, packageString)
| None ->
let firstGroupLine,lastGroupLine = findGroupBorders groupName
if pinDown then
if pinDown || sourceCount > 1 then
if newGroupInserted then
list.Add(packageString)
else
Expand Down

0 comments on commit a76c51a

Please sign in to comment.