Commit Graph

332 Commits (1b4881c9300a81bac80eace84caa2c10c2e41fa5)

Author SHA1 Message Date
Josip Sokcevic c1ab734908 Handle no changed content in presubmit support
git cl presubmit has --all option which marks all files as modified.
However, that doesn't work well with SCM diff. That is, git diff may not
contain affected file. Instead of throwing an exception in such case,
just return no diff.

R=gavinmak@google.com

Fixed: 808346
Change-Id: Ie1d534b8eebc84bc5206eba7db8057829390fbec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3485501
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
3 years ago
Josip Sokcevic e293d3dce9 Support py3 in post upload presubmit hooks
Currently, post upload presubmit hooks are exlusively executed with py2,
regardless of USE_PYTHON3 magic variable. This change adds py3 support
in the same fasion as regular presubmit hooks.

R=aravindvasudev@google.com

Fixed: 1297712
Change-Id: Ib464f8563e4135a63fc48692d27c8692fe1f630b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3469285
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Andrew Grieve bdfb8f2451 presubmit_support: Prevent crash when checks use Popen
Specifically, this change shows how it can be triggered:
https://chromium-review.googlesource.com/c/chromium/src/+/3433606

Calling Popen.wait() causes a __warningregistry__ key to be added to
context.

Bug: None
Change-Id: I7ceb453ffd1eb1ea689e909e3cc5c832df7e9b59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3433466
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
3 years ago
Aravind Vasudevan c5f0cbb865 Use pylint 2.7 for depot_tools
This includes a few fixes for specific errors, and disables several new
warnings introduced in this version, in order to allow for an incremental migration.

Bug:1262286
Change-Id: I4b8f8fc521386419a3121bbb07edc8ac83170a94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3413679
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
3 years ago
Josip Sokcevic 42c5bbbc96 Revert "Use pylint 2.7 for depot_tools"
This reverts commit 22bf605bb6.

Reason for revert: breaks gclient sync

Original change's description:
> Use pylint 2.7 for depot_tools
>
> This includes a few fixes for specific errors, and disables several new
> warnings introduced in this version, in order to allow for an incremental migration.
>
> Bug:1262286
> Change-Id: Ie97d686748c9c952e87718a65f401c5f6f80a5c9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3400616
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>

Bug: 1262286
Change-Id: Ieb946073c7886c7bf056ce843a5a48e82becf7a5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3413672
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Aravind Vasudevan 22bf605bb6 Use pylint 2.7 for depot_tools
This includes a few fixes for specific errors, and disables several new
warnings introduced in this version, in order to allow for an incremental migration.

Bug:1262286
Change-Id: Ie97d686748c9c952e87718a65f401c5f6f80a5c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3400616
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
3 years ago
Josip Sokcevic 7592e0a623 Fix PRESUBMIT errors ignored if there are warnings
R=gavinmak@google.com

Fixed: 1264947
Change-Id: If5163b167921f12cf91ca2efe3bbd1765109ba00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3360902
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
3 years ago
Josip Sokcevic 6635baff5b Make CannedChecksUnittest py3 compatible
R=apolito@google.com

Change-Id: I24610ca05536b4ac6eed2c0a33ef411650b46dd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3292089
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Sean McAllister 1e509c548e presubmits: Modify bug parsing to support FIX.* fields from gitwatch
Gitwatch supports closing bugs with a FIX(ES|ED|ING)? tag in the
commit message, but we only check BUG to ensure a bug is
specified, add the fix fields to BugsFromDescription so that presubmits
will still pass if only eg: FIXES=b:1234 is given.

Gitwatch reference:
  http://shortn/_LGPgBjgi3A

FIXED=b:203812728
TEST=presubmit_unittest.py doesn't fail more than it already does

Change-Id: I6afc38c786e281dcefb4d359bb9212ebe5980ed6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3237598
Auto-Submit: Sean McAllister <smcallis@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic 662d513faa Remove unused function GetPreferredTryMasters
Only usage was in v8, and that was removed in 2016:
http://crrev/45ec73da150e02fac1fc1dc15e3f14cb5bc2b45f

R=tandrii@chromium.org

Change-Id: I6aebcf1fc0cc29440b0b9c9b45d4e3fc35a38e53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3214209
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic f9d6b219ec Remove unused variables
R=apolito@google.com

