Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding the URL of methods doesn't work for packages added (not dev'ed) #30139

Open
oxinabox opened this issue Nov 24, 2018 · 1 comment
Open

Comments

@oxinabox
Copy link
Contributor

The code that finds the URL for the source for a method doesn't work for code that was installed via Pkg.add.
Since as of Pkg3 that no longer means it is a git repo.

julia/base/methodshow.jl

Lines 200 to 238 in f4c7779

function url(m::Method)
M = m.module
(m.file == :null || m.file == :string) && return ""
file = string(m.file)
line = m.line
line <= 0 || occursin(r"In\[[0-9]+\]", file) && return ""
Sys.iswindows() && (file = replace(file, '\\' => '/'))
libgit2_id = PkgId(UUID((0x76f85450_5226_5b5a,0x8eaa_529ad045b433)), "LibGit2")
if inbase(M)
if isempty(Base.GIT_VERSION_INFO.commit)
# this url will only work if we're on a tagged release
return "https://github.com/JuliaLang/julia/tree/v$VERSION/base/$file#L$line"
else
return "https://github.com/JuliaLang/julia/tree/$(Base.GIT_VERSION_INFO.commit)/base/$file#L$line"
end
elseif root_module_exists(libgit2_id)
LibGit2 = root_module(libgit2_id)
try
d = dirname(file)
return LibGit2.with(LibGit2.GitRepoExt(d)) do repo
LibGit2.with(LibGit2.GitConfig(repo)) do cfg
u = LibGit2.get(cfg, "remote.origin.url", "")
u = match(LibGit2.GITHUB_REGEX,u).captures[1]
commit = string(LibGit2.head_oid(repo))
root = LibGit2.path(repo)
if startswith(file, root) || startswith(realpath(file), root)
"https://github.com/$u/tree/$commit/"*file[length(root)+1:end]*"#L$line"
else
fileurl(file)
end
end
end
catch
return fileurl(file)
end
else
return fileurl(file)
end
end

I think I have code to fix this.
It involves trying to load Pkg (just like current code already tries to load LibGit2).
Then asking Pkg to check the registry for the git url is,
as well as checking what the current version (and thus tag) is.

@oxinabox
Copy link
Contributor Author

oxinabox commented Jan 2, 2019

CF: JuliaLang/Pkg.jl#960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant