Page MenuHomeSoftware Heritage

Improve validation of --author and --name.
ClosedPublic

Authored by vlorentz on Dec 18 2019, 6:54 PM.

Details

Summary

Mostly, the code used to allow having either --author or --name,
while it should use either both (when generating metadata) or
neither (when using a metadata file).

This code fixes this, and also catches some more invalid cases.

Depends on D2469.

Diff Detail

Repository
rDDEP swh-deposit
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz created this revision.Dec 18 2019, 6:54 PM
vlorentz updated this revision to Diff 8772.Dec 18 2019, 6:56 PM

remove file from commit

looks about right

wondering if we are not missing some valid case to demo

swh/deposit/tests/cli/test_client.py
208

Don't we want to also show that the correct combinations work:

  • --author and --name
  • --metadata
  • whatever i'm missing else cases ;)
ardumont added inline comments.Dec 19 2019, 9:20 AM
swh/deposit/cli/client.py
207

We could be lenient and drop the unneeded information.
By introspecting both metadata and flags then trying to determine what could be dropped.
In case of too much corner case and thus conflict, then raising and error to ask the clients what they really want ;)

That's a lot more work though...

build failure

I think that misses some rebase

ardumont accepted this revision.Dec 19 2019, 9:55 AM
This revision is now accepted and ready to land.Dec 19 2019, 9:55 AM
vlorentz added inline comments.Dec 19 2019, 1:36 PM
swh/deposit/cli/client.py
207

By introspecting both metadata and flags then trying to determine what could be dropped.

That's already what I'm doing. But if the user is giving contradictory arguments, you can't tell which way they should correct it.

swh/deposit/tests/cli/test_client.py
208

--author and --name

Tested in test_single_minimal_deposit

--metadata

Tested in test_multisteps_deposit.

This revision was automatically updated to reflect the committed changes.