Commit graph

97 commits

Author SHA1 Message Date
Ayush Poddar
c5fdcf6e92 relevant feature spec 2023-04-30 02:45:55 +05:30
Ayush Poddar
86daeef7ec rubocop fixes 2023-04-30 02:43:41 +05:30
Ayush Poddar
1001aa2832 refactor: DRY the fileinfo stub for spec readability 2023-04-30 02:31:39 +05:30
Ayush Poddar
4c5ef39093 fix the stubs in specs 2023-04-30 02:31:39 +05:30
Ayush Poddar
5f3b8807d3 spec fix: not more than 3 lines in the spec output 2023-04-26 18:42:22 +05:30
Ayush Poddar
69988e1b2e improve the regex 2023-04-19 16:48:38 +05:30
Ayush Poddar
81ced364a4 fix: fix failing spec due to new fixture file 2023-04-19 16:33:08 +05:30
Ayush Poddar
7eda794a07 spec: add spec to flags spec 2023-04-19 16:32:11 +05:30
t-mangoe
cbad7578a9 change the option name from '-H' to '-L' 2023-02-11 13:39:46 +09:00
t-mangoe
0e2bed11ad Merge branch 'master' into issue_515 2023-02-11 09:47:22 +09:00
Claudio Bley
33d4ac066a Auto-correct rubocop offenses 2023-01-25 21:08:12 +01:00
t-mangoe
77cf0b0770 add '-H' option 2023-01-07 10:36:26 +09:00
Claudio Bley
b053d33309 Workaround NameError in diffy 3.4.2
See https://github.com/samg/diffy#119
2022-07-04 17:11:19 +02:00
Claudio Bley
3ffea2976a Correct Style/OpenStructUse offenses
Replace with `Struct`, or use `instance_double` in tests.
2022-05-13 21:47:03 +02:00
Claudio Bley
60cf569776 Pass a null device instead of explicitly closing stderr
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.
2022-04-30 09:13:56 +02:00
Claudio Bley
c7aa167952
Merge pull request #519 from athityakumar/ci-on-windows 2022-04-29 16:14:46 +02:00
Claudio Bley
6d8e229cb3 Fix "shows the file in the linked directory" test on Windows
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.
2022-04-29 15:58:03 +02:00
Claudio Bley
ef86bcf66e Fix rubocop offense for RSpec/VerifiedDoubleReference
RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles.
2022-04-26 22:06:50 +02:00
Claudio Bley
dbdcd142a0 Fix --inode check
The range of inodes is roughly 2 to 2^32 (depending on the filesystem).

The test failed on CI, since the inode number was a 6-digit number.
2022-04-04 21:52:22 +02:00
t-mangoe
67459d0ef9 Merge branch 'master' into no-hardlinks 2022-03-26 16:25:05 +09:00
Claudio Bley
d5691d69c0 Fix arguments of with --inode flag check 2022-03-21 09:09:01 +01:00
goar5670
c1469a4196 Cover the new --inode flag with tests 2022-03-20 02:33:01 +03:00
bl7awy
e9166e8c15 Resolve long line offense 2022-03-18 23:41:36 +03:00
bl7awy
f43c9b9e7e Add tests for --report flag 2022-03-18 22:28:26 +03:00
Claudio Bley
6b35f942aa Fix offenses newly reported by rubocop-rspec
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.
2022-02-28 21:37:11 +01:00
t-mangoe
ced1cfebff add --no-hardlinks option 2022-02-19 09:28:10 +09:00
t-mangoe
90aaa4d0b6 change time/date format in '+FORMAT' 2021-11-13 09:21:15 +09:00
t-mangoe
d7e7ddd01e add --time-style option in long style format 2021-10-02 08:40:48 +09:00
t-mangoe
566ea3b45a add '--indicator-style' option 2021-07-19 10:24:25 +02:00
Claudio Bley
17b2142c48 Use File.extname to determine file extension
Fixes #441.
2021-01-29 10:21:24 +01:00
Claudio Bley
0048e3883a Group and process arguments in groups of files and directories
Fixes #233
2021-01-15 11:03:21 +01:00
Claudio Bley
2eeb30fc44 Refactor git_subdir_status
Instead of simply returning the opened pipe, consume the output
and yield the `mode, file` tuple to the given block.
2021-01-15 11:03:21 +01:00
Claudio Bley
373fb67003 Fix error when git is not installed 2021-01-15 11:03:21 +01:00
Claudio Bley
0ad630da4c Properly encode hyperlinks with special characters
This also works on Windows now, since absolute paths include a colon after the
drive letter, the `file:` URI needs to start with a triple slash.
2021-01-15 11:03:21 +01:00
Claudio Bley
e39703a3b5 Fix rubocop-rspec offenses or disable them 2020-12-23 22:32:36 +01:00
Claudio Bley
7f0af24ada Use rubocop's default include configuration and fix all offenses 2020-12-23 22:32:36 +01:00
Claudio Bley
d0df25d35d Re-use CoreLS::Core instance
Only initialize colors and flags once.
2020-12-22 14:01:55 +01:00
Claudio Bley
64a42c105d
Merge pull request #417 from t-mangoe/add-option-o-g
add -o and -g options.
2020-12-07 22:54:17 +01:00
Claudio Bley
175f2dc225
Correct description of -G -l check 2020-12-07 21:32:13 +01:00
t-mangoe
0d0a1d96ca add -G option 2020-12-05 09:14:12 +09:00
t-mangoe
39be15c6aa add -o and -g options. 2020-11-21 10:17:32 +09:00
Claudio Bley
a59258b749 Clean up monkey patches
* delete `#remove` method
* remove `#delete_prefix` spec, it was only used for Ruby < 2.5 (see 86cfa2f5cf)
* add specifications for `#colorize` and `#uniq`
2020-11-02 08:45:07 +01:00
Claudio Bley
8035deaab0 Ensure to use file_encoding for arguments
Fixes #377
2020-10-31 21:54:45 +01:00
t-mangoe
9992218ea4 make executables bold 2020-10-17 15:15:39 +09:00
Claudio Bley
d4110e4ac7 Officially support Windows
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)
2020-10-09 18:26:50 +02:00
t-mangoe
64b1891c2c Set exit status code when specified path doesn't exist
Similar to GNU ls, status code `2` is reported if an argument given on the
command line does not exist.

Close #397
2020-10-07 09:58:01 +02:00
Claudio Bley
52b8c3489d Fix unrecognized files count and colorization
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.
2020-09-07 20:38:42 +02:00
Claudio Bley
8379ba64db Fix newly reported offenses
* 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
2020-09-03 23:18:18 +02:00
Claudio Bley
825e9f711c Only warn if locale settings are broken
Keep running if calling `setlocale` fails, because of invalid locale settings.

Fixes #335.
2020-04-17 00:21:11 +02:00
Claudio Bley
73e4de9378 Use ASCII_8BIT for paths and directory entries
On Unix systems the encoding of file names is specified by the user via the
locale settings.

In order to avoid encoding problems simply read file names in ASCII 8 bit
encoding and try to convert to the external encoding while replacing undefined
characters.

Also, does not show an icon if the external encoding does not support it and
shows a `=` instead of a check mark for git status.

Fixes #352.
2020-04-16 21:58:39 +02:00