Skip to content

Commit

Permalink
Detect with magic unlisting date - references #327
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Nov 6, 2014
1 parent 33f4491 commit 1ff5bd8
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 51 deletions.
5 changes: 4 additions & 1 deletion src/Paket.Core/Constants.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ let ProjectDefaultNameSpace = "http://schemas.microsoft.com/developer/msbuild/20

let AppDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

let PaketConfigFolder = Path.Combine(AppDataFolder, "Paket")
let PaketConfigFolder = Path.Combine(AppDataFolder, "Paket")

/// The magic unpublished date is 1900-01-01T00:00:00
let MagicUnlistingDate = DateTimeOffset(1900, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8.)).DateTime
12 changes: 10 additions & 2 deletions src/Paket.Core/Nuget.fs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ let getODataDetails nugetURL raw =
}
|> Seq.head

let publishDate =
match [ for node in doc.SelectNodes("//ns:entry/m:properties/d:Published", manager) -> node.InnerText] with
| id::_ ->
match DateTime.TryParse id with
| true,date -> date
| _ -> DateTime.MinValue
| [] -> DateTime.MinValue

let downloadLink =
seq {
for node in doc.SelectNodes("//ns:entry/ns:content", manager) do
Expand All @@ -146,12 +154,12 @@ let getODataDetails nugetURL raw =
DownloadUrl = downloadLink
Dependencies = packages
SourceUrl = nugetURL
Unlisted = false }
Unlisted = publishDate = Constants.MagicUnlistingDate }

/// Gets package details from Nuget via OData
let getDetailsFromNugetViaOData auth nugetURL package version =
async {
let! raw = getFromUrl(auth,sprintf "%s/Packages(Id='%s',Version='%s')" nugetURL package version)
let! raw = getFromUrl(auth,sprintf "%s/Packages?$filter=Id eq '%s' and Version eq '%s'" nugetURL package version)
return getODataDetails nugetURL raw
}

Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<DocumentationFile>..\..\bin\Paket.xml</DocumentationFile>
<StartArguments>update --hard</StartArguments>
<StartArguments>update -f</StartArguments>
<StartWorkingDirectory>D:\code\paketkopie</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/Paket.Tests/NuGetOData/ODataSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ let ``can detect explicit dependencies for Rx-PlaformServices``() =
parse "NuGetOData/Rx-PlatformServices.xml"
|> shouldEqual
{ Name = "Rx-PlatformServices"
DownloadUrl = "http://www.nuget.org/api/v2/package/Rx-PlatformServices/2.3.0"
DownloadUrl = "https://www.nuget.org/api/v2/package/Rx-PlatformServices/2.3.0"
Dependencies = ["Rx-Interfaces",DependenciesFileParser.parseVersionRequirement(">= 2.2"), None
"Rx-Core",DependenciesFileParser.parseVersionRequirement(">= 2.2"), None]
Unlisted = false
Unlisted = true
SourceUrl = fakeUrl }

