-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Case sensitive Pkg operations on case insensitive filesystems #18210
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import ..Reqs, ..Read, ..Query, ..Resolve, ..Cache, ..Write, ..Dir | |
import ...LibGit2 | ||
importall ...LibGit2 | ||
import ...Pkg.PkgError | ||
using ..Types | ||
using ..Types, Base.Filesystem | ||
|
||
macro recover(ex) | ||
quote | ||
|
@@ -48,25 +48,23 @@ end | |
|
||
function add(pkg::AbstractString, vers::VersionSet) | ||
outdated = :maybe | ||
@sync begin | ||
@async if !edit(Reqs.add,pkg,vers) | ||
ispath(pkg) || throw(PkgError("unknown package $pkg")) | ||
info("Nothing to be done") | ||
end | ||
branch = Dir.getmetabranch() | ||
outdated = with(GitRepo, "METADATA") do repo | ||
if LibGit2.branch(repo) == branch | ||
if LibGit2.isdiff(repo, "origin/$branch") | ||
outdated = :yes | ||
else | ||
try | ||
LibGit2.fetch(repo) | ||
outdated = LibGit2.isdiff(repo, "origin/$branch") ? (:yes) : (:no) | ||
end | ||
end | ||
if !edit(Reqs.add,pkg,vers) | ||
ispath_casesensitive(pkg) || throw(PkgError("unknown package $pkg")) | ||
info("Nothing to be done") | ||
end | ||
branch = Dir.getmetabranch() | ||
outdated = with(GitRepo, "METADATA") do repo | ||
if LibGit2.branch(repo) == branch | ||
if LibGit2.isdiff(repo, "origin/$branch") | ||
outdated = :yes | ||
else | ||
:no # user is doing something funky with METADATA | ||
try | ||
LibGit2.fetch(repo) | ||
outdated = LibGit2.isdiff(repo, "origin/$branch") ? (:yes) : (:no) | ||
end | ||
end | ||
else | ||
:no # user is doing something funky with METADATA | ||
end | ||
end | ||
if outdated != :no | ||
|
@@ -79,7 +77,7 @@ add(pkg::AbstractString, vers::VersionNumber...) = add(pkg,VersionSet(vers...)) | |
|
||
function rm(pkg::AbstractString) | ||
edit(Reqs.rm,pkg) && return | ||
ispath(pkg) || return info("Nothing to be done") | ||
ispath_casesensitive(pkg) || return info("Nothing to be done") | ||
info("Removing $pkg (unregistered)") | ||
Write.remove(pkg) | ||
end | ||
|
@@ -113,7 +111,7 @@ function installed(pkg::AbstractString) | |
avail = Read.available(pkg) | ||
if Read.isinstalled(pkg) | ||
res = typemin(VersionNumber) | ||
if ispath(joinpath(pkg,".git")) | ||
if Read.isgitrepo(pkg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
LibGit2.with(GitRepo, pkg) do repo | ||
res = Read.installed_version(pkg, repo, avail) | ||
end | ||
|
@@ -159,7 +157,7 @@ function status(io::IO, pkg::AbstractString, ver::VersionNumber, fix::Bool) | |
@printf io " - %-29s " pkg | ||
fix || return println(io,ver) | ||
@printf io "%-19s" ver | ||
if ispath(pkg,".git") | ||
if Read.isgitrepo(pkg) | ||
prepo = GitRepo(pkg) | ||
try | ||
with(LibGit2.head(prepo)) do phead | ||
|
@@ -222,7 +220,8 @@ function clone(url_or_pkg::AbstractString) | |
end | ||
|
||
function checkout(pkg::AbstractString, branch::AbstractString, do_merge::Bool, do_pull::Bool) | ||
ispath(pkg,".git") || throw(PkgError("$pkg is not a git repo")) | ||
isdir_casesensitive(pkg) || throw(PkgError("$pkg is not installed")) | ||
Read.isgitrepo(pkg) || throw(PkgError("$pkg is not a git repo")) | ||
info("Checking out $pkg $branch...") | ||
with(GitRepo, pkg) do r | ||
LibGit2.transact(r) do repo | ||
|
@@ -240,7 +239,7 @@ function checkout(pkg::AbstractString, branch::AbstractString, do_merge::Bool, d | |
end | ||
|
||
function free(pkg::AbstractString) | ||
ispath(pkg,".git") || throw(PkgError("$pkg is not a git repo")) | ||
Read.isgitrepo(pkg) || throw(PkgError("$pkg is not a git repo")) | ||
Read.isinstalled(pkg) || throw(PkgError("$pkg cannot be freed – not an installed package")) | ||
avail = Read.available(pkg) | ||
isempty(avail) && throw(PkgError("$pkg cannot be freed – not a registered package")) | ||
|
@@ -267,7 +266,7 @@ end | |
function free(pkgs) | ||
try | ||
for pkg in pkgs | ||
ispath(pkg,".git") || throw(PkgError("$pkg is not a git repo")) | ||
Read.isgitrepo(pkg) || throw(PkgError("$pkg is not a git repo")) | ||
Read.isinstalled(pkg) || throw(PkgError("$pkg cannot be freed – not an installed package")) | ||
avail = Read.available(pkg) | ||
isempty(avail) && throw(PkgError("$pkg cannot be freed – not a registered package")) | ||
|
@@ -291,7 +290,8 @@ function free(pkgs) | |
end | ||
|
||
function pin(pkg::AbstractString, head::AbstractString) | ||
ispath(pkg,".git") || throw(PkgError("$pkg is not a git repo")) | ||
isdir_casesensitive(pkg) || throw(PkgError("$pkg is not installed")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Omit this |
||
Read.isgitrepo(pkg) || throw(PkgError("$pkg is not a git repo")) | ||
should_resolve = true | ||
with(GitRepo, pkg) do repo | ||
id = if isempty(head) # get HEAD commit | ||
|
@@ -341,7 +341,7 @@ end | |
pin(pkg::AbstractString) = pin(pkg, "") | ||
|
||
function pin(pkg::AbstractString, ver::VersionNumber) | ||
ispath(pkg,".git") || throw(PkgError("$pkg is not a git repo")) | ||
Read.isgitrepo(pkg) || throw(PkgError("$pkg is not a git repo")) | ||
Read.isinstalled(pkg) || throw(PkgError("$pkg cannot be pinned – not an installed package")) | ||
avail = Read.available(pkg) | ||
isempty(avail) && throw(PkgError("$pkg cannot be pinned – not a registered package")) | ||
|
@@ -411,7 +411,7 @@ function update(branch::AbstractString, upkgs::Set{String}) | |
try | ||
stopupdate = false | ||
for (pkg,ver) in fixed | ||
ispath(pkg,".git") || continue | ||
Read.isgitrepo(pkg) || continue | ||
pkg in dont_update && continue | ||
with(GitRepo, pkg) do repo | ||
if LibGit2.isattached(repo) | ||
|
@@ -685,6 +685,10 @@ function test!(pkg::AbstractString, | |
errs::Vector{AbstractString}, | ||
nopkgs::Vector{AbstractString}, | ||
notests::Vector{AbstractString}; coverage::Bool=false) | ||
if !isdir_casesensitive(pkg) | ||
push!(nopkgs, pkg) | ||
return false | ||
end | ||
reqs_path = abspath(pkg,"test","REQUIRE") | ||
if isfile(reqs_path) | ||
tests_require = Reqs.parse(reqs_path) | ||
|
@@ -694,9 +698,7 @@ function test!(pkg::AbstractString, | |
end | ||
end | ||
test_path = abspath(pkg,"test","runtests.jl") | ||
if !isdir(pkg) | ||
push!(nopkgs, pkg) | ||
elseif !isfile(test_path) | ||
if !isfile(test_path) | ||
push!(notests, pkg) | ||
else | ||
info("Testing $pkg") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,29 @@ | |
module Read | ||
|
||
import ...LibGit2, ..Cache, ..Reqs, ...Pkg.PkgError, ..Dir | ||
using ..Types | ||
using ..Types, Base.Filesystem | ||
|
||
readstrip(path...) = strip(readstring(joinpath(path...))) | ||
isgitrepo(pkg) = | ||
isdir_casesensitive(pkg) && ispath(pkg, ".git") | ||
|
||
url(pkg::AbstractString) = readstrip(Dir.path("METADATA"), pkg, "url") | ||
sha1(pkg::AbstractString, ver::VersionNumber) = readstrip(Dir.path("METADATA"), pkg, "versions", string(ver), "sha1") | ||
readstrip(path...) = | ||
strip(readstring(joinpath(path...))) | ||
|
||
url(pkg::AbstractString) = | ||
readstrip(Dir.path("METADATA"), pkg, "url") | ||
|
||
sha1(pkg::AbstractString, ver::VersionNumber) = | ||
readstrip(Dir.path("METADATA"), pkg, "versions", string(ver), "sha1") | ||
|
||
function available(names=readdir("METADATA")) | ||
pkgs = Dict{String,Dict{VersionNumber,Available}}() | ||
for pkg in names | ||
isfile("METADATA", pkg, "url") || continue | ||
versdir = joinpath("METADATA", pkg, "versions") | ||
pkgdir = joinpath("METADATA", pkg) | ||
if !isdir_casesensitive(pkgdir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really necessary? In cases where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. |
||
continue | ||
end | ||
isfile(pkgdir, "url") || continue | ||
versdir = joinpath(pkgdir, "versions") | ||
isdir(versdir) || continue | ||
for ver in readdir(versdir) | ||
ismatch(Base.VERSION_REGEX, ver) || continue | ||
|
@@ -28,13 +39,18 @@ function available(names=readdir("METADATA")) | |
end | ||
return pkgs | ||
end | ||
available(pkg::AbstractString) = get(available([pkg]),pkg,Dict{VersionNumber,Available}()) | ||
available(pkg::AbstractString) = | ||
get(available([pkg]),pkg,Dict{VersionNumber,Available}()) | ||
|
||
function latest(names=readdir("METADATA")) | ||
pkgs = Dict{String,Available}() | ||
for pkg in names | ||
isfile("METADATA", pkg, "url") || continue | ||
versdir = joinpath("METADATA", pkg, "versions") | ||
pkgdir = joinpath("METADATA", pkg) | ||
if !isdir_casesensitive(pkgdir) | ||
continue | ||
end | ||
isfile(pkgdir, "url") || continue | ||
versdir = joinpath(pkgdir, "versions") | ||
isdir(versdir) || continue | ||
pkgversions = VersionNumber[] | ||
for ver in readdir(versdir) | ||
|
@@ -53,12 +69,12 @@ function latest(names=readdir("METADATA")) | |
end | ||
|
||
isinstalled(pkg::AbstractString) = | ||
pkg != "METADATA" && pkg != "REQUIRE" && pkg[1] != '.' && isdir(pkg) | ||
pkg != "METADATA" && pkg != "REQUIRE" && pkg[1] != '.' && isdir_casesensitive(pkg) | ||
|
||
function isfixed(pkg::AbstractString, prepo::LibGit2.GitRepo, avail::Dict=available(pkg)) | ||
isinstalled(pkg) || throw(PkgError("$pkg is not an installed package.")) | ||
isfile("METADATA", pkg, "url") || return true | ||
ispath(pkg, ".git") || return true | ||
isgitrepo(pkg) || return true | ||
|
||
LibGit2.isdirty(prepo) && return true | ||
LibGit2.isattached(prepo) && return true | ||
|
@@ -101,7 +117,7 @@ function isfixed(pkg::AbstractString, prepo::LibGit2.GitRepo, avail::Dict=availa | |
end | ||
|
||
function ispinned(pkg::AbstractString) | ||
ispath(pkg,".git") || return false | ||
isgitrepo(pkg) || return false | ||
LibGit2.with(LibGit2.GitRepo, pkg) do repo | ||
return ispinned(repo) | ||
end | ||
|
@@ -115,7 +131,7 @@ function ispinned(prepo::LibGit2.GitRepo) | |
end | ||
|
||
function installed_version(pkg::AbstractString, prepo::LibGit2.GitRepo, avail::Dict=available(pkg)) | ||
ispath(pkg,".git") || return typemin(VersionNumber) | ||
isgitrepo(pkg) || return typemin(VersionNumber) | ||
|
||
# get package repo head hash | ||
local head | ||
|
@@ -176,7 +192,7 @@ end | |
|
||
function requires_path(pkg::AbstractString, avail::Dict=available(pkg)) | ||
pkgreq = joinpath(pkg,"REQUIRE") | ||
ispath(pkg,".git") || return pkgreq | ||
isgitrepo(pkg) || return pkgreq | ||
repo = LibGit2.GitRepo(pkg) | ||
head = LibGit2.with(LibGit2.GitRepo, pkg) do repo | ||
LibGit2.isdirty(repo, "REQUIRE") && return pkgreq | ||
|
@@ -203,7 +219,7 @@ function installed(avail::Dict=available()) | |
for pkg in readdir() | ||
isinstalled(pkg) || continue | ||
ap = get(avail,pkg,Dict{VersionNumber,Available}()) | ||
if ispath(pkg,".git") | ||
if isgitrepo(pkg) | ||
LibGit2.with(LibGit2.GitRepo, pkg) do repo | ||
ver = installed_version(pkg, repo, ap) | ||
fixed = isfixed(pkg, repo, ap) | ||
|
@@ -238,7 +254,7 @@ function free(inst::Dict=installed(), dont_update::Set{String}=Set{String}()) | |
end | ||
|
||
function issue_url(pkg::AbstractString) | ||
ispath(pkg,".git") || return "" | ||
isgitrepo(pkg) || return "" | ||
m = match(LibGit2.GITHUB_REGEX, url(pkg)) | ||
m === nothing && return "" | ||
return "https://github.com/" * m.captures[1] * "/issues" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message here seems a bit misleading.
If I do
Pkg.add("Foo")
and I already have a directoryFoo
inPkg.dir()
, butFoo
is not theFoo
repo corresponding to the one in METADATA, I would expect an error rather than "Nothing to be done". Should we check that their origins match?And if I already have a directory
foo
, an "unknown package Foo" error message is wrong.At the very least, we should probably be doing: