This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 5bb4688  Only read calendar once as part of ASF::SVN.update
5bb4688 is described below

commit 5bb46886ad6c2d69420062d829db8485bbcfdef0
Author: Sebb <s...@apache.org>
AuthorDate: Tue Jul 7 21:57:28 2020 +0100

    Only read calendar once as part of ASF::SVN.update
---
 www/board/agenda/views/actions/publish.json.rb | 38 ++++++++++++--------------
 1 file changed, 17 insertions(+), 21 deletions(-)

diff --git a/www/board/agenda/views/actions/publish.json.rb 
b/www/board/agenda/views/actions/publish.json.rb
index 0233b69..ad5adc1 100755
--- a/www/board/agenda/views/actions/publish.json.rb
+++ b/www/board/agenda/views/actions/publish.json.rb
@@ -41,8 +41,6 @@ CALENDAR = File.join(BOARD_SITE, 'calendar.mdtext')
   ASF::SVN.svn('update', dir) # TODO: does this need auth?
 end
 
-calendar = File.read(CALENDAR)
-
 # clean up summary
 @summary = @summary.gsub(/\r\n/,"\n").sub(/\s+\Z/,'') + "\n"
 
@@ -52,22 +50,6 @@ date = Date.parse(@date.gsub('_', '-'))
 year = date.year
 fdate = date.strftime("%d %B %Y")
 
-# add year header
-unless calendar.include? "##{year}"
-  calendar[/^()#.*Board meeting minutes #/,1] =
-    "# #{year} Board meeting minutes # {##{year}}\n\n"
-end
-
-# add summary
-if calendar.include? "\n- [#{fdate}]"
-  calendar.sub! /\n-\s+\[#{fdate}\].*?(\n[-#])/m, "\n" + @summary + '\1'
-else
-  calendar[/# #{year} Board meeting minutes #.*\n()/,1] = "\n" + @summary
-end
-
-# remove from calendar
-calendar.sub! /^(\s*[*-]\s+#{fdate}\s*?\n)/, ''
-
 minutes = "board_minutes_#{@date}.txt"
 
 #Commit the Minutes
@@ -88,10 +70,24 @@ ASF::SVN.update MINUTES, @message, env, _ do |tmpdir|
 end
 
 # Update the Calendar
-if File.read(CALENDAR) != calendar
-  ASF::SVN.update CALENDAR, @message, env, _ do |tmpdir, old_contents|
-    calendar
+ASF::SVN.update CALENDAR, @message, env, _ do |tmpdir, calendar|
+  # add year header
+  unless calendar.include? "##{year}"
+    calendar[/^()#.*Board meeting minutes #/,1] =
+      "# #{year} Board meeting minutes # {##{year}}\n\n"
+  end
+
+  # add summary
+  if calendar.include? "\n- [#{fdate}]"
+    calendar.sub! /\n-\s+\[#{fdate}\].*?(\n[-#])/m, "\n" + @summary + '\1'
+  else
+    calendar[/# #{year} Board meeting minutes #.*\n()/,1] = "\n" + @summary
   end
+
+  # remove from calendar
+  calendar.sub! /^(\s*[*-]\s+#{fdate}\s*?\n)/, ''
+
+  calendar
 end
 
 # Clean up board directory

Reply via email to