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 b3e3bbd5 Check for invalid revision; catchup on startup
b3e3bbd5 is described below
commit b3e3bbd566f76a921f86b7e740910a210ca379d1
Author: Sebb <[email protected]>
AuthorDate: Sun Mar 3 23:41:22 2024 +0000
Check for invalid revision; catchup on startup
---
tools/pubsub-ci-email.rb | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/tools/pubsub-ci-email.rb b/tools/pubsub-ci-email.rb
index 390ce0a0..25be5102 100755
--- a/tools/pubsub-ci-email.rb
+++ b/tools/pubsub-ci-email.rb
@@ -215,11 +215,11 @@ if $0 == __FILE__
ASF::Mail.configure
# show initial start
- previous_revision = File.read(PREVIOUS_REVISION).chomp
+ previous_revision = File.read(PREVIOUS_REVISION).chomp.sub('r','').to_i
svnrev, err = ASF::SVN.getInfoItem(SOURCE_URL, 'last-changed-revision')
if svnrev
- latest = "r#{svnrev}"
+ latest = svnrev.to_i
else
puts stamp err
latest = 'unknown'
@@ -228,8 +228,17 @@ if $0 == __FILE__
subject = "Started pubsub-ci-email from revision #{previous_revision},
current #{latest}"
puts stamp subject
+ if previous_revision > latest
+ error = "ERROR: Previous revision #{previous_revision} > latest
#{latest}!!"
+ else
+ error = nil
+ end
+
body = <<~EOD
This is a test email
+ Previous revision #{previous_revision}
+ Current revision #{latest}
+ #{error}
Generated by #{__FILE__}
EOD
@@ -241,6 +250,8 @@ if $0 == __FILE__
end
mail.deliver!
+ raise ArgumentError.new error if error
+
options = {}
args = ARGV.dup # preserve ARGV for relaunch
@@ -257,6 +268,9 @@ if $0 == __FILE__
pubsub_CRED = File.read(pubsub_FILE).chomp.split(':') or raise
ArgumentError.new "Missing credentials"
end
+ # Catchup on any missed entries
+ handle_change(latest) if latest > previous_revision
+
puts stamp(pubsub_URL)
PubSub.listen(pubsub_URL, pubsub_CRED, options) do |event|
puts stamp event if options[:debug]