Skip to content

Commit

Permalink
Respect comments in dependencies file
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 22, 2016
1 parent 6d8f182 commit 61955b6
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 26 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.9.1 - 22.07.2016
* Respect comments in dependencies file

#### 3.9.0 - 22.07.2016
* Don't create runtime references for CoreClr anymore - new concept coming soon
* BUGFIX: Allow to install packages that have "native" in package name - https://github.com/fsprojects/Paket/issues/1829
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ let ``#220 should respect the == operator``() =
let ``#263 should respect SemVer prereleases``() =
let lockFile = update "i000263-semver-prereleases"
lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[PackageName "Ninject"].Version
|> shouldEqual (SemVer.Parse "3.2.3-unstable-001")
|> shouldEqual (SemVer.Parse "3.2.3-unstable-001")

[<Test>]
let ``#263 should respect prereleases``() =
let lockFile = update "i000263-prereleases"
lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[PackageName "Ninject"].Version
|> shouldBeGreaterThan (SemVer.Parse "3.2.3-unstable-011")

[<Test>]
let ``#299 should restore package ending in lib``() =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source http://nuget.org/api/v2

nuget Ninject >= 3.2.3 prerelease #clever comment goes here
10 changes: 5 additions & 5 deletions src/Paket.Bootstrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
[assembly: AssemblyTitleAttribute("Paket.Bootstrapper")]
[assembly: AssemblyProductAttribute("Paket")]
[assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")]
[assembly: AssemblyVersionAttribute("3.9.0")]
[assembly: AssemblyFileVersionAttribute("3.9.0")]
[assembly: AssemblyInformationalVersionAttribute("3.9.0")]
[assembly: AssemblyVersionAttribute("3.9.1")]
[assembly: AssemblyFileVersionAttribute("3.9.1")]
[assembly: AssemblyInformationalVersionAttribute("3.9.1")]
namespace System {
internal static class AssemblyVersionInformation {
internal const string Version = "3.9.0";
internal const string InformationalVersion = "3.9.0";
internal const string Version = "3.9.1";
internal const string InformationalVersion = "3.9.1";
}
}
10 changes: 5 additions & 5 deletions src/Paket.Core/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")>]
[<assembly: AssemblyVersionAttribute("3.9.0")>]
[<assembly: AssemblyFileVersionAttribute("3.9.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.9.0")>]
[<assembly: AssemblyVersionAttribute("3.9.1")>]
[<assembly: AssemblyFileVersionAttribute("3.9.1")>]
[<assembly: AssemblyInformationalVersionAttribute("3.9.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.9.0"
let [<Literal>] InformationalVersion = "3.9.0"
let [<Literal>] Version = "3.9.1"
let [<Literal>] InformationalVersion = "3.9.1"
1 change: 1 addition & 0 deletions src/Paket.Core/BindingRedirects.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ let private createAppConfigInDirectory folder =
let private getProjectFilesInDirectory folder =
Directory.GetFiles(folder, "*proj")
|> Seq.filter (Path.GetExtension >> isDotNetProject)

let private addConfigFileToProject project =
project.ProjectNode
|> Xml.getNodes "ItemGroup"
Expand Down
27 changes: 22 additions & 5 deletions src/Paket.Core/DependenciesFileParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,24 @@ module DependenciesFileParser =
| Cache of Cache

let private (|Remote|Package|Empty|ParserOptions|SourceFile|Git|Group|) (line:string) =
match line.Trim() with
let trimmed = line.Trim()

let removeComment (text:string) =
match text.IndexOf("//") with
| -1 ->
match text.IndexOf("#") with
| -1 -> text
| p ->
let f = text.Substring(0,p).Trim()
printfn "%s" f

This comment has been minimized.

Copy link
@fsoikin

fsoikin Jun 30, 2017

Contributor

Sorry to bother, but I can't figure this out on my own: is this statement somehow needed, or is it just debug output accidentally left in?

This comment has been minimized.

Copy link
@forki

forki Jun 30, 2017

Author Member

Please send a pull request which removes it. Looks like accident

This comment has been minimized.

Copy link
@fsoikin

fsoikin Jun 30, 2017

Contributor

Yep, I was just going to remove it. Just needed to make sure.

f
| p ->
let f = text.Substring(0,p).Trim()
printfn "%s" f
f


match trimmed with
| _ when String.IsNullOrWhiteSpace line -> Empty(line)
| String.StartsWith "source" _ as trimmed -> Remote(RemoteParserOption.PackageSource(PackageSource.Parse(trimmed)))
| String.StartsWith "cache" _ as trimmed -> Remote(RemoteParserOption.Cache(Cache.Parse(trimmed)))
Expand All @@ -222,13 +239,13 @@ module DependenciesFileParser =
match parts with
| name :: operator1 :: version1 :: operator2 :: version2 :: rest
when List.exists ((=) operator1) operators && List.exists ((=) operator2) operators ->
Package(name,operator1 + " " + version1 + " " + operator2 + " " + version2, String.Join(" ",rest))
Package(name,operator1 + " " + version1 + " " + operator2 + " " + version2, String.Join(" ",rest) |> removeComment)
| name :: operator :: version :: rest
when List.exists ((=) operator) operators ->
Package(name,operator + " " + version, String.Join(" ",rest))
Package(name,operator + " " + version, String.Join(" ",rest) |> removeComment)
| name :: version :: rest when isVersion version ->
Package(name,version,String.Join(" ",rest))
| name :: rest -> Package(name,">= 0", String.Join(" ",rest))
Package(name,version,String.Join(" ",rest) |> removeComment)
| name :: rest -> Package(name,">= 0", String.Join(" ",rest) |> removeComment)
| [name] -> Package(name,">= 0","")
| _ -> failwithf "could not retrieve NuGet package from %s" trimmed
| String.StartsWith "references" trimmed -> ParserOptions(ParserOption.ReferencesMode(trimmed.Replace(":","").Trim() = "strict"))
Expand Down
10 changes: 5 additions & 5 deletions src/Paket.PowerShell/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")>]
[<assembly: AssemblyVersionAttribute("3.9.0")>]
[<assembly: AssemblyFileVersionAttribute("3.9.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.9.0")>]
[<assembly: AssemblyVersionAttribute("3.9.1")>]
[<assembly: AssemblyFileVersionAttribute("3.9.1")>]
[<assembly: AssemblyInformationalVersionAttribute("3.9.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.9.0"
let [<Literal>] InformationalVersion = "3.9.0"
let [<Literal>] Version = "3.9.1"
let [<Literal>] InformationalVersion = "3.9.1"
10 changes: 5 additions & 5 deletions src/Paket/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ open System.Reflection
[<assembly: AssemblyProductAttribute("Paket")>]
[<assembly: AssemblyCompanyAttribute("Paket team")>]
[<assembly: AssemblyDescriptionAttribute("A dependency manager for .NET with support for NuGet packages and git repositories.")>]
[<assembly: AssemblyVersionAttribute("3.9.0")>]
[<assembly: AssemblyFileVersionAttribute("3.9.0")>]
[<assembly: AssemblyInformationalVersionAttribute("3.9.0")>]
[<assembly: AssemblyVersionAttribute("3.9.1")>]
[<assembly: AssemblyFileVersionAttribute("3.9.1")>]
[<assembly: AssemblyInformationalVersionAttribute("3.9.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "3.9.0"
let [<Literal>] InformationalVersion = "3.9.0"
let [<Literal>] Version = "3.9.1"
let [<Literal>] InformationalVersion = "3.9.1"
16 changes: 16 additions & 0 deletions tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ let ``should read simple config``() =
cfg.GetDependenciesInGroup(Constants.MainDependencyGroup).[PackageName "FAKE"].Range |> shouldEqual (VersionRange.Exactly "1.1")
cfg.GetDependenciesInGroup(Constants.MainDependencyGroup).[PackageName "SignalR"].Range |> shouldEqual (VersionRange.Exactly "3.3.2")

let configWithComment = """
source "http://www.nuget.org/api/v2"
nuget Castle.Windsor-log4net >= 3.2 prerelease # test
"""

[<Test>]
let ``should read simple config with prerelease and comment``() =
let cfg = DependenciesFile.FromCode(configWithComment)
cfg.Groups.[Constants.MainDependencyGroup].Options.Strict |> shouldEqual false

let packageDefinition = cfg.GetDependenciesInGroup(Constants.MainDependencyGroup).[PackageName "Castle.Windsor-log4net"]
packageDefinition.Range |> shouldEqual (VersionRange.AtLeast("3.2"))
packageDefinition.PreReleases |> shouldEqual (PreReleaseStatus.All)


let config2 = """
source "http://www.nuget.org/api/v2"
Expand Down

0 comments on commit 61955b6

Please sign in to comment.