Skip to content

Commit

Permalink
chore: Distinguish news component from news column in data frame (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Nov 22, 2024
1 parent 21d1831 commit 3f57711
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions R/auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion R/fledgling.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/update-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3f57711

Please sign in to comment.