Commit Graph

9 Commits (c48f866fcf32b4d7f95743060ce841c0d3c34ee9)

Author SHA1 Message Date
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>
3 months ago
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>
3 months ago
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>
3 months ago
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>
3 months ago
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>
3 months ago
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>
9 months ago
Yiwei Zhang fdfc24e36a run tests using python 3.8
This is achieved by duplicating vpython spec in tests directory and
changing the python version to 3.8. The reason for this change is that
even though depot_tools support 3.11, the entire infra is still on
3.8 so any new 3.8+ feature used in depot_tools may break infra test and
it has already happened couple of times.

Bug: 346784198
Change-Id: I7dbd0d926da21854abf47af2c2f6edfeec2c5c4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5625090
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
11 months ago
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>
1 year ago
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>
1 year ago