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

Put file-modified label in front of mode changes. #874

Merged
merged 1 commit into from
Jan 1, 2022

Conversation

WayneD
Copy link
Contributor

@WayneD WayneD commented Dec 30, 2021

When using --navigate with files that get their mode modified, the file-modified label was not being prefixed, so these changes were not being marked as skip destinations. This is particularly bad if a file has line changes along with the mode change and the user has an empty hunk label (since that would make the entire file's changes get skipped with an "n").

I added a test of a mode-change with a line-change, and a test for a mode change where the old & new mode values are not one of the two expected value-pairs. I also used format_file() on the mode filenames since the other format() headings were using it.

When using `--navigate` with files that get their mode modified, the
file-modified label was not being prefixed, so these changes were not
being marked as skip destinations.  This is particularly bad if a file
has line changes along with the mode change AND the user has an empty
hunk label (since that would make the entire file's changes get skipped
with an "n").

I added a test of a mode-change with a line-change, and a test for a
mode change where the old & new mode values are not one of the two
expected value-pairs.  I also used format_file() on the mode filenames
since the other format() calls were using it.
WayneD added a commit to WayneD/delta that referenced this pull request Dec 30, 2021
This change makes the tests pass, but it will need to be reverted to
work with the output change in dandavison#874.
@dandavison dandavison merged commit 50ece4b into dandavison:master Jan 1, 2022
@dandavison
Copy link
Owner

LGTM, thanks @WayneD.

integration_test_utils::run_delta(GIT_DIFF_FILE_MODE_CHANGE_UNEXPECTED_BITS, &config);
let output = strip_ansi_codes(&output);
assert!(output.contains(r"Δ src/delta.rs: 100700 -> 100644"));
}
Copy link
Owner

Choose a reason for hiding this comment

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

Incidentally, there's a utility to make writing these tests easier now. It doesn't yet have an expect_contains() method but I'll add that, at which point this test will be able to be written as

    fn test_file_mode_change_unexpected_bits() {
        DeltaTest::with(&["--navigate", "--right-arrow=->"])
            .with_input(GIT_DIFF_FILE_MODE_CHANGE_UNEXPECTED_BITS)
            .expect_contains(r"Δ src/delta.rs: 100700 -> 100644");
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing that out. I've created a pull request that implements this (along with some other changes).

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.

2 participants