Commit Graph

729 Commits

Author SHA1 Message Date
Benjamin Sago
79feeba67d Move the functions in output to their own module
It didn’t feel quite right to have stand-alone functions in the module root file, which is usually just reserved for modules and exports.
2017-05-01 15:17:07 +01:00
Benjamin Sago
3ebc22580a Merge branch 'awkward-file-names'
Fixes #156.
2017-05-01 15:11:35 +01:00
Benjamin Sago
4249cf0fcc Give control characters their own colour 2017-05-01 15:10:39 +01:00
Benjamin Sago
eb7e53ef6c Only highlight escaped characters in file names
Rather than the *entire* file name.

The current method is extremely inefficient, but having control characters in file names is also extremely uncommon; it’s something that should be fixed, only eventually.
2017-05-01 15:06:37 +01:00
Benjamin Sago
a53c268c54 Measure, rather than calculating, cell widths
exa deals with cells and widths a lot: the items in a grid need to be aligned according to their *contents’* widths, rather than the length of their strings, which often included ANSI escape characters. As an optimisation, it used to calculate this separately based on the filename, and dealing with any extra characters (such as the classify ones) in that function too.

Recently, though, file names have become a lot more complicated. Classification added zero to one extra characters, and now with escaped control characters in file names, it’s not so easy to calculate the display width of a filename.

This commit removes the function that calculated the width, in favour of building the output string (it’s going to be displayed anyway) and just getting the width of what it displays instead.
2017-05-01 14:11:16 +01:00
Benjamin Sago
28fce347ff Initial implementation of file name escaping
It doesn’t do a perfect job, but at least there aren’t newlines littering the output anymore.
2017-05-01 12:23:28 +01:00
Benjamin Sago
56f859dd36 Add some awkward file name testcases 2017-05-01 12:22:57 +01:00
Benjamin Sago
70f8ae6e20 Move “coloured file name” into its own function 2017-05-01 11:50:52 +01:00
Kevin Ballard
b494c9c0f0 Always rebuild with make
`make` doesn't know how to tell if it needs to recompile or not, but
`cargo` does, so we should always call through into `cargo`.
2017-04-30 13:33:05 -07:00
Benjamin Sago
6b008a6177 Add tests for relative symlinks 2017-04-30 11:58:29 +01:00
Benjamin Sago
91ad09e188 Merge pull request #169 from kballard/symlink_leading_path
Don't prepend current path to symlink targets
2017-04-30 11:13:00 +01:00
Benjamin Sago
58b6d3e50c Make the Vagrant provisioning process quieter 2017-04-30 11:06:52 +01:00
Benjamin Sago
c49820a935 Merge pull request #171 from kballard/symlink_to_root
Handle linking to root directories better
2017-04-30 09:00:59 +01:00
Benjamin Sago
262dbe890b Merge pull request #172 from kballard/vagrant_up_date
Fix Vagrantfile
2017-04-30 08:32:12 +01:00
Kevin Ballard
f8624ed308 Don't prepend current path to symlink targets
It's confusing, and `ls` doesn't do this either. We're not prepending
the current path to all of the directory entries, and the user is going
to interpret the symlink target as relative to the directory containing
the symlink.
2017-04-29 15:01:54 -07:00
Kevin Ballard
e73eb2dc1a Fix Vagrantfile 2017-04-29 14:53:47 -07:00
Kevin Ballard
4beb7b6cb1 Handle linking to root directories better
We don't need a special case for this.
2017-04-29 14:38:28 -07:00
Benjamin Sago
0c69eeca07 Further tests for printing out directory names
., .., and / always seem to cause problems.
2017-04-29 11:52:44 +01:00
Benjamin Sago
956aa85b3b Special-case the root directory when linking to it
It’s the only file where its path is the same as its file name, and has been the source of numerous bugs in the past… this special-case isn’t very clean, but it works.
2017-04-29 11:52:10 +01:00
Benjamin Sago
f8b82642a6 oops
I think I took this off to see how the output was different. Which means there should really be a better way to check how the output is different, other than running the command and looking!
2017-04-29 11:03:43 +01:00
Benjamin Sago
7d6c1eb724 Merge pull request #168 from kballard/dot_filename
Print . and .. components properly
2017-04-29 10:58:39 +01:00
Benjamin Sago
3d97dffc24 Tests for the directory path fix 2017-04-29 10:56:17 +01:00
Benjamin Sago
e671217d60 Merge pull request #167 from kballard/two_path_components
Print paths with 2 components properly
2017-04-29 10:43:08 +01:00
Benjamin Sago
456fa287d2 Tests for classify and special file types 2017-04-29 09:21:31 +01:00
Benjamin Sago
c205c3592b Merge pull request #159 from MakeNowJust/feature/classify
Implement -F/--classify option
2017-04-28 23:24:52 +01:00
Benjamin Sago
eacbf55594 Start adding some special file testcases 2017-04-28 23:24:19 +01:00
Benjamin Sago
bd5095d0d0 Rename file-types tests to file-names-exts
This name more accurately reflects which code is being tested (things like .png and Makefile, rather than pipes and sockets), freeing up file-types for *actual* file types to be tested.
2017-04-28 20:07:31 +01:00
Benjamin Sago
22be5b047f Switch to an Ubuntu Vagrant image
The non-contrib Debian one doesn’t come with guest additions, meaning it used rsync instead of Virtualbox shared folders to sync files, meaning edits made in the VM didn’t get propogated back to the host, meaning I got very confused for a while.

