You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/11/27 01:01:12 UTC

[whimsy] branch master updated: More info; improved error handling

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 ec7ae90  More info; improved error handling
     new 3a80aa8  Merge branch 'master' of https://gitbox.apache.org/repos/asf/whimsy
ec7ae90 is described below

commit ec7ae90396a2145f8a88a63405830fd63bd82cc2
Author: Sebb <se...@apache.org>
AuthorDate: Wed Nov 27 01:00:33 2019 +0000

    More info; improved error handling
---
 lib/whimsy/asf/svn.rb | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index cc9f3b2..e4dd86f 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -420,28 +420,39 @@ module ASF
     end
 
     # update directory listing in /srv/svn/<name>.txt
+    # @return filerev, svnrev
+    # on error return nil,message
     def self.updatelisting(name, user=nil, password=nil)
+      url = self.svnurl(name)
+      unless url
+        return nil,"Cannot find URL"
+      end
       listfile = File.join(ASF::Config.root,'svn',"%s.txt" % name)
-      filerev = nil
-      lastrev = 0
+      filerev = "0"
+      svnrev = "?"
       begin
         open(listfile) do |l|
           filerev = l.gets.chomp
         end
       rescue
       end
-      url = self.svnurl(name)
-      lastrev = self.getInfoItem(url,'last-changed-revision',user,password)
-      if filerev == lastrev
-        puts "#{listfile}: #{filerev}"
+      svnrev, err = self.getInfoItem(url,'last-changed-revision',user,password)
+      if svnrev
+        begin
+          unless filerev == svnrev
+            list = self.list(url, user, password)
+            open(listfile,'w') do |w|
+              w.puts svnrev
+              w.puts list
+            end 
+          end
+        rescue Exception => e
+          return nil,e.inspect
+        end
       else
-        puts "#{listfile}: #{filerev} SVN: #{lastrev}"
-        list = self.list(url, user, password)
-        open(listfile,'w') do |w|
-          w.puts lastrev
-          w.puts list
-        end 
+        return nil,err
       end
+      return filerev,svnrev
 
     end