When calling git any error messages should be suppressed (e.g. if an directory
is not inside a git repository).
Closing the stderr output when calling `IO.popen` works fine on POSIX systems,
but on Windows it does not and spits out a warning for every invocation:
```
git.rb:44: warning: cannot close fd before spawn
```
Fixes#517.
When running on Windows this test failed with:
```
Failures:
1) ColorLS::Flags symlinked directory with trailing separator shows the file in the linked directory
Failure/Error: expect { subject }.to output(/yaml_sort_checker.rb/).to_stdout
expected block to output /yaml_sort_checker.rb/ to stdout, but output " Supportlink \n"
Diff:
@@ -1 +1 @@
-/yaml_sort_checker.rb/
+ Supportlink
# ./spec/color_ls/flags_spec.rb:329:in `block (3 levels) in <top (required)>'
```
This is due to the different handling of paths to a symlink with a trailing
slash / backslash.
`File.lstat(x).directory?` returns
OS | x | value
----------------------------
Windows | symlink\ | false
Windows | symlink | false
Linux | symlink/ | true
Linux | symlink | false
This could be fixed in colorls by handling a trailing (back)slash specifically,
but I am unsure whether that is the right thing to do on Windows.
The pessimistic version contraint on rubocop-rspec permitted minor version
updates of the dependency, which broke the tests again since version 2.9.0
introduced / changed offenses.
Allow only the patch version to increase automatically to avoid this in the future.
* delete `#remove` method
* remove `#delete_prefix` spec, it was only used for Ruby < 2.5 (see 86cfa2f5cf)
* add specifications for `#colorize` and `#uniq`
On Windows, MRI Ruby uses the `FindFirstFileW` et. al. kind of functions with
wide character paths and constantly converts from multi-byte to wide character
encoding back and forth when calling any methods on `File` or `Dir`.
This means that when using `Encoding::ASCII_8BIT` for reading directory entries,
that this does not round trip properly, if a file name contains unicode
characters. That is because Ruby assumes the path string is encoded in Windows
Codepage 1252[1].
* skip symlink test if files were checked out from git as textual symlinks on
Windows
* use UTF-8 encoding on Windows, since this properly round-trips between
multi-byte and wide character encoding
* travis: windows job no longer is allowed to fail
[1]: 946cd6c534/win32/file.c (L131-L134)
A *file* is assigned a generic icon / glyph in `files.yaml`, so looking up
`:file` in the corresponding hash always succeeds, but `:file` is also used as
the fallback key if a file's extension is not recognized.
First determining the color and group of a given file before falling back to
the `:file` key fixes this issue.
* Style/MultilineWhenThen: Do not use then for multiline when statement
* Style/StringConcatenation: Prefer string interpolation to string concatenation
* Style/OptionalBooleanParameter: Use keyword arguments when defining method with boolean argument
* Style/GlobalStdStream: Use $stderr instead of STDERR
* Style/GlobalStdStream: Use $stdout instead of STDOUT