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/25 23:51:40 UTC

[whimsy] branch master updated: Allow code to look up SVN URLs for aliases with no checkouts

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 de591bf  Allow code to look up SVN URLs for aliases with no checkouts
de591bf is described below

commit de591bf91d18b89a6c044f38b4d9be66ccd55c5e
Author: Sebb <se...@apache.org>
AuthorDate: Mon Nov 25 23:51:36 2019 +0000

    Allow code to look up SVN URLs for aliases with no checkouts
---
 lib/spec/lib/svn_spec.rb | 49 +++++++++++++++++++++++++++++++++++++++++++++++-
 lib/whimsy/asf/svn.rb    | 25 ++++++++++++++++++------
 repository.yml           | 11 +++++++++++
 3 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/lib/spec/lib/svn_spec.rb b/lib/spec/lib/svn_spec.rb
index bfe9eea..0a491a1 100644
--- a/lib/spec/lib/svn_spec.rb
+++ b/lib/spec/lib/svn_spec.rb
@@ -5,13 +5,20 @@ require 'spec_helper'
 require 'whimsy/asf'
 
 describe ASF::SVN do
-
+  
+  # repo_entry should only include repos that have local workspaces
+  
   describe "ASF::SVN.repo_entry" do
     it "should return string for 'templates'" do
       res = ASF::SVN.repo_entry('templates')
       expect(res.class).to equal(Hash)
     end
 
+    it "should return nil for 'Bills'" do
+      res = ASF::SVN.repo_entry('Bills')
+      expect(res.class).to equal(NilClass)
+    end
+
     it "should return nil for '__templates'" do
       res = ASF::SVN.repo_entry('__templates')
       expect(res.class).to equal(NilClass)
@@ -33,6 +40,7 @@ describe ASF::SVN do
 
   end
 
+  # svnurl should include aliases
 
   describe "ASF::SVN.svnurl" do
     it "should return URL for 'templates'" do
@@ -41,6 +49,12 @@ describe ASF::SVN do
       expect(res).to match(%r{https://.+/templates}) 
     end
   
+    it "should return URL for 'Bills'" do
+      res = ASF::SVN.svnurl('Bills')
+      expect(res.class).to equal(String)
+      expect(res).to match(%r{https://.+/Bills}) 
+    end
+  
     it "should return nil for '__templates'" do
       res = ASF::SVN.svnurl('__templates')
       expect(res.class).to equal(NilClass)
@@ -62,4 +76,37 @@ describe ASF::SVN do
     end
   
   end
+
+  # repo_entries should exclude aliases
+
+  describe "ASF::SVN.repo_entries" do
+    it "should return hash with templates but not Bills" do
+      res = ASF::SVN.repo_entries
+      expect(res.class).to equal(Hash)
+      expect(res['templates'].class).to equal(Hash)
+      expect(res['Bills']).to equal(nil)
+    end
+    
+  end
+
+  # find returns local workspace so excludes aliases
+
+  describe "ASF::SVN.find" do
+    it "should return string for 'templates'" do
+      res = ASF::SVN.find('templates')
+      expect(res.class).to equal(String)
+    end
+  
+    it "should return nil for 'Bills'" do
+      res = ASF::SVN.find('Bills')
+      expect(res.class).to equal(NilClass)
+    end
+  
+    it "should return nil for '__templates'" do
+      res = ASF::SVN.find('__templates')
+      expect(res.class).to equal(NilClass)
+    end
+  
+  end
+
 end
\ No newline at end of file
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 49ecbe9..90e4392 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -68,13 +68,14 @@ module ASF
       self.find!(name)
     end
 
-    # Get all the SVN repo entries
+    # Get the SVN repo entries corresponding to local checkouts
+    # Excludes those that are present as aliases only
     def self.repo_entries
-      self.repos # refresh @@repository_entries
-      @@repository_entries[:svn]
+      self._all_repo_entries.reject{|k,v| v['depth'] == 'skip'}
     end
 
     # fetch a repository entry by name
+    # Excludes those that are present as aliases only
     def self.repo_entry(name)
       self.repo_entries[name]
     end
@@ -89,6 +90,7 @@ module ASF
     end
 
     # get private and public repo names
+    # Excludes aliases
     # @return [['private1', 'privrepo2', ...], ['public1', 'pubrepo2', ...]
     def self.private_public
       prv = []
@@ -104,8 +106,9 @@ module ASF
     end
 
     # fetch a repository URL by name
+    # Includes aliases
     def self.svnurl(name)
-      entry = self.repo_entry(name) or return nil
+      entry = self._all_repo_entries[name] or return nil
       url = entry['url']
       unless url # bad entry
         raise Exception.new("Unable to find url attribute for SVN entry #{name}")
@@ -114,6 +117,7 @@ module ASF
     end
 
     # fetch a repository URL by name - abort if not found
+		# Includes aliases
     def self.svnurl!(name)
       entry = self.svnurl(name)
       unless entry
@@ -124,6 +128,7 @@ module ASF
 
     # find a local directory corresponding to a path in Subversion.  Returns
     # <tt>nil</tt> if not found.
+		# Excludes aliases
     def self.find(name)
       return @testdata[name] if @testdata[name]
 
@@ -391,11 +396,19 @@ module ASF
         FileUtils.rm_rf tmpdir
       end
     end
-  end
 
-  def self.classify_repos()
+    private
     
+    # Get all the SVN entries
+    # Includes those that are present as aliases only
+    # Not intended for external use
+    def self._all_repo_entries
+      self.repos # refresh @@repository_entries
+      @@repository_entries[:svn]
+    end
+
   end
+
 end
 
 if __FILE__ == $0 # local testing
diff --git a/repository.yml b/repository.yml
index fa09e20..fad9854 100644
--- a/repository.yml
+++ b/repository.yml
@@ -1,3 +1,7 @@
+#
+# This file should not be processed directly
+# Please use the ASF::SVN and ASF::Git APIs instead
+#
 ---
 :git:
 
@@ -9,9 +13,16 @@
     url: https://github.com/letsencrypt/letsencrypt
 
 # N.B. the names in the section below should not be changed as they are used by Ruby
+# Entries that are not intended to have local workspaces are indicated by: 'depth: skip'
+# Such entries are for url lookup only, e.g. Bills
 
 :svn:
 
+  Bills:
+    url: private/financials/Bills
+    depth: skip
+    
+
   Meetings:
     url: private/foundation/Meetings