Skip to content

Commit

Permalink
Adapt to changes in Pkg internals in Julia 1.7.
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnarFarneback committed Dec 2, 2021
1 parent 6091e26 commit d08123e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PackageCompatUI"
uuid = "65465c31-362d-417a-a2f0-7fa38ae507b9"
authors = ["Gunnar Farnebäck <[email protected]>"]
version = "1.0.0"
version = "1.0.1"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
23 changes: 21 additions & 2 deletions src/PackageCompatUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,34 @@ function compat_ui(;pagesize = 20, dates = true)
versions["julia"] = get_julia_versions()
version_dates["julia"] = Dict{String, String}()
packages = vcat("julia", sort(collect(keys(needs_compat))))
data = MenuData(packages, project.compat, versions, version_dates)
data = MenuData(packages, extract_compat_string(project.compat),
versions, version_dates)
menu = Menu(data, pagesize)
menu.cursor[] = selected
request(menu, cursor = menu.cursor)
project.compat = data.compat
set_project_compat!(project, data.compat)
Pkg.Types.write_project(project, Base.active_project())
return
end

# Compatibility layer to handle Pkg internals changes between Julia 1.6
# and Julia 1.7.
extract_compat_string(compat::Dict) = Dict(k => extract_compat_string(v)
for (k, v) in compat)
extract_compat_string(compat::String) = compat
extract_compat_string(compat) = compat.str
set_project_compat!(project_compat::Dict{String, String}, new_compat) =
merge!(empty!(project_compat), new_compat)
function set_project_compat!(project, compat)
if project.compat isa Dict{String, String}
project.compat = compat
else
for (package, compat_string) in compat
Pkg.Operations.set_compat(project, package, compat_string)
end
end
end

function gitcmd(repo)
git = Git.git(["-C", repo])
return (x...) -> readlines(`$git $x`)
Expand Down

0 comments on commit d08123e

Please sign in to comment.