Add uploading of binary files for diffs.
Review Request #13571 — Created Feb. 23, 2024 and submitted
This change adds the
rbt post
logic for uploading binary files to
diffs. We start by assembling a list of the newly-created FileDiffs that
are marked as binary (using the new binary flag to the FileDiff API).
This is either done for the individual commits (when posting with commit
history) or for the full diff (when posting a squashed diff or on tools
that do not support history). We then go through and find what files we
should upload, filtering by whether it's a reviewable MIME type and the
configured file limit. We then create new file attachments for each
matching binary file.This includes the base SCMClient flag and method definitions, but does
not implement upload for any SCMs. We have to do it per client because
we need to add new APIs to the clients to get file content (and
optionally file size) at specific revisions. Individual per-SCM
implementations will come in future changes.
- Ran unit tests.
- Posted a whole bunch of changes with Git and SVN repositories that
included image files. Tested with both commit history and squashed
diffs.
Summary | ID |
---|---|
40704b1378f6ea09fb4201aece271f0111371cff |
Description | From | Last Updated |
---|---|---|
I think we should specify that this is an optional function to implement, and should only be implemeneted if the … |
maubin | |
Missing a return type. |
maubin | |
This can also raise a ValueError, could you add that while here. |
maubin | |
Even though this and _upload_binary_files are private functions, might as well add "Version Added" to the docstrings. |
maubin | |
Missing blank line. |
chipx86 | |
Must be explicitly typed bool, or it'll be Literal[False]. |
chipx86 | |
Can we type this? |
chipx86 | |
Can we type this? |
chipx86 | |
Can this just be: files_to_upload += files.all_items If so, that'll simplify the code a bit and save some operations. |
chipx86 | |
Indentation is off by one level. |
chipx86 | |
'rbtools.api.resource.ItemResource' imported but unused Column: 5 Error code: F401 |
reviewbot |
- Change Summary:
-
Add missing Returns section in some docstrings.
- Commits:
-
Summary ID c150ebac3ce065c841fb6f6900b1d6238797cb04 f04883dc59b03bf07b14b927febe1b95743a3b4d
Checks run (2 succeeded)
-
-
I think we should specify that this is an optional function to implement, and should only be implemeneted if the subclass's tool can get the file size without loading the file.
Or, would it be better to put the logic of loading the file and getting the file size (which currently exists in
_upload_binary_files
) as a default here, and then specify that subclasses should optimize this if possible? -
-
-
Even though this and
_upload_binary_files
are private functions, might as well add "Version Added" to the docstrings.
- Commits:
-
Summary ID f04883dc59b03bf07b14b927febe1b95743a3b4d b3d467c76d4fc4f84a546aadf22186e6d5b4ad17
Checks run (2 succeeded)
- Commits:
-
Summary ID b3d467c76d4fc4f84a546aadf22186e6d5b4ad17 26d5bfcbd93c028c78f635b8886380c5be6713a5