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

Add option to specify git root directory #53

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/LocalCoverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ inside `dir`.

See [`generate_coverage`](@ref).
"""
function html_coverage(coverage::PackageCoverage; open = false, dir = tempdir())
function html_coverage(coverage::PackageCoverage; gitroot = ".", open = false, dir = tempdir())
cd(coverage.package_dir) do
branch = try
LibGit2.headname(GitRepo("./"))
LibGit2.headname(GitRepo(gitroot))
catch
@warn "git branch could not be detected"
@warn "git branch could not be detected, pass the `gitroot` kwarg if the git root is not the same as the package directory."
end

title = "on branch $(branch)"
Expand All @@ -313,13 +313,14 @@ function html_coverage(coverage::PackageCoverage; open = false, dir = tempdir())
end

function html_coverage(pkg = nothing;
gitroot = ".",
open = false,
dir = tempdir(),
test_args = [""],
folder_list = ["src"],
file_list = [])
gen_cov() = generate_coverage(pkg; test_args = test_args, folder_list = folder_list, file_list = file_list)
html_coverage(gen_cov(), open = open, dir = dir)
html_coverage(gen_cov(); gitroot = gitroot, open = open, dir = dir)
end

"""
Expand Down Expand Up @@ -379,7 +380,7 @@ This requires the Python package `lcov_cobertura` (>= v2.0.1), available in PyPl
function generate_xml(coverage::PackageCoverage, filename="cov.xml")
run(Cmd(Cmd(["lcov_cobertura", "lcov.info", "-o", filename]),
dir = joinpath(coverage.package_dir, COVDIR)))
@info("generated cobertura XML $filename")
@info("generated cobertura XML $(joinpath(coverage.package_dir, COVDIR, filename)).")
end

"""
Expand Down
Loading