Bug: 1098562
Change-Id: I98123cba5b6a2ff077a5a599c8640e18de3c4957
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3095027
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Anthony Polito <apolito@google.com>
Reviewed-by: Anthony Polito <apolito@google.com>
4 years ago
Tom McKee 61c72651d7 Harden _PresubmitResult against varying string types
When presubmit checks fail, we want to print the error message from the
underlying check/tool. We use _PresubmitResult objects to collect these
diagnostics and output them to the console and json files.

This change ensures that the string values passed to the
_PresubmitResult constructor will be converted, as needed, to 'str'
instances. This way, we will avoid encoding errors and make sure to
print the actual messages instead of repr(message).

SHERIFFS: this patch breaks backwards compatibility of presubmit error
handling but we don't expect issues in downstream projects. Please
revert if downstream presubmit checks start failing spuriously.

Bug: 1225052
Change-Id: If7f5c99cb5d730c1bfbd6d108b912f77b5f2455c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3037262
Commit-Queue: Tom McKee <tommckee@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
kyle Ju 965a05bedf Fix py3 presubmit error. Use unicode strings explicitly.
Bug:1225052
Change-Id: I7c536819133c75130baca2f8d295360d7d1ca69c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2995072
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Kyle Ju <kyleju@chromium.org>
4 years ago
Dirk Pranke 6f0df68e8b Add use_python3 to codereview.settings to set default for PRESUBMITs.
This CL adds a new field to the codereview.settings file used by
git_cl for project-wide defaults. If `USE_PYTHON3` is set to True,
then we will run the PRESUBMIT checks under Python3 by default
instead of Python2, unless the PRESUBMIT.py file contains
`USE_PYTHON3 = False` on a line by itself

(as opposed to now, where we'll use Python2 by default unless the
file contains `USE_PYTHON3 = True`).

This will allow us have Python3 be the default for new files
and to eventually eliminate any uses of `USE_PYTHON3` from the
individual presubmit files. Of course, you will have to go in and
explicitly add `USE_PYTHON3 = False` to any Py2-only files prior
to enabling this.

Bug: 1207012
Change-Id: Id8ec45b43940e5bcffeee196398c711c541e733e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2917747
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
4 years ago
Josip Sokcevic b4a7cffc40 [py3] Decode stdout in presubmit runs
Bug: 1215375
Change-Id: I068801f5e7482cf13cf70dd6c3a70c39f22a39f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2949974
Commit-Queue: Dirk Pranke <dpranke@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Josip Sokcevic 0b12346bf3 [py3] Return list of strings in GitChange.AllFiles
Currently, GitChange.AllFiles returns a list of byte[]. This is
inconsistent with py2 and may cause issues when byte[] is used when
string is expected.

Change-Id: I3e73bc5f71aa787f55357b8139cdeeabee056047
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2946934
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Dirk Pranke 7288f88590 Fix output flushing when getting warnings that should prompt in py3.
When presubmit checks create warnings that should raise a prompt
whether or not to continue, the output wasn't being flushed
properly under python3.

Bug: 1213316
Change-Id: Ibb4b4d965d49f0cd65ccc0737282e5f5b5f58004
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2921323
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
4 years ago
Greg Thompson 30cde45e06 Fix error handling in case of unicode decode error.
Commit 6fc394f added some diagnostics, but it didn't quite work out the
way it was planned.

Bug: 1210746
Change-Id: Ia4f30606e87d3f8b1362441bd74bb7ed0f5ca886
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2928771
Auto-Submit: Greg Thompson <grt@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Dirk Pranke 6fc394f93d Fix crash during presubmit checking.
If a presubmit happened to generate a crash, the logic we have
for reporting the presubmit check times would call `six.reraise()`
incorrectly, leading to a second crash.

This CL fixes the invocation of the second crash, and also adds
an error message to help users tripping over one possible source
of the first crash (reading a binary file as text).

Bug: 1210746
Change-Id: Ic46f38901b6acf2055b3feb7272dc751dc69037c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2921322
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
4 years ago
Bruce Dawson 2bdc49fadc Warn on long presubmits, like on long hooks
Presubmits when uploading occasionally take a very long time - over a
minute - and after the fact there is no easy way to know why. This makes
fixes to slow presubmits take longer.

This change builds on crrev.com/c/2532895 to print a message when any
individual presubmit function takes longer than ten seconds. During
normal usage this is a NOP but it will presumably find the long poles
when presubmits are running particularly slowly.

