Skip to content

Commit a76c51a

Browse files
committed
Allow to add package when sources are splitted - references fsprojects/Paket.VisualStudio#137
1 parent aef6573 commit a76c51a

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎RELEASE_NOTES.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#### 3.36.2 - 13.03.2017
2+
* BUGFIX: Allow to add package when sources are splitted - https://github.com/fsprojects/Paket.VisualStudio/issues/137
3+
14
#### 3.36.1 - 03.03.2017
25
* USABILITY: old bootstrapper did not work
36

‎src/Paket.Core/DependenciesFile.fs‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
246246
let packageString = DependenciesFileSerializer.packageString packageName versionRequirement resolverStrategy settings
247247

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

259+
let sourceCount =
260+
match groups |> Map.tryFind groupName with
261+
| None -> 0
262+
| Some group ->
263+
match group.Sources with
264+
| [] -> 0
265+
| sources -> group.Sources |> Seq.length
266+
267+
259268
let smaller =
260269
match groups |> Map.tryFind groupName with
261270
| None -> []
262271
| Some group ->
263272
group.Packages
264-
|> Seq.takeWhile (fun (p:PackageRequirement) -> p.Name <= packageName || not (isPackageInLastSource p))
273+
|> Seq.takeWhile (fun (p:PackageRequirement) -> p.Name <= packageName || not isPackageInLastSource)
265274
|> List.ofSeq
266275

267276
let list = new System.Collections.Generic.List<_>()
@@ -287,7 +296,7 @@ type DependenciesFile(fileName,groups:Map<GroupName,DependenciesGroup>, textRepr
287296
list.Insert(pos + 1, packageString)
288297
| None ->
289298
let firstGroupLine,lastGroupLine = findGroupBorders groupName
290-
if pinDown then
299+
if pinDown || sourceCount > 1 then
291300
if newGroupInserted then
292301
list.Add(packageString)
293302
else

0 commit comments

Comments
 (0)