Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make file style to be colored with same structure while color_only #405 #436

Merged
merged 6 commits into from Dec 8, 2020
Merged

Conversation

ghost
Copy link

@ghost ghost commented Dec 7, 2020

This pr changes below.

  • Make file style to be colored with same structure while color_only

ss 4

ss 6

I confirmed below apart from test.

  • git -c 'interactive.diffFilter="./target/release/delta" --color-only' add -p still works.

Remarks.

src/delta.rs Outdated
@@ -180,7 +188,7 @@ where
continue;
}

if state == State::FileMeta && should_handle(&State::FileMeta, config) {
if state == State::FileMeta && should_handle(&State::FileMeta, config) && !config.color_only {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be refactored after commit style and hunk header style are also resolved.

@@ -317,7 +325,7 @@ fn handle_generic_file_meta_header_line(
raw_line: &str,
config: &Config,
) -> std::io::Result<()> {
if config.file_style.is_omitted {
if config.file_style.is_omitted && !config.color_only {
return Ok(());
}
Copy link
Author

@ghost ghost Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required, otherwise we need to refactor should_handle.
We can discuss and make another pr if we need.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Feel free to add explanatory comments to the code while it is fresh in your brain. If we have some test coverage of this then we'll feel even better about refactoring :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes! I'm gonna add.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dandavison
Add comment here def9554

@@ -195,7 +195,6 @@ pub fn set_options(
opt.side_by_side = false;
opt.file_decoration_style = "none".to_string();
Copy link
Author

@ghost ghost Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required.
file_decoration_style will break structures. We should prevent any of them.

@dandavison
Copy link
Owner

Great! Thanks for working on this @ulwlu.

Already ready for pr of commit-style and hunk-header-style, but they depend on this pr.

You could open a second PR and use the PR target branch selector so that the second PR targets this branch. Unless I imagined it, I think GitHub is clever enough nowadays that the second one automatically switches to target master when the first merges.

Copy link
Owner

@dandavison dandavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, there's just one thing I'd ask for -- do you think you could add a failing test that demonstrates the problem that you are fixing? If you don't mind rebasing, it's nice to have the failing test be the first commit and the fixes come after (then I probably won't use squash-and-merge because the history is useful.)

The utility ansi_test_utils::assert_line_has_style might be useful for the test.

@ghost
Copy link
Author

ghost commented Dec 8, 2020

@dandavison
Sure!

You could open a second PR and use the PR target branch selector so that the second PR targets this branch. Unless I imagined it

Right, but I was not sure if this approach will be changed, and need to fix 2nd branch entirely or fix conflict (and I don't want so).

do you think you could add a failing test that demonstrates the problem that you are fixing?

Sure, just a minute.

@ghost
Copy link
Author

ghost commented Dec 8, 2020

@dandavison

Add test here.
b48fa01

confirmed it's succeed now, and failed before the first commit.

@dandavison dandavison merged commit 1dfb1f7 into dandavison:master Dec 8, 2020
@dandavison
Copy link
Owner

Perfect, thanks! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant