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>
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>
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>
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>
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>
_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>
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>
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>