Skip to content

Commit

Permalink
feat: Keep only raw NEWS (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr authored Nov 23, 2024
1 parent ca0cb73 commit 6ea21e7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
2 changes: 0 additions & 2 deletions R/fledgling.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ read_news <- function(news_lines = NULL) {
end = ends,
h2 = grepl("##", news_lines[starts]), # TODO does not account for all syntaxes,
raw = map2_chr(starts, ends, ~ paste(news_lines[seq2(.x, .y)], collapse = "\n")),
versions = versions,
section_state = "keep",
title = names(versions),
parse_versions(names(versions))[, c("version", "date", "nickname")],
Expand Down Expand Up @@ -124,7 +123,6 @@ read_news <- function(news_lines = NULL) {
}

parse_news_md <- function(news) {
news <- protect_hashtag(news)
versions <- versions_from_news(news)
if (is.null(versions)) {
return(NULL)
Expand Down
4 changes: 2 additions & 2 deletions R/update-news.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ add_news_to_fledgeling_samedev <- function(fledgeling, news_lines) {
section_state = "new"
)
} else {
old_news <- news_from_versions(fledgeling[["news"]]$versions[1])[[1]]
old_news <- news_from_versions(parse_news_md(fledgeling[["news"]]$raw[[1]]))[[1]]
combined <- c(parse_news_lines(news_lines), old_news)
combined <- purrr::discard(combined, purrr::is_empty)
regrouped <- regroup_news(combined)
Expand Down Expand Up @@ -106,7 +106,7 @@ add_news_to_fledgeling <- function(
}

if (dev_header_present) {
old_news <- news_from_versions(fledgeling[["news"]]$versions[1])[[1]]
old_news <- news_from_versions(parse_news_md(fledgeling[["news"]]$raw[[1]]))[[1]]
combined <- c(parse_news_lines(news_lines), old_news)
combined <- purrr::discard(combined, purrr::is_empty)
news <- regroup_news(combined)
Expand Down
10 changes: 0 additions & 10 deletions tests/testthat/_snaps/fledgling.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"end": 8,
"h2": false,
"raw": "# fledge v2.0.0\n\n* blop\n\n* lala\n",
"versions": "<section id=\"fledge-v200\" class=\"level1\">",
"section_state": "keep",
"title": "fledge v2.0.0",
"version": "2.0.0",
Expand All @@ -19,7 +18,6 @@
"end": 14,
"h2": false,
"raw": "# fledge v1.0.0\n\n* blip\n\n* lili\n",
"versions": "<section id=\"fledge-v100\" class=\"level1\">",
"section_state": "keep",
"title": "fledge v1.0.0",
"version": "1.0.0",
Expand All @@ -40,7 +38,6 @@
"end": 9,
"h2": false,
"raw": "# Changes in v2.0.0\n\n* blop\n\n* lala\n\n",
"versions": "<section id=\"changes-in-v200\" class=\"level1\">",
"section_state": "keep",
"title": "Changes in v2.0.0",
"version": "2.0.0",
Expand All @@ -52,7 +49,6 @@
"end": 15,
"h2": false,
"raw": "# Changes in v1.0.0\n\n* blip\n\n* lili\n",
"versions": "<section id=\"changes-in-v100\" class=\"level1\">",
"section_state": "keep",
"title": "Changes in v1.0.0",
"version": "1.0.0",
Expand All @@ -73,7 +69,6 @@
"end": 8,
"h2": false,
"raw": "# Changes in v2.0.0 \"Vigorous Calisthenics\"\n\n* blop\n\n* lala\n",
"versions": "<section id=\"changes-in-v200-vigorous-calisthenics\" class=\"level1\">",
"section_state": "keep",
"title": "Changes in v2.0.0 \"Vigorous Calisthenics\"",
"version": "2.0.0",
Expand All @@ -85,7 +80,6 @@
"end": 14,
"h2": false,
"raw": "# Changes in v1.0.0 \"Pumpkin Helmet\"\n\n* blip\n\n* lili\n",
"versions": "<section id=\"changes-in-v100-pumpkin-helmet\" class=\"level1\">",
"section_state": "keep",
"title": "Changes in v1.0.0 \"Pumpkin Helmet\"",
"version": "1.0.0",
Expand All @@ -106,7 +100,6 @@
"end": 8,
"h2": true,
"raw": "## Changes in v2.0.0 \"Vigorous Calisthenics\"\n\n* blop\n\n* lala\n",
"versions": "<section id=\"changes-in-v200-vigorous-calisthenics\" class=\"level2\">",
"section_state": "keep",
"title": "Changes in v2.0.0 \"Vigorous Calisthenics\"",
"version": "2.0.0",
Expand All @@ -118,7 +111,6 @@
"end": 14,
"h2": true,
"raw": "## Changes in v1.0.0 \"Pumpkin Helmet\"\n\n* blip\n\n* lili\n",
"versions": "<section id=\"changes-in-v100-pumpkin-helmet\" class=\"level2\">",
"section_state": "keep",
"title": "Changes in v1.0.0 \"Pumpkin Helmet\"",
"version": "1.0.0",
Expand All @@ -139,7 +131,6 @@
"end": 7,
"h2": false,
"raw": "fledge v2.0.0\n=============\n\n* blop\n\n* lala\n",
"versions": "<section id=\"fledge-v200\" class=\"level1\">",
"section_state": "keep",
"title": "fledge v2.0.0",
"version": "2.0.0",
Expand All @@ -151,7 +142,6 @@
"end": 13,
"h2": false,
"raw": "# fledge v1.0.0\n\n* blip\n\n* lili\n",
"versions": "<section id=\"fledge-v100\" class=\"level1\">",
"section_state": "keep",
"title": "fledge v1.0.0",
"version": "1.0.0",
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/update-news.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
[1] "<!-- NEWS.md is maintained by https://fledge.cynkra.com, contributors should not edit this file -->"
$news
# A tibble: 1 x 10
# A tibble: 1 x 9
start end h2
<int> <int> <lgl>
1 3 6 FALSE
raw
<chr>
1 "# tea 0.0.1 (2023-01-23)\n\n- Added a `NEWS.md` file to track changes to the~
versions section_state title version date nickname
<named list> <chr> <chr> <chr> <chr> <chr>
1 <xml_node> keep tea 0.0.1 (2023-01-23) 0.0.1 (2023-01-2~ <NA>
section_state title version date nickname
<chr> <chr> <chr> <chr> <chr>
1 keep tea 0.0.1 (2023-01-23) 0.0.1 (2023-01-23) <NA>
$preamble_in_file
[1] TRUE
Expand Down

0 comments on commit 6ea21e7

Please sign in to comment.