Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Bump vendored fileutils to 1.2.0 #7068

Merged
1 commit merged into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 33 additions & 24 deletions lib/bundler/vendor/fileutils/lib/fileutils.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# frozen_string_literal: true

begin
require 'rbconfig'
rescue LoadError
# for make mjit-headers
end

require "bundler/vendor/fileutils/lib/fileutils/version"

#
# = fileutils.rb
#
Expand Down Expand Up @@ -56,7 +65,7 @@
#
# There are some `low level' methods, which do not accept any option:
#
# Bundler::FileUtils.copy_entry(src, dest, preserve = false, dereference = false)
# Bundler::FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
# Bundler::FileUtils.copy_file(src, dest, preserve = false, dereference = true)
# Bundler::FileUtils.copy_stream(srcstream, deststream)
# Bundler::FileUtils.remove_entry(path, force = false)
Expand Down Expand Up @@ -84,13 +93,8 @@
# files/directories. This equates to passing the <tt>:noop</tt> and
# <tt>:verbose</tt> flags to methods in Bundler::FileUtils.
#

require 'rbconfig'

module Bundler::FileUtils

VERSION = "1.1.0"

def self.private_module_function(name) #:nodoc:
module_function name
private_class_method name
Expand All @@ -110,12 +114,14 @@ def pwd
#
# Changes the current directory to the directory +dir+.
#
# If this method is called with block, resumes to the old
# working directory after the block execution finished.
# If this method is called with block, resumes to the previous
# working directory after the block execution has finished.
#
# Bundler::FileUtils.cd('/') # change directory
#
# Bundler::FileUtils.cd('/', :verbose => true) # chdir and report it
# Bundler::FileUtils.cd('/', :verbose => true) # change directory and report it
#
# Bundler::FileUtils.cd('/') do # chdir
# Bundler::FileUtils.cd('/') do # change directory
# # ... # do something
# end # return to original directory
#
Expand Down Expand Up @@ -519,13 +525,12 @@ def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
if destent.exist?
if destent.directory?
raise Errno::EEXIST, d
else
destent.remove_file if rename_cannot_overwrite_file?
end
end
begin
File.rename s, d
rescue Errno::EXDEV
rescue Errno::EXDEV,
Errno::EPERM # move from unencrypted to encrypted dir (ext4)
copy_entry s, d, true
if secure
remove_entry_secure s, force
Expand All @@ -543,11 +548,6 @@ def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
alias move mv
module_function :move

def rename_cannot_overwrite_file? #:nodoc:
/emx/ =~ RbConfig::CONFIG['host_os']
end
private_module_function :rename_cannot_overwrite_file?

#
# Remove file(s) specified in +list+. This method cannot remove directories.
# All StandardErrors are ignored when the :force option is set.
Expand Down Expand Up @@ -698,7 +698,7 @@ def remove_entry_secure(path, force = false)
f.chown euid, -1
f.chmod 0700
}
rescue EISDIR # JRuby in non-native mode can't open files as dirs
rescue Errno::EISDIR # JRuby in non-native mode can't open files as dirs
File.lstat(dot_file).tap {|fstat|
unless fu_stat_identical_entry?(st, fstat)
# symlink (TOC-to-TOU attack?)
Expand Down Expand Up @@ -1145,8 +1145,11 @@ def touch(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)
module StreamUtils_
private

def fu_windows?
/mswin|mingw|bccwin|emx/ =~ RbConfig::CONFIG['host_os']
case (defined?(::RbConfig) ? ::RbConfig::CONFIG['host_os'] : ::RUBY_PLATFORM)
when /mswin|mingw/
def fu_windows?; true end
else
def fu_windows?; false end
end

def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
Expand Down Expand Up @@ -1271,9 +1274,15 @@ def door?
def entries
opts = {}
opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
Dir.entries(path(), opts)\
.reject {|n| n == '.' or n == '..' }\
.map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }

files = if Dir.respond_to?(:children)
Dir.children(path, opts)
else
Dir.entries(path(), opts)
.reject {|n| n == '.' or n == '..' }
end

files.map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
end

def stat
Expand Down
5 changes: 5 additions & 0 deletions lib/bundler/vendor/fileutils/lib/fileutils/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module Bundler::FileUtils
VERSION = "1.2.0"
end