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 a4dcc3a Avoid Dir.chdir a4dcc3a is described below commit a4dcc3aa303523e02ecaaf3de868e5d2621e8f6a Author: Sebb <s...@apache.org> AuthorDate: Fri Jun 12 16:54:03 2020 +0100 Avoid Dir.chdir See: https://ruby-doc.org/core-2.6.3/Dir.html#method-c-chdir Can throw error in multi-threaded program, so best avoided if possible --- lib/whimsy/asf/git.rb | 7 +++---- lib/whimsy/asf/svn.rb | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/whimsy/asf/git.rb b/lib/whimsy/asf/git.rb index 0f2b48e..60399a4 100644 --- a/lib/whimsy/asf/git.rb +++ b/lib/whimsy/asf/git.rb @@ -53,12 +53,11 @@ module ASF @@repository_entries = YAML.load_file(REPOSITORY) @repos = Hash[Dir[*git].map { |name| - next unless Dir.exist? name.untaint - Dir.chdir name.untaint do + if Dir.exist? name.untaint out, _, status = - Open3.capture3(*%(git config --get remote.origin.url)) + Open3.capture3(*%(git config --get remote.origin.url), {chdir: name}) if status.success? - [File.basename(out.chomp, '.git'), Dir.pwd.untaint] + [File.basename(out.chomp, '.git'), name] end end }.compact] diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb index 5b7b657..811d989 100644 --- a/lib/whimsy/asf/svn.rb +++ b/lib/whimsy/asf/svn.rb @@ -43,12 +43,10 @@ module ASF @@repository_entries = YAML.load_file(REPOSITORY) @repos = Hash[Dir[*svn].map { |name| - next unless Dir.exist? name.untaint - # TODO not sure why chdir is necessary here; it looks like svn info can handle soft links OK - Dir.chdir name.untaint do - out, err = self.getInfoItem('.','url') # svn() checks for path... + if Dir.exist? name.untaint + out, _ = self.getInfoItem(name, 'url') if out - [out.sub(/^http:/,'https:'), Dir.pwd.untaint] + [out.sub(/^http:/,'https:'), name] end end }.compact]