Skip to content

Commit

Permalink
Detect the version of a GitHub gist correctly - fixes #499
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 2, 2015
1 parent 348c0d1 commit 58953ef
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 0.20.14 - 02.01.2015
* BUGFIX: Detect the version of a GitHub gist correctly - https://github.com/fsprojects/Paket/issues/499

#### 0.20.13 - 02.01.2015
* Do not fail on BadCrcException during unzip and only show a warning - https://github.com/fsprojects/Paket/issues/484

Expand Down
3 changes: 2 additions & 1 deletion src/Paket.Core/LockFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ module LockFileSerializer =
let path = file.Name.TrimStart '/'
match String.IsNullOrEmpty(file.Commit) with
| false -> yield sprintf " %s (%s)" path file.Commit
| true -> yield sprintf " %s" path
| true -> yield sprintf " %s" path

for (PackageName name,v) in file.Dependencies do
let versionStr =
let s = v.ToString()
Expand Down
18 changes: 8 additions & 10 deletions src/Paket.Core/ModuleResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,21 @@ type UnresolvedSourceFile =
| Some commit -> sprintf "%s %s/%s:%s%s" link this.Owner this.Project commit name
| None -> sprintf "%s %s/%s%s" link this.Owner this.Project name


type ResolvedSourceFile =
type ResolvedSourceFile =
{ Owner : string
Project : string
Name : string
Name : string
Commit : string
Dependencies : Set<PackageName*VersionRequirement>
Origin : SingleSourceFileOrigin
}
member this.FilePath = this.ComputeFilePath(this.Name)
Dependencies : Set<PackageName * VersionRequirement>
Origin : SingleSourceFileOrigin }

member this.ComputeFilePath(name:string) =
member this.FilePath = this.ComputeFilePath(this.Name)

member this.ComputeFilePath(name : string) =
let path = normalizePath (name.TrimStart('/'))

let di = DirectoryInfo(Path.Combine(Constants.PaketFilesFolderName, this.Owner, this.Project, path))
di.FullName

override this.ToString() = sprintf "%s/%s:%s %s" this.Owner this.Project this.Commit this.Name

let private getCommit (file : UnresolvedSourceFile) = defaultArg file.Commit "master"
Expand Down
3 changes: 2 additions & 1 deletion src/Paket.Core/RemoteDownload.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ let getSHA1OfBranch origin owner project branch =
let url = sprintf "https://api.github.com/gists/%s/%s" project branch
let! document = getFromUrl(None, url)
let json = JObject.Parse(document)
return json.["id"].ToString()
let latest = json.["history"].First.["version"]
return latest.ToString()
| ModuleResolver.SingleSourceFileOrigin.HttpLink _ -> return ""
}

Expand Down
2 changes: 1 addition & 1 deletion src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<DocumentationFile>
</DocumentationFile>
<StartArguments>update -f</StartArguments>
<StartArguments>add nuget nhibernate</StartArguments>
<StartArguments>update -f</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>
Expand Down
15 changes: 15 additions & 0 deletions tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,21 @@ let ``should read gist source file from config without quotes with file specs``(
Origin = ModuleResolver.SingleSourceFileOrigin.GistLink
Commit = None } ]

[<Test>]
let ``should read gist source file``() =
let config = """source https://www.nuget.org/api/v2
nuget JetBrainsAnnotations.Fody
gist misterx/5d9c6983004c1c9ec91f"""
let dependencies = DependenciesFile.FromCode(config)
dependencies.RemoteFiles
|> shouldEqual
[ { Owner = "misterx"
Project = "5d9c6983004c1c9ec91f"
Name = "FULLPROJECT"
Origin = ModuleResolver.SingleSourceFileOrigin.GistLink
Commit = None } ]

[<Test>]
let ``should read http source file from config without quotes, parsing rules``() =
Expand Down

0 comments on commit 58953ef

Please sign in to comment.