Skip to content

Commit 4bec100

Browse files
authored
Merge pull request #53 from theogf/master
Add option to specify git root directory
2 parents f197f21 + 9fb8e83 commit 4bec100

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/LocalCoverage.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ inside `dir`.
286286
287287
See [`generate_coverage`](@ref).
288288
"""
289-
function html_coverage(coverage::PackageCoverage; open = false, dir = tempdir())
289+
function html_coverage(coverage::PackageCoverage; gitroot = ".", open = false, dir = tempdir())
290290
cd(coverage.package_dir) do
291291
branch = try
292-
LibGit2.headname(GitRepo("./"))
292+
LibGit2.headname(GitRepo(gitroot))
293293
catch
294-
@warn "git branch could not be detected"
294+
@warn "git branch could not be detected, pass the `gitroot` kwarg if the git root is not the same as the package directory."
295295
end
296296

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

315315
function html_coverage(pkg = nothing;
316+
gitroot = ".",
316317
open = false,
317318
dir = tempdir(),
318319
test_args = [""],
319320
folder_list = ["src"],
320321
file_list = [])
321322
gen_cov() = generate_coverage(pkg; test_args = test_args, folder_list = folder_list, file_list = file_list)
322-
html_coverage(gen_cov(), open = open, dir = dir)
323+
html_coverage(gen_cov(); gitroot = gitroot, open = open, dir = dir)
323324
end
324325

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

385386
"""

0 commit comments

Comments
 (0)