diff --git a/NEWS.md b/NEWS.md index d7f3a70a0..e6a73b19e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # usethis (development version) +* The URLs baked into the badge generated by `use_coverage(type = "codecov")` + no longer specify a branch (#2008). + * The `ui_*()` functions have been marked as [superseded](https://lifecycle.r-lib.org/articles/stages.html#superseded). External users of these functions are encouraged to use the diff --git a/R/coverage.R b/R/coverage.R index dc9dd5f2a..2406cd8bd 100644 --- a/R/coverage.R +++ b/R/coverage.R @@ -44,9 +44,8 @@ use_covr_ignore <- function(files) { } use_codecov_badge <- function(repo_spec) { - default_branch <- git_default_branch() - url <- glue("https://app.codecov.io/gh/{repo_spec}?branch={default_branch}") - img <- glue("https://codecov.io/gh/{repo_spec}/branch/{default_branch}/graph/badge.svg") + url <- glue("https://codecov.io/gh/{repo_spec}") + img <- glue("https://codecov.io/gh/{repo_spec}/graph/badge.svg") use_badge("Codecov test coverage", url, img) } diff --git a/README.Rmd b/README.Rmd index 0fbb3d006..ed3b4ac0a 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,10 +17,10 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml) -[![Codecov test coverage](https://codecov.io/gh/r-lib/usethis/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis?branch=main) [![CRAN status](https://www.r-pkg.org/badges/version/usethis)](https://CRAN.R-project.org/package=usethis) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![.github/workflows/R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml) +[![Codecov test coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://codecov.io/gh/r-lib/usethis) usethis is a workflow package: it automates repetitive tasks that arise during project setup and development, both for R packages and non-package projects. diff --git a/README.md b/README.md index a68a2b255..b865cb055 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ [![R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml) -[![Codecov test -coverage](https://codecov.io/gh/r-lib/usethis/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis?branch=main) [![CRAN status](https://www.r-pkg.org/badges/version/usethis)](https://CRAN.R-project.org/package=usethis) [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) [![.github/workflows/R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml) +[![Codecov test +coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://codecov.io/gh/r-lib/usethis) usethis is a workflow package: it automates repetitive tasks that arise diff --git a/tests/testthat/_snaps/coverage.md b/tests/testthat/_snaps/coverage.md new file mode 100644 index 000000000..c849622be --- /dev/null +++ b/tests/testthat/_snaps/coverage.md @@ -0,0 +1,13 @@ +# we use specific URLs in a codecov badge + + Code + use_codecov_badge("OWNER/REPO") + Message + ! Can't find a README for the current project. + i See `usethis::use_readme_rmd()` for help creating this file. + i Badge link will only be printed to screen. + [ ] Copy and paste the following lines into 'README': + + [![Codecov test coverage](https://codecov.io/gh/OWNER/REPO/graph/badge.svg)](https://codecov.io/gh/OWNER/REPO) + + diff --git a/tests/testthat/test-coverage.R b/tests/testthat/test-coverage.R new file mode 100644 index 000000000..954938c49 --- /dev/null +++ b/tests/testthat/test-coverage.R @@ -0,0 +1,5 @@ +test_that("we use specific URLs in a codecov badge", { + create_local_package() + withr::local_options(usethis.quiet = FALSE) + expect_snapshot(use_codecov_badge("OWNER/REPO")) +})