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 9606aaad += WithdrawalRequestFiles.findpath
9606aaad is described below

commit 9606aaad318c498f23b56426411e1ce6eecf5b3f
Author: Sebb <[email protected]>
AuthorDate: Tue Sep 10 21:46:21 2024 +0100

    += WithdrawalRequestFiles.findpath
---
 lib/whimsy/asf/documents.rb | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib/whimsy/asf/documents.rb b/lib/whimsy/asf/documents.rb
index 0e87ef23..eab271b7 100644
--- a/lib/whimsy/asf/documents.rb
+++ b/lib/whimsy/asf/documents.rb
@@ -269,5 +269,24 @@ module ASF
     def self.refreshnames(storedates, env)
       ASF::DocumentUtils.update_cache(STEM, env, storedates: storedates, 
force: true)
     end
+  
+    # Find the file name (or directory) that matches a person
+    # return [svnpath, name] if found
+    # return nil if not found
+    def self.findpath(userid)
+      reqdir = ASF::SVN.svnpath!(STEM)
+      list, err = ASF::SVN.listnames(reqdir)
+      if list
+        names = list.select{|x| x.start_with?("#{userid}.") or x == 
"#{userid}/"} # if there is a sig, then files are in a subdir
+        if names.size == 1
+          name = names.first
+          path = ASF::SVN.svnpath!(STEM, name)
+          return [path, name]
+        end
+        return nil
+      else
+        raise Exception.new("Failed to list #{STEM} files #{err}")
+      end
+    end
   end
 end

Reply via email to