Skip to content

Commit

Permalink
hopefully more robust way of getting github URL (don't assume module …
Browse files Browse the repository at this point in the history
…name is Pkg name)
  • Loading branch information
stevengj committed Dec 22, 2013
1 parent 8d10edf commit 4861ee2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions base/methodshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,18 @@ function url(m::Method)
return "https://github.com/JuliaLang/julia/tree/$(Base.BUILD_INFO.commit)/base/$file#L$line"
else
try
pkg = Pkg.dir(string(M))
if file[1:length(pkg)] != pkg
d = dirname(file)
u = Git.readchomp(`config remote.origin.url`, dir=d)
u = match(Git.GITHUB_REGEX,u).captures[1]
root = cd(d) do # dir=d confuses --show-toplevel, apparently
Git.readchomp(`rev-parse --show-toplevel`)
end
if beginswith(file, root)
commit = Git.readchomp(`rev-parse HEAD`, dir=d)
return "https://github.com/$u/tree/$commit/"*file[length(root)+2:end]*"#L$line"
else
return "file://"*find_source_file(file)
end
u = Git.readchomp(`config remote.origin.url`, dir=pkg)
u = match(Git.GITHUB_REGEX,u).captures[1]
commit = Git.readchomp(`rev-parse HEAD`, dir=pkg)
return "https://github.com/$u/tree/$commit/"*file[length(pkg)+2:end]*"#L$line"
catch
return "file://"*find_source_file(file)
end
Expand Down

0 comments on commit 4861ee2

Please sign in to comment.