From c803b08560686580b30a038187e8528ca18da486 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Wed, 1 Nov 2023 11:25:41 +0100 Subject: [PATCH] Fixes #4462 --- bin/lint.rb | 4 ++-- bin/news.rb | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/bin/lint.rb b/bin/lint.rb index a569ca93dbc9ce..fd8806445395f5 100755 --- a/bin/lint.rb +++ b/bin/lint.rb @@ -685,7 +685,7 @@ def self.check_bolded_heading(contents) end def self.zenodo_api(contents) - find_matching_texts(contents, /(zenodo\.org\/api\/files\/)/) + find_matching_texts(contents, %r{(zenodo\.org/api/files/)}) .map do |idx, _text, selected| ReviewDogEmitter.error( path: @path, @@ -723,7 +723,7 @@ def self.fix_md(contents) *check_bad_heading_order(contents), *check_bolded_heading(contents), *snippets_too_close_together(contents), - *zenodo_api(contents), + *zenodo_api(contents) ] end diff --git a/bin/news.rb b/bin/news.rb index d2ff784fea33ce..a9f3b31bf0dc97 100755 --- a/bin/news.rb +++ b/bin/news.rb @@ -122,23 +122,27 @@ def format_news(news) output end -def format_tutorials(added, modified, kind: 'tutorials') +def format_tutorials(added, modified, kind: 'tutorials', updates: true) output = '' - output += "\n\n## #{added.length + modified.length} #{kind}!" if added.length.positive? || modified.length.positive? + count = added.length + if updates + count += modified.length + end + output += "\n\n## #{count} #{kind}!" if count.positive? if added.length.positive? output += "\n\nNew #{kind}:\n\n" output += added.map { |n| n[:md] }.join("\n").gsub(/^/, '- ') end - if modified.length.positive? + if updates && modified.length.positive? output += "\n\nUpdated #{kind}:\n\n" output += modified.map { |n| n[:md] }.join("\n").gsub(/^/, '- ') end output end -def build_news(data, filter: nil) +def build_news(data, filter: nil, updates: true) infix = filter.nil? ? '' : titleize(filter) output = "# GTN #{infix} News for #{NOW.strftime('%b %d')}" newsworthy = false @@ -150,7 +154,8 @@ def build_news(data, filter: nil) o = format_tutorials( data[:added][:tutorials].select { |n| filter.nil? || n[:path] =~ %r{topics/#{filter}} }, - data[:modified][:tutorials].select { |n| filter.nil? || n[:path] =~ %r{topics/#{filter}} } + data[:modified][:tutorials].select { |n| filter.nil? || n[:path] =~ %r{topics/#{filter}} }, + updates: updates ) output += o @@ -159,7 +164,8 @@ def build_news(data, filter: nil) o = format_tutorials( data[:added][:slides].select { |n| filter.nil? || n[:path] =~ %r{topics/#{filter}} }, data[:modified][:slides].select { |n| filter.nil? || n[:path] =~ %r{topics/#{filter}} }, - kind: 'slides' + kind: 'slides', + updates: updates ) output += o newsworthy |= o.length.positive? @@ -214,7 +220,9 @@ def send_news(output, options, channel: 'default') end end else + puts "==============" puts output + puts "==============" end end @@ -224,5 +232,5 @@ def send_news(output, options, channel: 'default') send_news(output, options, channel: channel) end -output, newsworthy = build_news(data, filter: 'single-cell') +output, newsworthy = build_news(data, filter: 'single-cell', updates: false) send_news(output, options, channel: 'single-cell') if newsworthy