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/28 22:09:16 UTC

[whimsy] branch master updated: Need to trim trailing '/' to be compatible original code

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 6473aa9  Need to trim trailing '/' to be compatible original code
6473aa9 is described below

commit 6473aa9c955c60a89faeea50be9d860164be3ce8
Author: Sebb <se...@apache.org>
AuthorDate: Thu Nov 28 22:07:30 2019 +0000

    Need to trim trailing '/' to be compatible original code
---
 lib/whimsy/asf/svn.rb | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 30e3211..95d4f99 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -481,6 +481,7 @@ module ASF
     end
 
     # update directory listing in /srv/svn/<name>.txt
+    # N.B. The listing includes the trailing '/' so directory names can be distinguished
     # @return filerev, svnrev
     # on error return nil,message
     def self.updatelisting(name, user=nil, password=nil)
@@ -519,20 +520,27 @@ module ASF
     end
 
     # get listing if it has changed
+    # @param
+    # - name: alias for SVN checkout
+    # - tag: previous tag to check for changes
+    # - trimSlash: whether to trim trailing '/', default true
     # @return tag, Array of names
     # or tag, nil if unchanged
     # or Exception if error
-    # The tag happens to be the mtime of the file currently, but that could change
-    # so should be regarded as opaque
-    def self.getlisting(name, tag)
+    # The tag should be regarded as opaque
+    def self.getlisting(name, tag, trimSlash = true)
       listfile, _ = self.listingNames(name)
-      mtime = File.mtime(listfile)
-      if mtime == tag
-        return mtime, nil
+      curtag = "%s:%d" % [trimSlash, File.mtime(listfile)]
+      if curtag == tag
+        return curtag, nil
       else
         open(listfile) do |l|
           filerev = l.gets.chomp
-          return mtime, l.readlines.map(&:chomp)
+          if trimSlash
+            return curtag, l.readlines.map {|x| x.chomp.chomp('/')}
+          else
+            return curtag, l.readlines.map(&:chomp)
+          end
         end
       end
     end