Skip to content

Commit

Permalink
fixed GitHub saved token retrieval & PkgError visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wildart committed May 19, 2015
1 parent 09707b5 commit 6d32dd3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions base/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export dir, init, rm, add, available, installed, status, clone, checkout,
const DEFAULT_META = "https://github.com/JuliaLang/METADATA.jl"
const META_BRANCH = "metadata-v2"

type PkgError <: Exception
msg::AbstractString
end

for file in split("git libgit2 dir github types reqs cache read query resolve write generate entry")
include("pkg/$file.jl")
end
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/cache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Cache

import ..LibGit2, ..Dir
import ..LibGit2, ..Dir, Pkg.PkgError
using ..Types

path(pkg::AbstractString) = abspath(".cache", pkg)
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Dir

import ..Pkg: DEFAULT_META, META_BRANCH
import ..Pkg: DEFAULT_META, META_BRANCH, PkgError
import ..LibGit2, ..LibGit2.with

const DIR_NAME = ".julia"
Expand Down
7 changes: 5 additions & 2 deletions base/pkg/github.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module GitHub

import Main, ..LibGit2, ..Dir
import Main, ..LibGit2, ..Dir, ...Pkg.PkgError

const AUTH_NOTE = "Julia Package Manager"
const AUTH_DATA = Dict{Any,Any}(
Expand Down Expand Up @@ -64,7 +64,10 @@ end

function token(user::AbstractString=user())
tokfile = Dir.path(".github","token")
isfile(tokfile) && return strip(readchomp(tokfile))
if isfile(tokfile)
tok = strip(readchomp(tokfile))
!isempty(tok) && return tok
end
status, header, content = curl("https://api.github.com/authorizations",AUTH_DATA,`-u $user`)
tfa = false

Expand Down
2 changes: 1 addition & 1 deletion base/pkg/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Query

import ...Pkg
import ...Pkg.PkgError
using ..Types

function requirements(reqs::Dict, fix::Dict, avail::Dict)
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Read

import ..LibGit2, ..Cache, ..Reqs
import ..LibGit2, ..Cache, ..Reqs, ...Pkg.PkgError
using ..Types

readstrip(path...) = strip(readall(joinpath(path...)))
Expand Down
1 change: 1 addition & 0 deletions base/pkg/reqs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module Reqs

import Pkg.PkgError
using ..Types

# representing lines of REQUIRE files
Expand Down
6 changes: 1 addition & 5 deletions base/pkg/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,4 @@ show(io::IO, f::Fixed) = isempty(f.requires) ?
# Free could include the same information too, it just isn't
# required by anything that processes these things.

type PkgError <: Exception
msg::AbstractString
end

end # module
end # module

0 comments on commit 6d32dd3

Please sign in to comment.