Skip to content

Commit

Permalink
feat: Consistent protection of hash tag (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Nov 25, 2024
1 parent e61b9aa commit fd269b8
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion R/fledgling.R
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ paste_news_lines <- function(lines, header_level) {
if (!nzchar(x)) {
""
} else {
paste(header_sign, x, "\n\n")
paste0(header_sign, " ", x, "\n\n")
}
}
lines <- purrr::imap_chr(
Expand Down
4 changes: 3 additions & 1 deletion R/pandoc.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions_from_news <- function(news) {
news <- protect_hashtag(news)

temp_file <- withr::local_tempfile(fileext = ".md")
brio::write_lines(news, temp_file)

Expand Down Expand Up @@ -76,7 +78,7 @@ news_get_section_name <- function(section) {

protect_hashtag <- function(lines) {
lines <- gsub(
"(?<!#)(?<!^)(?<!`)#([[:alnum:]]*)([[:space:]]|[[:punct:]])",
"(?<!^|[#`\n])#([[:alnum:]]*)([[:space:]]|[[:punct:]])",
"`#\\1`{=html}\\2",
lines,
perl = TRUE
Expand Down
2 changes: 1 addition & 1 deletion R/parse-news-items.R
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ is_merge_commit <- function(message) {
}

harvest_pr_data <- function(message) {
pr_number <- regmatches(message, regexpr("(?<=#)[0-9]*", message, perl = TRUE))
pr_number <- regmatches(message, regexpr("(?<=#)[0-9]+", message, perl = TRUE))

if (length(pr_number) == 0) {
return(tibble::tibble(
Expand Down
2 changes: 1 addition & 1 deletion R/submit.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extract_cran_msg <- function(msg) {

upload_cran <- function(pkg, built_path) {
maint <- utils::as.person(desc::desc_get_maintainer(pkg))
maint_name <- paste(maint$given, maint$family)
maint_name <- paste0(maint$given, " ", maint$family)
maint_email <- maint$email
comments <- cran_comments(pkg)

Expand Down
3 changes: 1 addition & 2 deletions R/update-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ add_scope <- function(row) {
if (is.na(row$scope)) {
row$description
} else {
sprintf("### %s \n\n%s", row$scope, row$description)
sprintf("### %s\n\n%s", row$scope, row$description)
}
}
add_hyphen <- function(row) {
Expand Down Expand Up @@ -329,7 +329,6 @@ get_date <- function() {
}

parse_news_lines <- function(news) {
news <- protect_hashtag(news)
versions <- versions_from_news(news)
news_collection_treat_section(versions)
}
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/auto/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Add cool blop.

- Add cool bla.
- Add cool bla (@someone, #hashtag-test).

- Added a `NEWS.md` file to track changes to the package.

2 changes: 1 addition & 1 deletion tests/testthat/test-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test_that("merge_dev_news() works", {

use_r("bla")
fast_git_add("R/bla.R")
gert::git_commit("* Add cool bla.")
gert::git_commit("* Add cool bla (@someone, #hashtag-test).")
bump_version()

use_r("blop")
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-update-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ test_that("regroup_news() works", {
)

combined <- c(news_list1, news_list2)
regrouped <-
expect_snapshot({
regroup_news(combined)
})

expect_snapshot({
regroup_news(combined)
})
})

test_that("Can update dev version news item", {
Expand Down

0 comments on commit fd269b8

Please sign in to comment.