This is similar to gclient runhooks where any hooks that take longer
than ten seconds have their run time printed.

Change-Id: If57ed35d7a7d221f6380e9b97cf72af56f75e441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2911594
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
4 years ago
Bruce Dawson f0bcfdd702 Optionally preserve line endings
CheckForWindowsLineEndings is a Chromium presubmit to make sure that
\r\n line endings (Windows line endings) don't get committed. Among
other things these line endings mess up the license checks, leading to
cryptic errors.

The problem is that ChangedContents() was stripping line endings, making
any checking for them futile. This change adds an option to preserve
line endings, to be used by Chromium's CheckForWindowsLineEndings.

It's not clear how long this has been broken.

See also crrev.com/c/2911914 which must land after this.

Bug: 801033
Change-Id: I7cdb9b3581788624f9eca081da43bb070ee412a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2910488
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
4 years ago
Allen Webb fe7d709f05 presubmit_support: Use six instead of future.utils for raise_from.
This fixes CL:2880843 to use a module already present in vpython.

Bug: 1206782
Change-Id: If4158a62011e043e89f40f368c9c644434df6614
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2901758
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Erik Staab 69135d1e32 Add python3_executable to the PRESUBMIT API.
Change-Id: I1706bc696590215f304dcc16f08ecb6afe1144fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2897933
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Erik Staab <estaab@chromium.org>
4 years ago
Allen Webb b65bbfe4d5 Include original traceback in _run_check_function.
This is a followup to CL:2797935 to make it easier to debug exceptions.

Bug: 1206782
Change-Id: Ibb649e94fd562919737de152e3203ca6b02b38ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2880843
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
4 years ago
Dirk Pranke 61bf6e8d69 Add support for running PRESUBMIT.py checks under Python2 or 3.
This CL adds support for running PRESUBMIT.py under either Python2
or Python3 as specified in each PRESUBMIT.py file.

To run the checks under Python3, the PRESUBMIT.py file must contain
a line exactly matching "^USE_PYTHON3 = True$". If the file
does not contain this string, the checks will run under Python2.

Different PRESUBMIT.py files in a single CL may thus contain
a mix of 2- and 3-compatible checks, but each individual file will
only be run in one or the other (it doesn't likely make sense to run
them in both by default).

Bug: 1157663
Change-Id: Ic74977941a6519388089328b6e1dfba2e885924b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2832654
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
4 years ago
Gavin Mak 554187a21c Add more exception details in _run_check_function
Bug: 1194603
Change-Id: I4945f815078a681c853e038faecc443762a07bd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2797935
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
4 years ago
Edward Lesmes 392c407b55 presubmit: GerritAccessor has project field, not repo field
Change-Id: I712c39a6171e11cf65d8663ef4ee1333911931df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2776158
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Sky Malice <skym@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
4 years ago
Edward Lesmes 8170c29fd1 Reland "presubmit: Skip owners checks if code-owners plugin is enabled."
This is a reland of 2cf835a9ba

URL-encoded repo path, so chromium/src becomes chromium%2Fsrc
as Gerrit expects

Original change's description:
> presubmit: Skip owners checks if code-owners plugin is enabled.
>
> If code-owners plugin is enable for the repo, skip owners check on
> commit, and skip checking owners format, as that will be done by
> the plugin.
>
> Change-Id: I1663baef4f0f27b00423071343fe740f6da50ce7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2727131
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

Change-Id: I3038590f3a92cbf7b6dc0ba6eb47f72593a2ccf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2775840
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
4 years ago
Edward Lesmes dc11c6bd18 Reland "presubmit: Use code-owners plugin if available."
This is a reland of 36de4be91e
Should be fixed after cl/363445481

Original change's description:
> presubmit: Use code-owners plugin if available.
>
> Change-Id: I56734de985731d007360a4a4e65f2b16de28b69a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2753894
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>

Change-Id: Id7d5c6c3bd0a246e3400ca99584bb41a92853d16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2774218
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Edward Lesmes c456617ddd presubmit: Allow Bot-Commit+1 to self-approve change.
Change-Id: I29a7aeb6f797be015f29e1e514bbe44988a1221e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2775839
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Dirk Pranke e4bab45474 Reland "presubmit: Don't skip OWNERS check when Bot-Commit+1 is present."
This reverts commit e7c0581740.

