Alex Ovsienko
30e928fe1c
Fix possibly unbound Body by assigning preassigning them the else case and overriding them in the if case.
...
The current case will work until eiether the has_chunk_header above or below the _process_diff function changes, and then it will cause runtime crash as one cannot concat string and None.
Change-Id: I81737328f609e636bcee5087a2bc4aa96a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7260374
Reviewed-by: Brian Egizi <begizi@google.com >
Reviewed-by: Gavin Mak <gavinmak@google.com >
Commit-Queue: Alex Ovsienko <ovsienko@google.com >
2025-12-17 16:09:22 -08:00
Scott Lee
80d1969422
presubmit_diff: add support for -U
...
This is a reland of https://crrev.com/c/6168707 with fixes.
The CL adds a new param, unified, to git_diff() and create_diffs()
as a required param.
The functions themselves are tested in presubmit_diffs_test.py, but
their usages in presubmit_support.py were not, and the missing param
caused a failure in CiderG (b/389876151)
This CL basically carries the same patch, but makes the params
optional with a default value and adds unit tests for the usage
in presubmit_support.py
Tested with CiderG: https://screenshot.googleplex.com/PYEDZ3NGn5cYGtV
Change-Id: Ic747c6a133c016dbcd80034e521c76a3db3a3f60
Bug: 389876151, 379902295
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6182703
Commit-Queue: Scott Lee <ddoman@chromium.org >
Reviewed-by: Gary Tong <gatong@chromium.org >
2025-01-17 14:51:19 -08:00
Scott Lee
7b9ced4220
Revert "Reland "add support for -U in presubmit_diff.py""
...
This reverts commit 9a9142793a .
Reason for revert: failed again
Original change's description:
> Reland "add support for -U in presubmit_diff.py"
>
> This reverts commit 4c54361841 .
>
> Reason for revert: Reland with a fix.
>
> Find https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173762/1..2
> Tested by running presubmit_support.py --generate_diff
>
>
> Original change's description:
> > Revert "add support for -U in presubmit_diff.py"
> >
> > This reverts commit b576ab3b78 .
> >
> > Reason for revert: http://b/389876151
> >
> > Original change's description:
> > > add support for -U in presubmit_diff.py
> > >
> > > presubmit_diff.py is going to be used to compute the changes to be
> > > formatted, and -U helps minimize the number of irrelevant lines
> > > from formatting.
> > >
> > > Bug: 379902295
> > > Change-Id: I9c0a2ee6b5ffa6b9fe4427362556020d525f1105
> > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6168707
> > > Reviewed-by: Gavin Mak <gavinmak@google.com >
> > > Commit-Queue: Scott Lee <ddoman@chromium.org >
> >
> > Bug: 379902295
> > Change-Id: I82dd707e5ae3d4b1760e632506ee0e1bc1d76e09
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173760
> > Reviewed-by: Scott Lee <ddoman@chromium.org >
> > Commit-Queue: Gavin Mak <gavinmak@google.com >
> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com >
>
> Bug: 379902295
> Change-Id: Icbc4aa98bbfaa816143be064217fb2d992b48baf
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173762
> Reviewed-by: Gavin Mak <gavinmak@google.com >
> Commit-Queue: Scott Lee <ddoman@chromium.org >
Bug: 379902295
Change-Id: I84875f6667689e1a9085876555bc6aef4ea2d7b4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6177776
Commit-Queue: Scott Lee <ddoman@chromium.org >
Reviewed-by: Gary Tong <gatong@chromium.org >
2025-01-15 10:38:03 -08:00
Scott Lee
9a9142793a
Reland "add support for -U in presubmit_diff.py"
...
This reverts commit 4c54361841 .
Reason for revert: Reland with a fix.
Find https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173762/1..2
Tested by running presubmit_support.py --generate_diff
Original change's description:
> Revert "add support for -U in presubmit_diff.py"
>
> This reverts commit b576ab3b78 .
>
> Reason for revert: http://b/389876151
>
> Original change's description:
> > add support for -U in presubmit_diff.py
> >
> > presubmit_diff.py is going to be used to compute the changes to be
> > formatted, and -U helps minimize the number of irrelevant lines
> > from formatting.
> >
> > Bug: 379902295
> > Change-Id: I9c0a2ee6b5ffa6b9fe4427362556020d525f1105
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6168707
> > Reviewed-by: Gavin Mak <gavinmak@google.com >
> > Commit-Queue: Scott Lee <ddoman@chromium.org >
>
> Bug: 379902295
> Change-Id: I82dd707e5ae3d4b1760e632506ee0e1bc1d76e09
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173760
> Reviewed-by: Scott Lee <ddoman@chromium.org >
> Commit-Queue: Gavin Mak <gavinmak@google.com >
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com >
Bug: 379902295
Change-Id: Icbc4aa98bbfaa816143be064217fb2d992b48baf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173762
Reviewed-by: Gavin Mak <gavinmak@google.com >
Commit-Queue: Scott Lee <ddoman@chromium.org >
2025-01-14 12:41:32 -08:00
Gavin Mak
4c54361841
Revert "add support for -U in presubmit_diff.py"
...
This reverts commit b576ab3b78 .
Reason for revert: http://b/389876151
Original change's description:
> add support for -U in presubmit_diff.py
>
> presubmit_diff.py is going to be used to compute the changes to be
> formatted, and -U helps minimize the number of irrelevant lines
> from formatting.
>
> Bug: 379902295
> Change-Id: I9c0a2ee6b5ffa6b9fe4427362556020d525f1105
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6168707
> Reviewed-by: Gavin Mak <gavinmak@google.com >
> Commit-Queue: Scott Lee <ddoman@chromium.org >
Bug: 379902295
Change-Id: I82dd707e5ae3d4b1760e632506ee0e1bc1d76e09
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173760
Reviewed-by: Scott Lee <ddoman@chromium.org >
Commit-Queue: Gavin Mak <gavinmak@google.com >
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com >
2025-01-14 10:59:04 -08:00
Scott Lee
b576ab3b78
add support for -U in presubmit_diff.py
...
presubmit_diff.py is going to be used to compute the changes to be
formatted, and -U helps minimize the number of irrelevant lines
from formatting.
Bug: 379902295
Change-Id: I9c0a2ee6b5ffa6b9fe4427362556020d525f1105
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6168707
Reviewed-by: Gavin Mak <gavinmak@google.com >
Commit-Queue: Scott Lee <ddoman@chromium.org >
2025-01-13 09:28:54 -08:00
Gavin Mak
f52dad9747
Handle binaries in presubmit_diff
...
presubmit_diff always tries to decode files from Gitiles with UTF-8
but if the file is binary, it gets a UnicodeDecodeError. Don't
assume that a file is text and just write the bytes directly.
Bug: b/358175830
Change-Id: Iaa259051b4157737397933e9d994c00e9da5836c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5771938
Reviewed-by: Scott Lee <ddoman@chromium.org >
Commit-Queue: Gavin Mak <gavinmak@google.com >
2024-08-08 02:48:22 +00:00
Gavin Mak
b83a3038f1
Handle diff without chunk header
...
_process_diff assumes "@@" will always be present in a diff, but those
aren't present in a git diff where only the file mode changed.
Bug: b/323243527
Change-Id: Id129bc6c14994affc43a77feab553fa119612b7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5384645
Reviewed-by: Joanna Wang <jojwang@chromium.org >
Commit-Queue: Gavin Mak <gavinmak@google.com >
2024-03-26 00:19:53 +00:00
Gavin Mak
6551a7eb43
Fetch file contents from Gitiles in parallel
...
This makes it much faster to get a diff for a set of multiple files.
Bug: b/323243527
Change-Id: I6c54a4fa8782d4a0bbb187b8bed4fbd52be47344
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5384647
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org >
Commit-Queue: Gavin Mak <gavinmak@google.com >
2024-03-21 05:28:39 +00:00
Gavin Mak
9782552ca4
Add presubmit_diff.py
...
Create a script to create a unified git diff of a local workspace
against a remote Gerrit commit. This will be used to create a diff file
for running presubmits.
Bug: b/323243527
Change-Id: Ia0d287624162dbfe5231a5653c9a962a6c85c8e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5374833
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org >
Commit-Queue: Gavin Mak <gavinmak@google.com >
2024-03-18 22:48:36 +00:00