Skip to content

Commit

Permalink
Merge #1199 #1200
Browse files Browse the repository at this point in the history
1199: Wrap reading of project status in HEAD in try-catch, fixes #1180. r=fredrikekre a=fredrikekre



1200: Fix st -m X when X is in manifest but not in project, fixes #1183. r=fredrikekre a=fredrikekre



Co-authored-by: Fredrik Ekre <ekrefredrik@gmail.com>
  • Loading branch information
bors[bot] and fredrikekre committed May 22, 2019
3 parents a6c05b5 + eae6598 + 8cd2d8d commit c6fad5e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/API.jl
Expand Up @@ -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)
Expand Down
18 changes: 11 additions & 7 deletions src/Display.jl
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions test/api.jl
Expand Up @@ -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

Expand Down
13 changes: 13 additions & 0 deletions test/pkg.jl
Expand Up @@ -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
Expand Down

0 comments on commit c6fad5e

Please sign in to comment.