From 3f57711c6d1231a5c5cbce95dde4b8b777c8676a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Fri, 22 Nov 2024 22:49:25 +0100 Subject: [PATCH] chore: Distinguish `news` component from `news` column in data frame (#820) --- R/auto.R | 17 +++++++++++------ R/fledgling.R | 2 +- R/update-news.R | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/R/auto.R b/R/auto.R index 500a1fb0d..c982087aa 100644 --- a/R/auto.R +++ b/R/auto.R @@ -243,12 +243,14 @@ get_remote_name <- function(branch = get_main_branch()) { } merge_dev_news <- function(fledgeling, new_version) { - dev_idx <- grepl("^[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+$", fledgeling$news$version) + dev_idx <- grepl("^[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+$", fledgeling[["news"]]$version) stopifnot(dev_idx[[1]]) n_dev <- rle(dev_idx)$lengths[[1]] - news <- regroup_news(unlist(fledgeling$news$news[seq_len(n_dev)], recursive = FALSE)) + news <- regroup_news( + unlist(fledgeling[["news"]]$news[seq_len(n_dev)], recursive = FALSE) + ) new_section <- tibble::tibble( start = 3, @@ -263,8 +265,11 @@ merge_dev_news <- function(fledgeling, new_version) { section_state = "new" ) - fledgeling$version <- as.package_version(new_version) - fledgeling$news <- vctrs::vec_rbind(new_section, fledgeling$news[-seq_len(n_dev), ]) + fledgeling[["version"]] <- as.package_version(new_version) + fledgeling[["news"]] <- vctrs::vec_rbind( + new_section, + fledgeling[["news"]][-seq_len(n_dev), ] + ) fledgeling } @@ -567,9 +572,9 @@ create_github_release <- function() { fledgling <- read_fledgling() - stopifnot(sum(fledgling$news$version == version) == 1) + stopifnot(sum(fledgling[["news"]]$version == version) == 1) header <- paste0(fledgling$name, " ", version) - body <- fledgling$news$raw[fledgling$news$version == version] + body <- fledgling[["news"]]$raw[fledgling[["news"]]$version == version] body <- gsub("^# [^\n]*\n+", "", body) diff --git a/R/fledgling.R b/R/fledgling.R index a795dc289..43a0d72fa 100644 --- a/R/fledgling.R +++ b/R/fledgling.R @@ -193,7 +193,7 @@ write_fledgling <- function(fledgeling) { # store news - news_df <- fledgeling$news + news_df <- fledgeling[["news"]] news_lines <- purrr::map_chr( split(news_df, seq_len(nrow(news_df))), write_news_section diff --git a/R/update-news.R b/R/update-news.R index 357a84c3d..04fe66f4b 100644 --- a/R/update-news.R +++ b/R/update-news.R @@ -92,7 +92,7 @@ update_news_impl <- function(commits, if (dev_header_present) { combined <- c( parse_news_md(news_lines), - fledgeling[["news"]][1, ]$news[[1]] + fledgeling[["news"]]$news[[1]] ) combined <- purrr::discard(combined, purrr::is_empty) news <- regroup_news(combined)