Thanks to the parent commit, this shouldn’t be an issue at all: the default user name, which is now “ubuntu” instead of “vagrant” is specified in a lot fewer places, making it much easier to change.
2017-04-28 19:36:42 +01:00
Benjamin Sago
ef18f9ca91 Protect xtests against different default users
The Vagrant tests assumed that there’d be a user called “vagrant” that would run the tests and create the files by default. Files would be owned by vagrant:vagrant by default, and this worked, until it came time to change that username. The naïve method was a search-and-replace, but this caused problems when the new user’s name wasn’t exactly the same length as the previous one.

So to fix this, we now have our own user, named after the first animal I thought of, that makes the files’ owners and groups independent of the default user of whichever VM image the xtests are running on.

Another place where it was hard-coded was the home directory, which was “/home/vagrant”, where the awkward testcases live. That last one has been changed to just “/testcases”, which has no mention of the user in it.
2017-04-28 19:34:23 +01:00
Benjamin Sago
b885b34aa6 Protect xtests against the passage of time
There was a problem with the Vagrant tests where the year 2016 was hard-coded in as the modified date. This had to be done to make the --long tests use the correct date format, which varies depending on whether the timestamp is in the current year.

Unfortunately, time progresses [citation needed], and what was once 2016 is now 2017, so the date format changed and the tests broke.

Because the Vagrantfile is just a Ruby script, we can look up the current year at runtime and use that instead. There’s also a check added to the test runner that makes sure none of the files are more than 365 days old, because if any are, then it’s time to update the timestamps (or it’s the last day of a leap year)
2017-04-28 19:26:57 +01:00
Benjamin Sago
2ba4e99251 Versions bump 2017-04-28 18:13:39 +01:00
Kevin Ballard
dd63774e37 Print . and .. components properly
`Path.file_name()` returns `None` if the path ends in `.` or `..`, which
causes e.g. `exa -d ..` to print a blank line.
2017-04-26 22:28:34 -07:00
Benjamin Sago
b3957a2909 Merge pull request #162 from raphink/filetypes
Add cr2 as image
2017-04-26 21:23:33 +01:00
Kevin Ballard
a28bd8fa64 Print paths with 2 components properly
Previously, `exa -d foo/bar` would print the file as "bar", but
`exa -d foo/bar/baz` would correctly print "foo/bar/baz".
2017-04-25 15:55:05 -07:00
Raphaël Pinson
8ac68f9964
Add cr2 as image 2017-04-19 00:08:29 +02:00
TSUYUSATO Kitsune
e81b83b4ac Implement -F/--classify option 2017-04-14 07:27:37 +09:00
Benjamin Sago
3087565c01 Merge pull request #154 from neosilky/clippy-fixes
Fix some issues indicated by clippy
2017-04-11 08:18:55 +01:00
Benjamin Sago
e5ab15f09c I fixed the build problem! version 0.5.0 2017-04-11 08:11:37 +01:00
Benjamin Sago
1a6066327d Fix a merge mistake
The last PR was meant to remove the duplicate bitflags, but I think I messed it up and another one crept in.
2017-04-02 03:24:06 +01:00
Benjamin Sago
23ab19eb20 Merge pull request #147 from spk/use-official-jessie64
Use official vagrant jessie64
2017-04-02 02:33:39 +01:00
Benjamin Sago
59c4120e6a Merge pull request #149 from Stebalien/update-deps
Update dependencies
2017-04-02 02:31:50 +01:00
Benjamin Sago
22b593d159 Merge branch 'master' into update-deps 2017-04-02 02:31:36 +01:00
Benjamin Sago
f1be6b89d5 Merge pull request #146 from spk/fix-exit-status
Exit with a non-zero status on error
2017-04-02 02:25:31 +01:00
Benjamin Sago
98f0326d9e Merge pull request #145 from spk/update-git2
Update git2 to 0.6.4
2017-04-02 02:24:05 +01:00
Laurent Arnoud
8b61a3a0f2
Exit with a non-zero status on error
With `ls` from Debian coreutils 8.26-2

```
ls /bad/path
echo $? # => 2
```

Reproduced same behaviour with exa

Fix https://github.com/ogham/exa/issues/135
2017-04-01 00:10:49 +02:00
Laurent Arnoud
3fa3ae1595
Install pkg-config for openssl-sys 2017-04-01 00:08:41 +02:00
Laurent Arnoud
2960ec91d4
Update git2 to 0.6.4 2017-04-01 00:08:31 +02:00
Daniel Lockyer
cc4a65ac4b Remove lifetimes as they aren't needed 2017-03-31 17:12:20 +01:00
Daniel Lockyer
79b4f1a6ee Switch to better handling method 2017-03-31 17:12:01 +01:00
Daniel Lockyer
ec84f16da7 Collapse down similar branches of match-statement 2017-03-31 17:11:49 +01:00