Skip to content
23 changes: 23 additions & 0 deletions R/synchronization.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#' Check whether all versions NEWS.md have been git-tagged
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title/description text is grammatically off: “all versions NEWS.md” is missing “in” (i.e., “all versions in NEWS.md”). Since man/check_tags.Rd is generated from this roxygen block, fix the wording here and re-run roxygen so the Rd stays in sync.

Suggested change
#' Check whether all versions NEWS.md have been git-tagged
#' Check whether all versions in NEWS.md have been git-tagged

Copilot uses AI. Check for mistakes.
#'
#' @return `NULL`
#'
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_tags() is documented, tested, and used in examples via fledge::check_tags(), but it is not exported (no @export tag). As-is, fledge::check_tags() will fail and check_tags() won’t be found when running tests against an installed package. Add @export in the roxygen block (and regenerate NAMESPACE via roxygen2).

Suggested change
#'
#'
#' @export

Copilot uses AI. Check for mistakes.
#' @example man/examples/check-tags.R
check_tags <- function() {
versions <- get_news_headers()[["version"]]
tags <- gsub("^v", "", gert::git_tag_list()[["name"]])

untagged_versions <- versions[!(versions %in% tags)]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
untagged_versions <- versions[!(versions %in% tags)]
untagged_versions <- setdiff(versions, tags)

if (length(untagged_versions) == 0) {
return(NULL)
}

rlang::warn(
Comment thread
maelle marked this conversation as resolved.
sprintf(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the package imports cli so this should use cli::cli_warn() and cli pluralization. https://cli.r-lib.org/reference/pluralization.html

"Version%s with no corresponding tags: %s.",
ifelse(length(untagged_versions) == 1, "", "s"),
toString(untagged_versions)
)
)
return(NULL)
}
34 changes: 34 additions & 0 deletions man/check_tags.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions man/examples/check-tags.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Create mock package in a temporary directory.
with_demo_project({
# Use functions as if inside the newly created package project.
# (Or go and actually run code inside the newly created package project!)
# Add a new R file.
usethis::use_r("cool-function", open = FALSE)
# Pretend we added useful code inside it.
# Track the new R file with Git.
gert::git_add("R/cool-function.R")
gert::git_commit("- Add cool function.")
# Bump version with fledge.
fledge::bump_version()
fledge::update_news(c("- something I forgot", "- blabla"))
fledge::update_version()
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example calls fledge::update_version(), which is marked deprecated in the package docs. Examples are executed during R CMD check, so it’s better to avoid deprecated APIs here (use fledge::update_news() instead).

Suggested change
fledge::update_version()

Copilot uses AI. Check for mistakes.
gert::git_add("NEWS.md")
gert::git_commit(message = "release notes tweaking")
fledge::check_tags()
})
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/synchronization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# check_tags

Code
check_tags()
Condition
Warning:
Version with no corresponding tags: 0.0.0.9000.
Output
NULL

9 changes: 9 additions & 0 deletions tests/testthat/test-synchronization.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test_that("check_tags", {
skip_if_not_installed("rlang", "1.0.1")
skip_if_not_installed("testthat", "3.1.2")

local_demo_project(quiet = TRUE)
expect_snapshot(check_tags())
shut_up_fledge(tag_version())
expect_null(expect_silent(check_tags()))
})
Loading