whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Allow local override of repository.yml definitions
Date Sun, 28 Jun 2020 19:08:28 GMT
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 33cfa99  Allow local override of repository.yml definitions
33cfa99 is described below

commit 33cfa998a32b140c5505c7f9d09d90a5a9d39080
Author: Sebb <sebb@apache.org>
AuthorDate: Sun Jun 28 20:08:09 2020 +0100

    Allow local override of repository.yml definitions
---
 lib/whimsy/asf/git.rb |  8 ++++++++
 lib/whimsy/asf/svn.rb | 43 +++++++++++++++++++++++++++++++++----------
 2 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/lib/whimsy/asf/git.rb b/lib/whimsy/asf/git.rb
index 60399a4..f093320 100644
--- a/lib/whimsy/asf/git.rb
+++ b/lib/whimsy/asf/git.rb
@@ -51,6 +51,14 @@ module ASF
         unless @repos
           @@repository_mtime = File.exist?(REPOSITORY) && File.mtime(REPOSITORY)
           @@repository_entries = YAML.load_file(REPOSITORY)
+          repo_override = ASF::Config.get(:repository)
+          if repo_override
+            git_over = repo_override[:git]
+            if git_over
+              Wunderbar.warn("Found override for repository.yml[:git]")
+            end
+            @@repository_entries[:git].merge!(git_over)
+          end
 
           @repos = Hash[Dir[*git].map { |name|
             if Dir.exist? name.untaint
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 70213c7..c5b049c 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -41,6 +41,14 @@ module ASF
         unless @repos
           @@repository_mtime = File.exist?(REPOSITORY) && File.mtime(REPOSITORY)
           @@repository_entries = YAML.load_file(REPOSITORY)
+          repo_override = ASF::Config.get(:repository)
+          if repo_override
+            svn_over = repo_override[:svn]
+            if svn_over
+              Wunderbar.warn("Found override for repository.yml[:svn]")
+            end
+            @@repository_entries[:svn].merge!(svn_over)
+          end
 
           @repos = Hash[Dir[*svn].map { |name| 
             if Dir.exist? name.untaint
@@ -299,16 +307,20 @@ module ASF
         user = env.user
       else
         password = options[:password]
-        user = options[:user] if password
-      end
-      # password was supplied, add credentials
-      if password and not options[:dryrun] # don't add auth for dryrun
-        cmd << ['--username', user, '--no-auth-cache']
-        if self.passwordStdinOK?()
-          stdin = password
-          cmd << ['--password-from-stdin']
-        else
-          cmd << ['--password', password]
+        user = options[:user]
+      end
+      unless options[:dryrun] # don't add auth for dryrun
+        if password or user == 'whimsysvn' # whimsysvn user does not require password
+          cmd << ['--username', user, '--no-auth-cache']
+        end
+        # password was supplied, add credentials
+        if password
+          if self.passwordStdinOK?()
+            stdin = password
+            cmd << ['--password-from-stdin']
+          else
+            cmd << ['--password', password]
+          end
         end
       end
 
@@ -383,6 +395,7 @@ module ASF
     #  :args - string or array of strings, e.g. '-v', ['--depth','empty']
     #  :msg - shorthand for {args: ['--message', value]}
     #  :depth - shorthand for {args: ['--depth', value]}
+    #  :auth - authentication (as [['--username', etc]])
     #  :env - environment: source for user and password
     #  :user, :password - used if env is not present
     #  :verbose - show command (including credentials) before executing it
@@ -400,10 +413,20 @@ module ASF
       
       # Pick off the options specific to svn_ rather than svn
       sysopts = options.delete(:sysopts) || {}
+      auth = options.delete(:auth)
+      if auth
+        # override any other auth
+        [:env, :user, :password].each do |k|
+          options.delete[k]
+        end
+      end
 
 
       cmd, stdin = self._svn_build_cmd(command, path, options)
       sysopts[:stdin] = stdin if stdin
+      if auth
+        cmd.insert(1, auth, '--no-auth-cache')
+      end
 
       Wunderbar.warn cmd.inspect if options[:verbose] # includes auth
 


Mime
View raw message