[<Test>]
Expand Down
96 changes: 51 additions & 45 deletions tests/Paket.Tests/NuGetOData/Rx-PlatformServices.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="http://www.nuget.org/api/v2/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>http://www.nuget.org/api/v2/Packages(Id='Rx-PlatformServices',Version='2.3')</id>
<category term="NuGetGallery.V2FeedPackage" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="V2FeedPackage" href="Packages(Id='Rx-PlatformServices',Version='2.3')" />
<title type="text">Rx-PlatformServices</title>
<summary type="text"></summary>
<updated>2014-08-21T19:17:53Z</updated>
<author>
<name>Microsoft</name>
</author>
<link rel="edit-media" title="V2FeedPackage" href="Packages(Id='Rx-PlatformServices',Version='2.3')/$value" />
<content type="application/zip" src="http://www.nuget.org/api/v2/package/Rx-PlatformServices/2.3.0" />
<m:properties>
<d:Version>2.3</d:Version>
<d:NormalizedVersion>2.3.0</d:NormalizedVersion>
<d:Copyright>Copyright (C) Microsoft Corporation</d:Copyright>
<d:Created m:type="Edm.DateTime">2014-01-27T19:28:43.397</d:Created>
<d:Dependencies>Rx-Interfaces:2.2:|Rx-Core:2.2:</d:Dependencies>
<d:Description>Reactive Extensions Platform Services Library used to access platform-specific functionality and enlightenment services.</d:Description>
<d:DownloadCount m:type="Edm.Int32">260453</d:DownloadCount>
<d:GalleryDetailsUrl>http://www.nuget.org/packages/Rx-PlatformServices/2.3.0</d:GalleryDetailsUrl>
<d:IconUrl>http://go.microsoft.com/fwlink/?LinkId=261274</d:IconUrl>
<d:IsLatestVersion m:type="Edm.Boolean">false</d:IsLatestVersion>
<d:IsAbsoluteLatestVersion m:type="Edm.Boolean">false</d:IsAbsoluteLatestVersion>
<d:IsPrerelease m:type="Edm.Boolean">false</d:IsPrerelease>
<d:Language>en-US</d:Language>
<d:Published m:type="Edm.DateTime">2014-01-27T19:28:43.397</d:Published>
<d:PackageHash>H3aiFtRAsdG2mN5O6p/tvOiDbRRISYEQAnTDJGheX9Kmal0YS3txJbqlOuOtJB6XbkVA7/vtvdsWDswSKItFyA==</d:PackageHash>
<d:PackageHashAlgorithm>SHA512</d:PackageHashAlgorithm>
<d:PackageSize m:type="Edm.Int64">196416</d:PackageSize>
<d:ProjectUrl>http://go.microsoft.com/fwlink/?LinkId=261273</d:ProjectUrl>
<d:ReportAbuseUrl>http://www.nuget.org/package/ReportAbuse/Rx-PlatformServices/2.3.0</d:ReportAbuseUrl>
<d:ReleaseNotes m:null="true" />
<d:RequireLicenseAcceptance m:type="Edm.Boolean">true</d:RequireLicenseAcceptance>
<d:Summary m:null="true" />
<d:Tags>Rx Reactive Extensions Observable LINQ Events</d:Tags>
<d:Title>Reactive Extensions - Platform Services Library</d:Title>
<d:VersionDownloadCount m:type="Edm.Int32">357</d:VersionDownloadCount>
<d:MinClientVersion m:null="true" />
<d:LastEdited m:type="Edm.DateTime">2014-01-27T19:32:41.41</d:LastEdited>
<d:LicenseUrl>http://go.microsoft.com/fwlink/?LinkID=261272</d:LicenseUrl>
<d:LicenseNames>MS-EULA</d:LicenseNames>
<d:LicenseReportUrl></d:LicenseReportUrl>
</m:properties>
</entry>
<feed xml:base="https://www.nuget.org/api/v2/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>https://www.nuget.org/api/v2/Packages</id>
<title type="text">Packages</title>
<updated>2014-11-06T18:43:44Z</updated>
<link rel="self" title="Packages" href="Packages" />
<entry>
<id>https://www.nuget.org/api/v2/Packages(Id='Rx-PlatformServices',Version='2.3')</id>
<category term="NuGetGallery.V2FeedPackage" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" title="V2FeedPackage" href="Packages(Id='Rx-PlatformServices',Version='2.3')" />
<title type="text">Rx-PlatformServices</title>
<summary type="text"></summary>
<updated>2014-11-06T16:07:51Z</updated>
<author>
<name>Microsoft</name>
</author>
<link rel="edit-media" title="V2FeedPackage" href="Packages(Id='Rx-PlatformServices',Version='2.3')/$value" />
<content type="application/zip" src="https://www.nuget.org/api/v2/package/Rx-PlatformServices/2.3.0" />
<m:properties>
<d:Version>2.3</d:Version>
<d:NormalizedVersion>2.3.0</d:NormalizedVersion>
<d:Copyright>Copyright (C) Microsoft Corporation</d:Copyright>
<d:Created m:type="Edm.DateTime">2014-01-27T19:28:43.397</d:Created>
<d:Dependencies>Rx-Interfaces:2.2:|Rx-Core:2.2:</d:Dependencies>
<d:Description>Reactive Extensions Platform Services Library used to access platform-specific functionality and enlightenment services.</d:Description>
<d:DownloadCount m:type="Edm.Int32">262798</d:DownloadCount>
<d:GalleryDetailsUrl>https://www.nuget.org/packages/Rx-PlatformServices/2.3.0</d:GalleryDetailsUrl>
<d:IconUrl>http://go.microsoft.com/fwlink/?LinkId=261274</d:IconUrl>
<d:IsLatestVersion m:type="Edm.Boolean">false</d:IsLatestVersion>
<d:IsAbsoluteLatestVersion m:type="Edm.Boolean">false</d:IsAbsoluteLatestVersion>
<d:IsPrerelease m:type="Edm.Boolean">false</d:IsPrerelease>
<d:Language>en-US</d:Language>
<d:Published m:type="Edm.DateTime">1900-01-01T00:00:00</d:Published>
<d:PackageHash>H3aiFtRAsdG2mN5O6p/tvOiDbRRISYEQAnTDJGheX9Kmal0YS3txJbqlOuOtJB6XbkVA7/vtvdsWDswSKItFyA==</d:PackageHash>
<d:PackageHashAlgorithm>SHA512</d:PackageHashAlgorithm>
<d:PackageSize m:type="Edm.Int64">196416</d:PackageSize>
<d:ProjectUrl>http://go.microsoft.com/fwlink/?LinkId=261273</d:ProjectUrl>
<d:ReportAbuseUrl>https://www.nuget.org/package/ReportAbuse/Rx-PlatformServices/2.3.0</d:ReportAbuseUrl>
<d:ReleaseNotes m:null="true" />
<d:RequireLicenseAcceptance m:type="Edm.Boolean">true</d:RequireLicenseAcceptance>
<d:Summary m:null="true" />
<d:Tags>Rx Reactive Extensions Observable LINQ Events</d:Tags>
<d:Title>Reactive Extensions - Platform Services Library</d:Title>
<d:VersionDownloadCount m:type="Edm.Int32">363</d:VersionDownloadCount>
<d:MinClientVersion m:null="true" />
<d:LastEdited m:type="Edm.DateTime">2014-01-27T19:32:41.41</d:LastEdited>
<d:LicenseUrl>http://go.microsoft.com/fwlink/?LinkID=261272</d:LicenseUrl>
<d:LicenseNames>MS-EULA</d:LicenseNames>
<d:LicenseReportUrl></d:LicenseReportUrl>
</m:properties>
</entry>
</feed>

0 comments on commit 1ff5bd8

Please sign in to comment.