Use new, smaller PagerCfg instead of the full Config, as for
pager output only 3 variables are relevant.
oneshot_write() can be used to write paginated output, usually
before exiting.
Insta makes writing new tests or performing changes which update the
expected value(s) easier. The new reference data can be reviewed
and inserted/updated automatically by `cargo insta review` (after
`cargo install cargo-insta`, but that tool is optional).
The snapshots are stored inline using the `@""` syntax and not in
separate files because the delta test output is small and designed to
be human readable.
See https://insta.rs/#hello-snapshot-testing
and https://docs.rs/insta/1.39.0/insta/
* Fix unused variables
* Don't read git files when --no-gitconfig is given
Despite starting delta with `--no-gitconfig`, strace still shows
that `.git/config` etc. files are accessed. By no longer doing
that it is very clear that no config options are read from there.
* Update direct dependencies
* Update transient dependencies
* Switch back to `dirs` crate
The `dirs`/`dirs-sys` repositories are unarchived and the crates are
maintained again, while `dirs-next` crates aren't.
* Move theme iteration logic to `GitConfig`
The `git2::Config` type is now encapsulated and the regex is given to
`libgit2` to filter the config entries.
* Move remote url getter to `GitConfig`
* try fix bad alignment in unicode (#1144)
* use width instead of count in wrap_line
* fix fmt
* 3 tests do not need fail
* fix tests
Co-authored-by: Thomas Otto <th1000s@posteo.net>
Following fixes are included:
* derive_partial_eq_without_eq:
Eq trait was added by running `cargo clippy --fix --no-deps`.
* get_first:
Function was replaced by running `cargo clippy --fix --no-deps`.
* unnecessary_to_owned:
This check was disabled for ANSIString as to_string call is required
to enforce formatting. Otherwise the underlying string was returned
directly (probably due to Deref implementation).
* type_complexity:
Closure type was simplified and Box<> usage was removed.
* Use "overridden" instead of "overriden"
* Use "line_numbers" instead of "linennumbers"
* Use "context" instead of "contexct"
* Use "summary" instead of "sumary"
This allow to no longer ignore some tests (marked previously as FIXME)
by storing the env at the start of the program (Or creating a custom env
for test purpose)
This centralize almost alls calls to std::env inside one wrapper
Add a test profile to increase speed for testing (5min -> 20sec on my
machine)
clean a few code style like this:
```
if Some(value) = ...
if value
```
to
```
if Some(true) = ...
```
Co-authored-by: William Escande <wescande@google.com>
Fix file paths and hyperlinks
With this commit the target of a hyperlink should always be an absolute path. This should be true for all file hyperlinks, e.g.
- File hyperlink
- Hunk header hyperlink
- Line number hyperlink
Fixes#890
Similar to Pythons `{n:2.1f}` where f indicates a floating point type.
The type may be separated by an underscore: `{n:<15.14_type}`.
Add a FormatStringPlaceholderDataAnyPlaceholder template which works
without a borrowed Placeholder.
There is no such thing as "Center Align" with discrete terminal cells. In
some cases a decision has to be made whether to use the left or the right
cell, e.g. when centering one char in 4 cells: "_X__" or "__X_".
The format!() center/^ default is left, but when padding numbers these
are now aligned to the right if required. Strings remain left-aligned.
* DeltaTest improvements
- Added .expect_contains(), .expect_raw_contains(), and
.expect_contains_once() member functions to DeltaTestOutput.
These functions also output some helpful debug info when the
assert fails.
- Separated .with_config_and_input() into .with_config() and (the
tweaked) .with_input().
- Made .with_config() create a DeltaTest object (like .with() does).
- Renamed .with() as .with_args().
- Moved .explain_ansi() from DeltaTestOutput to DeltaTest, which must
now be called prior to .with_input() since the latter stashes off both
the raw_output & the processed output in the object.
- Changed .expect() and .expect_skip() to return Self so that they can
continue a chain of multiple expect calls (e.g. a series of partial
matches with different skip values).
- The processed output text can be accessed via `test_obj.output` (see
also `test_obj.raw_output`).
- Renamed .expect_skip() to .expect_after_skip().
- Changed .expect() to start at the first line.
- Added .expect_after_header() that works like the old .expect().
- Renamed lines_match() to assert_lines_match() and made it match all
lines (no skip number).
- Added assert_lines_match_after_skip() to work like the old
lines_match() function, but with the .expect_after_skip() arg order.
- Converted some old-style tests into DeltaTest style tests.
- Renamed set_cfg as set_config
Using a syntax similar to the builder pattern:
`DeltaTest::with([config options]).with_input(DIFF).expect(lines)`
plus `.explain_ansi()` to pretty-print ansi codes and `.inspect()` to
print the to-be-tested output.
Rewrite a few tests using it and add ansi tests for
--line-fill-method=<spaces|ansi>
* Allow navigate-regexp value to be overridden.
* Don't add an empty label to the navigate_regexp.
* Make --hunk-label=str not require --navigate.
* Change navigate regexp to navigate regex.
* Turn navigate-regex into an Option<String>.
Simplifies line handling and printing by removing a "magical"
1-offset previously required in various locations.
Now explicitly prepend "" in `tokenize()`.
Even though this feature enables line numbers, these can be disabled via
the git config `delta.line-numbers=false`. So always enable line numbers,
even if they do not print numbers.
Construct more structs with ..Self::default()