Commit Graph

36 Commits (0d849838d98e28766ae13d7be58a45c92b9ef881)

Author SHA1 Message Date
Gavin Mak 7f5b53ff8d Remove last py2 workarounds
python3 is the only supported version of python in depot_tools.

Changes include:
  * updating python version requirements
  * removing third_party/six

Bug: 1475402
Change-Id: Ib86231413fcac494ceb27d1783e53b9d86533c26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4845292
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Mike Frysinger 124bb8e53c switch to 4 space indent
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.

Reformatted using:
files=( $(
	git ls-tree -r --name-only HEAD | \
		grep -Ev -e '^(third_party|recipes)/' | \
		grep '\.py$';
	git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"

The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py

These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py

Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Gavin Mak cc97655889 Reland "Drop py2 support in gerrit and git related files"
This is a reland of commit b5c7f4b46c

Original change's description:
> Drop py2 support in gerrit and git related files
>
> python3 is the only supported version of python in depot_tools.
>
> Bug: 1475402
> Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Commit-Queue: Gavin Mak <gavinmak@google.com>

Bug: 1475402
Change-Id: I194180494071777b7b9dd91a5c8edabbbf5484c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4811218
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Gavin Mak 42674f5d2d Revert "Drop py2 support in gerrit and git related files"
This reverts commit b5c7f4b46c.

Reason for revert: missing a replace for urlparse.urlparse

Original change's description:
> Drop py2 support in gerrit and git related files
>
> python3 is the only supported version of python in depot_tools.
>
> Bug: 1475402
> Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Commit-Queue: Gavin Mak <gavinmak@google.com>

Bug: 1475402
Change-Id: Idd00fdfe0b3d62785da2789a7dfcc9fbc79b6385
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4811623
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Gavin Mak b5c7f4b46c Drop py2 support in gerrit and git related files
python3 is the only supported version of python in depot_tools.

Bug: 1475402
Change-Id: Ie4ee18d297081b3aa0206b8d7ce6461819bff0ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809560
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Mike Frysinger 98d3bb27f0 gerrit_client: changes: support raw search queries
The --param option does not support extended bool logic.  It forces
every search query to be AND-ed together.  There is no way to do more
OR joins or subclauses like "( X OR Y ) AND Z".

Let's add a new --query option to let people type out the full string
themselves rather than try and support this bool logic directly.

Bug: b/282975918
Test: ./gerrit_client.py changes --host https://chromium-review.googlesource.com --query '( owner:vapier OR owner:briannorris ) is:open project:chromiumos/chromite'
Change-Id: I792e4deec34797295824ec13da41f45eb85e65ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4638081
Reviewed-by: Greg Edelston <gredelston@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
2 years ago
Nico Weber 6b33f85fb9 [gerrit-client.py] Fix DeprecationWarnings in mass-abandon
Fixes

    .../gerrit_client.py:424: DeprecationWarning: The 'warn' function is deprecated, use 'warning' instead
      logging.warn("%s CLs match search query: " % len(result))
    WARNING:root:100 CLs match search query:
    .../gerrit_client.py:426: DeprecationWarning: The 'warn' function is deprecated, use 'warning' instead
      logging.warn("[ID: %d] %s" % (change['_number'], change['subject']))

when using `gerrit_client.py mass-abandon`.

Also fixes other `logging.warn()` instances in the same method.

No behavior change.

Bug: none
Change-Id: Ib382d78aca18885ad3c8c0a97631dc76ef7cb22d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4631658
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Xinan Lin dbcecc9017 Allow 409 error from Gerrit when creating the branch
Gerrit may return 409 error to us even if the branch was created.
We should ignore this error if the branch head is the commit we
requested.

Also pre-check the branch status before creating it.
If an existing branch is expected by the caller, simply return
the branch info without sending the creation request.

BUG=1433047
TEST=local run
Change-Id: Ic6184705579f1410cb9c54843cc0bbb4c4ad61b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4436317
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Garrett Beaty <gbeaty@google.com>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
2 years ago
Xinan Lin 91d2a5db01 Allow to pass CC list when create a gerrit change
CC list needs to be contained in notify_details. We
can not use --param, because it is a map of recipient
type to NotifyInfo entity. '--param' can not accept a dict
from command line.

BUG=NA
TEST=gpaste/4774055988166656

Change-Id: I1560fe3a6136ab431052bc3fee7d4c8d989c8579
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3438508
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
3 years ago
Michael Moss 5c9e8b474f Don't escape "commit" value for Gerrit branch/tag creation.
This value is passed in the JSON body, not in the URL, so does not need
to be escaped, otherwise trying to make a branch/tag from another
branch/tag leads to errors like:

  gerrit_util.GerritError: (400) Bad Request: invalid revision "refs%2Fheads%2Fchromium%2F4665"

BUG=1052179
R=linxinan@chromium.org, sokcevic@google.com

Change-Id: I80d709370165fcb84a3375e18b67d4a921be9a8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3243724
Auto-Submit: Michael Moss <mmoss@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Xinan Lin <linxinan@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
3 years ago
Michael Moss 9c28af45e6 Add ability to generically call most Gerrit APIs.
This will make it easier to call new or uncommon Gerrit APIs, without
needing to add dedicated methods for each one. This also makes it easier
to debug API calls by exposing the raw response data, which is often
processed or filtered in the existing wrapper methods.

BUG=1052179
R=linxinan@chromium.org

Change-Id: I0b594a9fdaabae4b0ebb379dc5473f4d6de67a13
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3235714
Auto-Submit: Michael Moss <mmoss@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Xinan Lin <linxinan@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
3 years ago
Michael Moss b6ce244503 Add 'create tag' support to gerrit_client and gerrit recipe_module.
BUG=1052179
R=dpranke@google.com, linxinan@chromium.org

Change-Id: I6e220b70e63d990e9257d9fe4d107de7dbd2eb81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3232849
Auto-Submit: Michael Moss <mmoss@chromium.org>
Commit-Queue: Michael Moss <mmoss@chromium.org>
Reviewed-by: Xinan Lin <linxinan@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
3 years ago
Josip Sokcevic 284fbdd412 Fix gerrit_client py3 incompatibility
R=gavinmak@google.com

Bug: 1255669
Change-Id: I4fbbe9fb716a6abd58f40c9ca489a0043ee3584b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3214208
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Ben Pastene 281edf7577 Add a 'setlabel' command to gerrit_client.py
And add a hook for it in the gerrit recipe_module.

This will allow invocations of gerrit_client to set votes like
"code-review-1" or "commit-queue+1" on CLs. This will be used by bots
to control CLs they just created with update_files().

Bug: 1250084
Change-Id: I888458983165fed5882e5c37cba4a69dbfb9b810
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3207266
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
3 years ago
Xinan Lin 2b4ec95534 Add new subcommand for 'Changes Submitted Together'.
We may need to submit a chain of CLs. With this sub-cmd, we could
track their revisions along the chain, without querying them one
by one.

BUG=1236658
TEST=local run

Change-Id: If5930fb8f01daccff4d7c5c5e91c8db8887d8e47
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3098095
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Michael Moss <mmoss@chromium.org>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
4 years ago
Xinan Lin 1bd4ffa295 Remove wait-for-merge from gerrit client tool
Following comment in crrev.com/c/3039331, submit call
is fully synchronous.

BUG=1207955
TEST=e2e

Change-Id: I9146d43b4d4530ad5064709e418d34e3229e19ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3049672
Commit-Queue: Xinan Lin <linxinan@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
4 years ago
Xinan Lin 0b0738d9fe Add setbotcommit method to gerrit_client
This is required if we want to land a bot-generated-cl.

BUG=1207955
TEST=e2e

Change-Id: Ib758b9782f9951a3ec23ce9970b0db2a48b1b5f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3049573
Commit-Queue: Xinan Lin <linxinan@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Michael Moss <mmoss@chromium.org>
4 years ago
Xinan Lin c2fb26a337 gerrit_client could retrieve the branch and tag info for a commit hash
BUG=1207955
TEST=verified at local

Change-Id: Ife31456371f156d342ddd099bba1521051d700fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3044919
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Michael Moss <mmoss@chromium.org>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
4 years ago
Xinan Lin 6ec7cd87ac Add CMDsubmitchange to gerrit_client
Grant the power to gerrit_client cmd to submit a change. Once
we create a change and update it via CMDchangeedit, we can
submit it if the service account has permission.

BUG=1207955
TEST=e2e

Change-Id: Ia3102641ffe5bb72f8f63ad80bf15b5478cf5a2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3039331
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Michael Moss <mmoss@chromium.org>
Commit-Queue: Xinan Lin <linxinan@chromium.org>
4 years ago
Michael Moss 5eebf6fa78 Add docstrings so gerrit_client subcommands display properly.
Running './gerrit_client.py' currently shows only "help" as an available
subcommand. Adding these docstrings allows it to properly show all the
other subcommands.

R=sokcevic@google.com

Change-Id: I44c9d63fe8d481cabade50311d0f630b0f747018
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3032207
Auto-Submit: Michael Moss <mmoss@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic 84434e8481 Use py3 with gerrit_client.py
R=ehmaldonado@chromium.org

Change-Id: I93a4c20121010e8644982aa7910ff41884734f97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2949972
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
4 years ago
Marco Georgaklis 85557a08f4 Implemented suppport for getrelatedchanges endpoint in gerrit module
The endpoint documentation can be found here:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-related-changes

This involved adding support for the command in gerrit_client and
gerrit_util and then incorporating functionality and testing into
the gerrit recipe module.

The reasoning for this is to be able to identify chained builds for
improved accuracy of the new test identification for the FLake
Endorser project.

Bug:1204163
Change-Id: Ic60c733540a9afd7ff159408b0ea9ad7aac078e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2928016
Commit-Queue: Marco Georgaklis <mgeorgaklis@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic f5c6d8a27d Handle spaces in Gerrit search options
Gerrit rejects requests with 400 Bad request if query string `q`
contains any spaces. Replace spaces with a plus sign solves the problem.

R=thakis@chromium.org

Bug: 1199692
Change-Id: Ic13dda378527594c6cf57b8cb2edf740517811ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2832653
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic e1a98941d3 Add mass-abandon to gerrit_client.py
mass-abandon allows users to mass abandon CLs based on search query.
Owner is always specified (either "me" or user defined via -p).

R=gavinmak@google.com, thakis@chromium.org

Change-Id: I789a3a1f3af22867ebbbc50c35b60486206ff403
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2811005
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
LaMont Jones 9eed4238d8 gerrit: add createchange changeedit publishchangeedit
Add calls to support creating changes, as well as editing and publishing
them in gerrit_client and gerrit_util.

Bug=b:182613582

Change-Id: I0514cf08dce63ab29d99d4485d96fa124006326a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2800811
Auto-Submit: LaMont Jones <lamontjones@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: LaMont Jones <lamontjones@chromium.org>
4 years ago
Josip Sokcevic 848a5361d7 Stop using /usr/bin/python directly
Use /usr/bin/env python instead

R=dpranke@google.com

Bug: 1191100
Change-Id: I8de37ea7a02e7236d3bd36d4bae8cf4ffcf75ab9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2780631
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Josip Sokcevic df9a802ad2 Add change HEAD cli option to gerrit_client
This option modifies default branch of desired repository.

R=ehmaldonaldo@chromium.org, gavinmak@google.com

Change-Id: I1e20dc8d333c4301eacffff5049e3a98c3d59f75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2575884
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Mike Frysinger 8820ab859b gerrit_client: validate --param options
Passing an invalid --param option in leads to a crash lower down in
the gerrit modules which can be hard to trace back to the original
error: the user forgot the "key" in the "key=value".

Change-Id: I6fe5fab0fad15cf8d25173e0f1c8ea130efc44ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2558651
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
4 years ago
Josip Sokcevic c39ab997ba Support main as default branch
R=apolito@google.com

Change-Id: Ic338c698b8eb8d2e04fc1ef23ae4b13cae08b80f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2404701
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
4 years ago
Josip Sokcevic c99efb2f8c Add gerrit_client unit tests
Change-Id: Id4ca28da6c38f6403636ef8c4de5dae1206cb499
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2106518
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
5 years ago
Quinten Yearsley d9cbe7ad69 [git-cl] Lint and clean-up git-cl, test, and related modules
In this CL:
 - Clarify some comments.
 - Remove some unused imports.
 - Make some style more consistent (e.g. quotes, whitespace)

Tools used: pyflakes, flake8 (most warnings ignored)

Change-Id: Ibfb6733c8d844b3c75a7f50b4f3c1d43afabb0ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1773856
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
Commit-Queue: Quinten Yearsley <qyearsley@chromium.org>
6 years ago
Sergiy Belozorov fe34723a55 Add gerrit.abandon_change command
R=tandrii@chromium.org

Bug: 935715
Change-Id: Ia7b8e2b187b59680270d694b24edf82493d1ed5c
Reviewed-on: https://chromium-review.googlesource.com/c/1487212
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Sergiy Belozorov <sergiyb@chromium.org>
6 years ago
Sergey Berezin e866182f33 depot_tools: Fix executable bit for gerrit_*.py
BUG=628259
TBR=agable@chromium.org

Change-Id: I79bd59bb922d70c59a42ec09f153e9c9220fd9bb
Reviewed-on: https://chromium-review.googlesource.com/599362
Reviewed-by: Sergey Berezin <sergeyberezin@chromium.org>
Commit-Queue: Sergey Berezin <sergeyberezin@chromium.org>
8 years ago
Paweł Hajdan, Jr 24025d3e71 tryserver: add support for gerrit footers
Bug: 644609
Change-Id: Ied7439d688b89f90b9705968927521b5060c5fb4
Reviewed-on: https://chromium-review.googlesource.com/565564
Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
8 years ago
Michael Achenbach 6fbf12f21c Enable query for changes in gerrit recipe module
This'll allow to query gerrit from recipes for e.g. current changes in
CQ.

Bug: 685318
Change-Id: I73d08d4b186b2e5fe044fd4d4fafd9db62e27066
Reviewed-on: https://chromium-review.googlesource.com/558939
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
8 years ago
dimu 833c94c6fb Create recipe_modules/gerrit to interact with gerrit REST API
BUG=
R=mmoss,agable

Change-Id: I6410c28280ed05cf384a3da93e6b154c6081e039
Reviewed-on: https://chromium-review.googlesource.com/427375
Reviewed-by: Michael Moss <mmoss@chromium.org>
8 years ago