Reason for revert: Whoops. chromium/src was updated. I was confused by a conversation on the #ops slack channel and my checkout being slightly out of date. I think the original change was actually okay.

Original change's description:
> Revert "presubmit: Don't skip OWNERS check when Bot-Commit+1 is present."
>
> This reverts commit 9757ad5883.
>
> Reason for revert: We need to update callers first (e.g., //PRESUBMIT.py in chromium/src).
>
> Original change's description:
> > presubmit: Don't skip OWNERS check when Bot-Commit+1 is present.
> >
> > Change-Id: I17b07796a86c5214e13a0058428889c1bb2b850d
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2774080
> > Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> > Reviewed-by: Jason Clinton <jclinton@chromium.org>
> > Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
>
> Change-Id: I02c3d5ea2e65ef852d34a6816d04fe1cad82823a
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2775101
> Auto-Submit: Dirk Pranke <dpranke@google.com>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>

Change-Id: I2c1ae8c60938cbd9316e9075488cc7451068a2f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2775103
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Auto-Submit: Dirk Pranke <dpranke@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
4 years ago
Dirk Pranke e7c0581740 Revert "presubmit: Don't skip OWNERS check when Bot-Commit+1 is present."
This reverts commit 9757ad5883.

Reason for revert: We need to update callers first (e.g., //PRESUBMIT.py in chromium/src).

Original change's description:
> presubmit: Don't skip OWNERS check when Bot-Commit+1 is present.
>
> Change-Id: I17b07796a86c5214e13a0058428889c1bb2b850d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2774080
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Jason Clinton <jclinton@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

Change-Id: I02c3d5ea2e65ef852d34a6816d04fe1cad82823a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2775101
Auto-Submit: Dirk Pranke <dpranke@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
4 years ago
Edward Lesmes 9757ad5883 presubmit: Don't skip OWNERS check when Bot-Commit+1 is present.
Change-Id: I17b07796a86c5214e13a0058428889c1bb2b850d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2774080
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Jason Clinton <jclinton@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Edward Lesmes 48492322a0 Revert "presubmit: Use code-owners plugin if available."
This reverts commit 36de4be91e.

Reason for revert:
Not working for v8: crbug.com/1189233

Original change's description:
> presubmit: Use code-owners plugin if available.
>
> Change-Id: I56734de985731d007360a4a4e65f2b16de28b69a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2753894
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>

Bug: 1189233
Change-Id: Id96277e1a6d3b9dcf5fc1bf4816706515b75e55c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2767720
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
4 years ago
Edward Lesmes 36de4be91e presubmit: Use code-owners plugin if available.
Change-Id: I56734de985731d007360a4a4e65f2b16de28b69a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2753894
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic ec3c39536a Revert "presubmit: Skip owners checks if code-owners plugin is enabled."
This reverts commit 2cf835a9ba.

Reason for revert: doesn't work with depot_tools

error 404 Not found: tools (with applied patch from 2729404)

Bug: 1183975

Original change's description:
> presubmit: Skip owners checks if code-owners plugin is enabled.
>
> If code-owners plugin is enable for the repo, skip owners check on
> commit, and skip checking owners format, as that will be done by
> the plugin.
>
> Change-Id: I1663baef4f0f27b00423071343fe740f6da50ce7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2727131
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

Change-Id: Id4d560701e4b0144e0aafc5263e09ed6927f6222
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2729409
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
4 years ago
Josip Sokcevic cd71dafbf0 Revert "presubmit: Fix checking if code-owners enabled for repo."
This reverts commit 70405c2f9f.

Reason for revert: doesn't work with depot_tools

error 404 Not found: tools

Bug: 1183975

Original change's description:
> presubmit: Fix checking if code-owners enabled for repo.
>
> Change-Id: I22e6a9d4405d92d26dfbfba64735b6e9ce92674c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2729404
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>

Change-Id: Ib358f31e7c4c6fc07f98db4758004097234eaa87
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2729408
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
4 years ago
Edward Lesmes 70405c2f9f presubmit: Fix checking if code-owners enabled for repo.
Change-Id: I22e6a9d4405d92d26dfbfba64735b6e9ce92674c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2729404
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
4 years ago
Edward Lesmes 2cf835a9ba presubmit: Skip owners checks if code-owners plugin is enabled.
If code-owners plugin is enable for the repo, skip owners check on
commit, and skip checking owners format, as that will be done by
the plugin.

Change-Id: I1663baef4f0f27b00423071343fe740f6da50ce7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2727131
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Edward Lesmes eb1bd62b91 presubmit_support: Add flags for Gerrit project and target branch.
Will be used in a follow-up CL to initialize code-owners client.

Recipe-Nontrivial-Roll: build
Change-Id: Iefe9176320b4d1ae7715e88a8db132e815be76ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2717979
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
4 years ago
Stephen Martinis fb09de29ea Revert "Use GetCodeOwnersClient in presubmit_support"
This reverts commit 7a67bca65a.

Reason for revert: Probably broke chromium presubmit, see https://ci.chromium.org/ui/p/chromium/builders/try/chromium_presubmit/1152280/overview

Original change's description:
> Use GetCodeOwnersClient in presubmit_support
>
> This change also adds a target_ref flag to presubmit_support.py.
>
> Recipe-Nontrivial-Roll: build
> Change-Id: I6de6bb87fc1482b88d9fbebe5e4ad1dbd8ce9748
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2702792
> Commit-Queue: Gavin Mak <gavinmak@google.com>
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>

Change-Id: I2cca469f14194f65306baab7928ddddd48033a3b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2718691
Auto-Submit: Stephen Martinis <martiniss@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
4 years ago
Gavin Mak 7a67bca65a Use GetCodeOwnersClient in presubmit_support
This change also adds a target_ref flag to presubmit_support.py.

Recipe-Nontrivial-Roll: build
Change-Id: I6de6bb87fc1482b88d9fbebe5e4ad1dbd8ce9748
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2702792
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic 8c95595001 Remove non-inclusive parameters from presubmit
R=ehmaldonado@google.com

Bug: 1118435, 1118436
Change-Id: Ie66b2cb39a3d8abc83679bee44d2e594eba77442
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2657981
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Edward Lesmes 9ce03f80a4 presubmit: Add owners_client to presubmit API.
So that presubmit API can use it to check owners
approval.

Change-Id: Ie26c8a83de02b750fd92b4f419fe4d55809e6dbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2621745
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Gavin Mak e6a623392d [depot_tools] Use logging.warning
logging.warn is deprecated and should be replaced with logging.warning.

Bug:1097402
Change-Id: I55ce007bec47608eeafcf3cd9ac2b90f60073115
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2575621
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
4 years ago
Scott Lee cc2fe9b767 [resultdb] use requests.Session in rdb_wrapper
requests.post() creates a new HTTP connection for each call.
It makes presubmit checks slower and timed out.
This CL updates rdb_wrapper to use requests.Session() to use
a connection pool for Sink requests.

Change-Id: Id02ecce85898ae15993d53df17473bb5dfb7e89f
Bug: 1145762
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2532895
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Chan Li <chanli@chromium.org>
Reviewed-by: Erik Staab <estaab@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Edward Lesmes cf49cb8206 [presubmit][owners] Skip owners check when Owners-Override is +1
Add support for Owners-Override label to allow trusted bots, sheriffs,
and global owners to bypass owners checks.

Bug: 1093627
Change-Id: Ie217369a67e4060807c0a12f84430e30a7c57daa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2530488
Reviewed-by: Yulan Lin <yulanlin@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes 02d4b82580 [presubmit][owners] Skip owners check when Bot-Review is +1
Add support for Bot-Review label to allow trusted bots to
bypass owners checks.

Bug: 1093627
Change-Id: Ie7398041e9e32fd87bb415b239b5ec0a4740e1ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2530516
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Yulan Lin <yulanlin@google.com>
5 years ago
Garrett Beaty acb807e458 Output a newline when there are warnings and no prompt.
Not outputting a newline when not prompting causes the command prompt to
not appear on a new line.

Change-Id: I791c829e1e0b37c9ad5d6bfdb246db4c779be020
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2380598
Auto-Submit: Garrett Beaty <gbeaty@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Garrett Beaty <gbeaty@chromium.org>
5 years ago
Josip Sokcevic c6aa151180 Warn only if non-inclusive term is used
This fixes the issue where presubmit_canned_checks issues a warning if
optional arguments in CheckAuthorizedAuthor are not used at all.

This relands commit b09f2bb2f2 with some
additional changes.

R=apolito@google.com

Bug: 1098560
Change-Id: If323d90ab7d6bcca68ed89142ea67edc4be057d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2373216
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
5 years ago