1- any_mismatch = FALSE
2-
31# ensure that numbered list in each section is in sequence
42check_section_numbering = function (news ) {
3+ if (! grepl(" NEWS" , news )) return ()
4+ news = readLines(news )
55 # plain '#' catches some examples; 'd' for 'data.table'
66 sections = grep(" ^#+ [A-Zd]" , news )
77 entries = grep(" ^[0-9]+[.]" , news )
88 entry_value = as.integer(gsub(" ^([0-9]+)[.].*" , " \\ 1" , news [entries ]))
99 section_id = findInterval(entries , sections )
10-
10+
1111 any_mismatch = FALSE
1212 for (id in unique(section_id )) {
1313 section_entries = entry_value [section_id == id ]
@@ -22,11 +22,12 @@ check_section_numbering = function(news) {
2222 paste0(" [" , section_entries [! matched ], " --> " , intended_value [! matched ], " ]" , collapse = " \n " )
2323 ))
2424 }
25- return ( any_mismatch )
25+ stopifnot( " Please fix the issues above " = ! any_mismatch )
2626}
2727
2828# ensure that GitHub link text & URL actually agree
2929check_gh_links = function (news ) {
30+ news = readLines(news )
3031 gh_links_info = gregexpr(
3132 " \\ [#(?<md_number>[0-9]+)\\ ]\\ (https://github.com/Rdatatable/data.table/(?<link_type>[^/]+)/(?<link_number>[0-9]+)\\ )" ,
3233 news ,
@@ -48,14 +49,5 @@ check_gh_links = function(news) {
4849 " In line %d, link pointing to %s %s is written #%s\n " ,
4950 line_number , link_type , link_number , md_number
5051 )))
51- return (TRUE )
52- }
53-
54- any_error = FALSE
55- for (news in list.files(pattern = " NEWS" )) {
56- cat(sprintf(" Checking NEWS file %s...\n " , news ))
57- news_lines = readLines(news )
58- any_error = check_section_numbering(news_lines ) || any_error
59- any_error = check_gh_links(news_lines ) || any_error
52+ stop(" Please fix the issues above." )
6053}
61- if (any_error ) stop(" Please fix the NEWS issues above." )
0 commit comments