Commit graph

183 commits

Author SHA1 Message Date
Claudio Bley
747dc37a13 Prepare release 1.4.2 2020-07-09 09:53:16 +02:00
dependabot-preview[bot]
41df9f7e0f
Merge pull request #370 from athityakumar/dependabot/bundler/rubocop-tw-0.87.0 2020-07-07 09:05:27 +00:00
Claudio Bley
7fb4c0619a Fix Style/AccessorGrouping offense in fileinfo.rb 2020-07-07 11:01:06 +02:00
Claudio Bley
f27048b1db Add missing require 'set'
Fixes #371
2020-07-07 09:02:20 +02:00
George Pickering
e345cfca8b Update yaml and monkeys to support hexstring colors 2020-05-28 15:02:37 -04:00
Claudio Bley
1a2d3ad6c1 Prepare release 1.4.1 2020-05-10 21:26:43 +02:00
Claudio Bley
f34453bce3 Workaround Errno::ENOENT error in rubygems
When trying to `require` a gem running in an unlinked directory, an exception is
thrown because `Dir.pwd` is called (see rubygems/rubygems#3087).

Until the fix lands in an official release, we monkey patch `Dir.pwd` to return
'/' if a `Errno::ENOENT` exception is raised while loading the colorls gem.

This should work for all Unixes. On Windows, this error cannot happen since you
cannot unlink a directory which is still in use by a process.

Fixes #351.
2020-05-10 21:23:07 +02:00
Claudio Bley
f8674d46df Prepare release 1.4.0 2020-05-08 22:27:51 +02:00
Claudio Bley
53a6bef959 Directly use Unicode symbols in yaml config 2020-05-08 22:12:35 +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
86cfa2f5cf Drop support for Ruby 2.4
It reached EOL on March 31, 2020, and no longer receives patches.

See https://www.ruby-lang.org/en/news/2020/04/05/support-of-ruby-2-4-has-ended/
2020-04-16 22:49:54 +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
Max Ainatchi
8b6ba5ee2f
case-insensitive directory matching
Check directories case-insensitively, per https://github.com/athityakumar/colorls/issues/325
2020-03-16 17:32:17 -04:00
Claudio Bley
5640a6e104
Prepare release 1.3.3 2020-01-31 09:27:21 +01:00
Claudio Bley
6b2cbdc17d Fix exception when permission denied on symlinks
Fixes #338.
2020-01-31 08:57:55 +01:00
Claudio Bley
f451476238
Prepare release 1.3.2
[skip ci]
2020-01-24 09:53:08 +01:00
Claudio Bley
fb39a9da6d Correct git status for directories without changes
git does not report any status for empty directories, and it also does not
report any status for directories without any modified, untracked or ignored
files.

To correctly show the status, we need to check whether the directory is empty if
git did not report any status codes. When empty, show it as "not interesting",
otherwise the "no changes" green check mark is shown.

Note, I am specifically not using the untracked marker, as that would mean there
is some interesting file inside the directory which could be added.

Fixes #334.
2020-01-24 09:22:43 +01:00
Claudio Bley
d0244c2aa7 Fix git output showing no changes
Fixes #336.
2020-01-23 14:41:29 +01:00
Claudio Bley
6c51cd974d Bump VERSION to 1.3.1 2020-01-08 22:32:04 +01:00
Claudio Bley
d4aa862f79 Fix deprecation warning on Ruby 2.7
```
lib/colorls/flags.rb:50: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
lib/colorls/core.rb:5: warning: The called method `initialize is defined here
```
2020-01-07 22:08:02 +01:00
Claudio Bley
141a8e5fbe Fix rubocop offense for Style/MultilineWhenThen 2019-07-24 18:21:20 +02:00
Claudio Bley
ac9734d879 Align number of link column in long listing
This fixes the misalignment of files in a long listing when some files have a
different number of characters in the links column.

Instead of iterating three times over the @contents array, in order to compute
the sizes of the variant columns, use a single loop to compute the maximum size
for each column in a one pass.
2019-07-07 23:09:22 +02:00
Claudio Bley
dfd572310a Add --format=vertical and -C flags
* add and wire up `VerticalLayout` which is now the default
* adapt flags spec to use single-column layout for testing sort order
  since the output is hard to verify when in vertical format

Fixes #189.
2019-07-01 23:27:53 +02:00
Claudio Bley
d528bf18ef Introduce Layout classes and use them
* add `Layout` base class which contains the base (binary) algorithm
  for finding the maximum amount of columns fitting the given limit
* add `HorizontalLayout` and use it in `Core`
* add `SingleColumnLayout` and use it in `Core`
2019-07-01 23:16:33 +02:00
Claudio Bley
1dad6e0f15 Only add padding when necessary
Only when using more than one column, empty space should be added.

Instead of multiple print calls, we construct the complete line and print it.
2019-07-01 23:16:33 +02:00
Claudio Bley
41c933658b Simplify formatting in ColorLS#fetch_string 2019-07-01 23:16:33 +02:00
Paul McCarthy
ec0ed26458 Fix typo accross => across 2019-07-01 23:12:45 +02:00
Claudio Bley
97c9570437 Refactor git status handling, add some tests 2019-07-01 22:59:27 +02:00
Claudio Bley
56a0ec6903 Show number of hard links in long listing
Fixes #293
2019-06-30 19:05:00 +02:00
Claudio Bley
41669c94a3 Release version 1.2.0 2019-04-09 18:52:11 +02:00
Claudio Bley
7454814894 Handle git status for . and .. properly
The git status is only computed for the given directory and is stored as
a Hash mapping relative paths to their mode string.

For a directory, the git status is comprised of all the statuses of its files
itself and all its sub directories.

The current directory's prefix is just an empty string matching all files inside
the `@git_status` Hash.

Asking for the status of the parent directory is pointless, we do not compute it
(yet).
2019-04-08 21:47:18 +02:00
Claudio Bley
c0d9266378 Fix spec failures due to calling exit 2019-03-14 23:37:55 +01:00
Claudio Bley
6d6d121553 Add --human-readable option for compatibility with GNU ls
* make `-h` an alias for `--human-readable`
* both options are simply ignored when used with an argument or another option
* running `colorls -h` still shows the help text since just as before
2019-03-14 14:48:19 +01:00
Claudio Bley
c92b5c59a4 Fix git status reporting for file arguments 2019-03-11 23:42:38 +01:00
Claudio Bley
6f500722d0 Add String#delete_prefix method for Ruby < 2.5 2019-03-11 23:17:52 +01:00
Claudio Bley
b5caa35de5 Compute git status relative to the actual directory
Using the `--show-prefix` option for `git ref-parse` simplifies determining the
status for the child items.

Previsouly, `File.realdirpath` was used to determine an absolute path, but this
method returns a path without symlinks. This caused status to be reported about
the link target instead of the symlink.
2019-03-11 23:17:52 +01:00
Alex Cano
c60a2ebec8 Add the option to handle depth for the tree flag (#253)
* Add the option to handle depth for the tree flag

* Update README to describe the new option for the tree flag

* Add tests
2019-01-11 07:36:02 +01:00
Claudio Bley
e02b30a111 Drop support for Ruby 2.2
It reached EOL on 20th Jun 2018 and no longer receives patches.

* set required Ruby version to >= 2.3 in spec file
* set rubocop's TargetRubyVersion to 2.3 and fix all the offenses
2019-01-04 12:08:06 +01:00
Claudio Bley
9c266c9fda Make ColorLS::Git a module instead of a class
There is no reason it should inherit from `Core`.
2018-12-29 17:23:07 +01:00
Claudio Bley
306bcd3cbc Fix warning about method redefinement
`lib/colorls/monkeys.rb:26: warning: method redefined; discarding old sum`
2018-12-29 17:13:33 +01:00
Claudio Bley
73e036c939 Fix warning about unintialized instance variable
`warning: instance variable @git_status not initialized`
2018-12-29 16:46:51 +01:00
Claudio Bley
f0e53937de Fix rubocop warnings 2018-12-28 18:55:57 +01:00
Justin Hallquist
54bafa03f0 add forwardable dependency 2018-11-20 08:38:25 -08:00
Claudio Bley
7a9ea25808
Merge pull request #229 from avdv/socket-chardev-blockdev
Add support for special files
2018-11-12 08:23:51 +01:00
Claudio Bley
5d6fe50edd Remove _keys arrays from Core, use key? instead
Instead of searching through an Array, it is much better querying a Hash for a
key.
2018-10-21 23:27:38 +02:00
Claudio Bley
4a0ece2908 Add support for special files
Like sockets, character and block devices.
2018-10-21 23:14:21 +02:00
Claudio Bley
f3e9186ee2 Add --format and -x options
Both are also supported by GNU ls, although currently not all formats are
supported.

This change lays ground for implementing column based formatting and also
supports using a pager with colorls keeping the formatting intact:

`colorls --color -x | less --tabs=4 -RFX`
2018-10-20 10:50:30 +02:00
Claudio Bley
6b972de57d Add --color option
This option works the same as for GNU ls, although if not specified colorization
is on by default (the `auto` mode).

Using `--color` is equivalent to `--color=always`.
2018-10-20 00:01:31 +02:00
Jason Schweier
7bb0f564d5 Fix alignment for file sizes
File size can be up to 1023 B/KiB/etc.
The simplest solution is to allow 4 characters for alignment.
2018-10-13 14:49:48 -04:00
Claudio Bley
127eb510cd Check whether Etc.getpwuid/getgrid returns nil
On Microsoft Windows, the File.Stat information always has the `uid` and `gid`
set to `0`. Also, the Etc functions simply return `nil`.

Fixes #220.
2018-10-05 22:15:02 +02:00