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

idiff: allow users to specify a directory as the 2nd argument #4015

Merged

Conversation

davvid
Copy link
Contributor

@davvid davvid commented Oct 12, 2023

Description

Teach idiff to accept a directory as the 2nd argument.

Fixes #4009

Tests

Functional tests for idiff don't currently exist. Manual testing verifies it works as advertised.

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (Usage strings updated)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary). (N/A)
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options). (N/A)
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

The Unix "diff" utility allows you to run:

    diff path/to/file1.txt path/to/dir

When "diff" sees a directory it appends "file1.txt" to the
directory so that this command is treated as if the user ran:

    diff path/to/file1.txt path/to/dir/file1.txt

Teach "idiff" to detect when a directory is specified and expand
the path to include the file basename from the first argument.

Closes: AcademySoftwareFoundation#4009
Signed-off-by: David Aguilar <davvid@gmail.com>
Let users know that the 2nd argument to "idiff" can be either an image
filename or a directory.

Related-to: AcademySoftwareFoundation#4009
Helped-by: @CheeksTheGeek
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid
Copy link
Contributor Author

davvid commented Oct 12, 2023

@CheeksTheGeek here's my take on the idiff feature.

I didn't originally update the usage/help string, so I took inspiration from CheeksTheGeek@c7522b7 and adjusted this PR to do something similar. I mentioned you in the commit message for that tweak.

One notable difference between this commit and the one linked above is that this is checking for size() == 2 before attempting to access the 2nd argument and it doesn't do any particular error handling itself because the code that follows already handles that.

second += Filesystem::filename(first);
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Filesystem class didn't already provide this functionality so adding this to idiff seemed like the right place to keep this for now. If other code ends up needing to build paths then moving this to the Filesystem class might be worth it at that point in time. It didn't seem worth extending its public API just for this one small tweak, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I believe Windows will happily accept / as a path separator so I'm not sure if the extra #if defined(_MSC_VER) complexity is worth it. Backslashes are idiomatic on Windows which is why I included it.

@davvid davvid changed the title Feat/idiff directories idiff: allow users to specify a directory as the 2nd argument Oct 12, 2023
@davvid
Copy link
Contributor Author

davvid commented Oct 12, 2023

The failed check looks to be configuration or a CI glitch:

Downloading packages:
warning: /var/cache/yum/x86_64/7/oneAPI/packages/intel-oneapi-common-licensing-2023.2.0-2023.2.0-49462.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 53d04109: NOKEY
Public key for intel-oneapi-common-licensing-2023.2.0-2023.2.0-49462.noarch.rpm is not installed
--------------------------------------------------------------------------------
Total                                              7.9 MB/s | 1.1 GB  02:23     
warning: /var/cache/yum/x86_64/7/oneAPI/packages/intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.1.0-2023.1.0-46305.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 7e6c5dbe: NOKEY
Retrieving key from https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
Importing GPG key 0x53D04109:
 Userid     : "CN=Intel(R) Software Development Products"
 Fingerprint: e9bf 0afc 46d6 e8b7 da58 82f1 bac6 f0c3 53d0 4109
 From       : https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB


Public key for intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.1.0-2023.1.0-46305.x86_64.rpm is not installed


 Failing package is: intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2023.1.0-2023.1.0-46305.x86_64
 GPG Keys are configured as: https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB

It was just that one permutation that hit this error.

@lgritz
Copy link
Collaborator

lgritz commented Oct 12, 2023

Don't worry about the icc/icx CI failures. That's a problem on the Intel side, they updated their signature key but didn't re-sign some of the older versions they had on that repo. It's on them to fix, I think. We will accept PRs that pass all the other CI tests.

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

LGTM!

This is fine as it is, though may I be greedy and ask for more? Would you be so kind as to touch up src/doc/idiff.rst to document the new feature?

@lgritz
Copy link
Collaborator

lgritz commented Oct 12, 2023

Fixes #4009

@lgritz
Copy link
Collaborator

lgritz commented Oct 12, 2023

Hmmm, that didn't work, probably because I'm not the author. @davvid, would you mind adding the magic line "Fixes #4009" to the description of this PR? That will link the issue and make it close automatically when this PR is merged.

@lgritz
Copy link
Collaborator

lgritz commented Oct 12, 2023

BTW, I built this on my end and tested, works! This is cool, now my "diff" muscle memory will work with "idiff" as well.

@davvid
Copy link
Contributor Author

davvid commented Oct 12, 2023

I think the commits themselves have Closes: #4009 in them so that should handle it. I'll update the description as well.

I'll also take a stab at updating idiff.rst as well -- thanks for the pointer to that file. I didn't notice it until you pointed it out.

Use "input1" and "input2" in the usage example to match
the description immediately below it.

Add a sentence explaining that "input2" can also be a directory.

Related-to: AcademySoftwareFoundation#4009
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid
Copy link
Contributor Author

davvid commented Oct 12, 2023

I pushed in a new commit that updates src/doc/idiff.rst as well. Thanks for reviewing!

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding it to the docs

@lgritz lgritz merged commit 0d2e990 into AcademySoftwareFoundation:master Oct 12, 2023
24 of 25 checks passed
@davvid davvid deleted the feat/idiff-directories branch October 13, 2023 06:57
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Oct 14, 2023
…cademySoftwareFoundation#4015)

Teach `idiff` to accept a directory as the 2nd argument.

Fixes AcademySoftwareFoundation#4009

## Tests

Functional tests for `idiff` don't currently exist. Manual testing
verifies it works as advertised.

---------

Signed-off-by: David Aguilar <davvid@gmail.com>
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.

[FEATURE REQUEST] idiff "directory mode"
2 participants