diff --git a/src/API.jl b/src/API.jl index 0e4bea0d01..70a9dcacdd 100644 --- a/src/API.jl +++ b/src/API.jl @@ -498,6 +498,9 @@ status(pkgs::Vector{PackageSpec}; mode=PKGMODE_PROJECT) = status(Context(), pkgs function status(ctx::Context, pkgs::Vector{PackageSpec}; mode=PKGMODE_PROJECT) project_resolve!(ctx.env, pkgs) project_deps_resolve!(ctx.env, pkgs) + if mode === PKGMODE_MANIFEST + foreach(pkg -> pkg.mode = PKGMODE_MANIFEST, pkgs) + end manifest_resolve!(ctx.env, pkgs) ensure_resolved(ctx.env, pkgs) Pkg.Display.status(ctx, pkgs, mode=mode) diff --git a/src/Display.jl b/src/Display.jl index d3405074b6..43b8522e99 100644 --- a/src/Display.jl +++ b/src/Display.jl @@ -64,13 +64,17 @@ function status(ctx::Context, pkgs::Vector{PackageSpec}=PackageSpec[]; println(pkg.name, " v", pkg.version) end end - if env.git != nothing - LibGit2.with(LibGit2.GitRepo(env.git)) do repo - git_path = LibGit2.path(repo) - project_path = relpath(env.project_file, git_path) - manifest_path = relpath(env.manifest_file, git_path) - project₀ = read_project(git_file_stream(repo, "HEAD:$project_path", fakeit=true)) - manifest₀ = read_manifest(git_file_stream(repo, "HEAD:$manifest_path", fakeit=true)) + if env.git !== nothing + try + LibGit2.with(LibGit2.GitRepo(env.git)) do repo + git_path = LibGit2.path(repo) + project_path = relpath(env.project_file, git_path) + manifest_path = relpath(env.manifest_file, git_path) + project₀ = read_project(git_file_stream(repo, "HEAD:$project_path", fakeit=true)) + manifest₀ = read_manifest(git_file_stream(repo, "HEAD:$manifest_path", fakeit=true)) + end + catch + @warn "Could not read project from HEAD, displaying absolute status instead." end end if mode == PKGMODE_PROJECT || mode == PKGMODE_COMBINED diff --git a/test/api.jl b/test/api.jl index bc4e47d33b..d072ada846 100644 --- a/test/api.jl +++ b/test/api.jl @@ -64,6 +64,10 @@ end Pkg.status(; mode=PKGMODE_MANIFEST) Pkg.status("Example"; mode=PKGMODE_MANIFEST) @test_deprecated Pkg.status(PKGMODE_MANIFEST) + # issue #1183: Test exist in manifest but not in project + Pkg.status("Test"; mode=PKGMODE_MANIFEST) + @test_throws PkgError Pkg.status("Test"; mode=Pkg.Types.PKGMODE_COMBINED) + @test_throws PkgError Pkg.status("Test"; mode=PKGMODE_PROJECT) end end diff --git a/test/pkg.jl b/test/pkg.jl index 55151bf734..f338e7aac2 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -728,6 +728,19 @@ end end end end +@testset "issue #1180: broken toml-files in HEAD" begin + temp_pkg_dir() do dir; cd(dir) do + write("Project.toml", "[deps]\nExample = \n") + LibGit2.with(LibGit2.init(dir)) do repo + LibGit2.add!(repo, "*") + LibGit2.commit(repo, "initial commit"; author=TEST_SIG, committer=TEST_SIG) + end + write("Project.toml", "[deps]\nExample = \"7876af07-990d-54b4-ab0e-23690620f79a\"\n") + Pkg.activate(dir) + @test_logs (:warn, r"Could not read project from HEAD") Pkg.status() + end end +end + import Markdown @testset "REPL command doc generation" begin # test that the way doc building extracts