* First, we were treating the return value of HTTPResponse.read() as a
string when it is really a byte string.
* Second, the urlparse library was renamed to urllib.parse in Python 3,
so I made the appropriate substitution.
Change-Id: I0b23716e990eca8ddf77742f378ab54eda3d3717
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2307509
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dan McArdle <dmcardle@chromium.org>
Use the same set of default filters as presubmit checks. Presubmit
checks use filters to give better lint results as expected by Google C++
style. Give git-cl's lint subcommand the same benefit.
Bug: 1106028
Change-Id: I51ff0737b310990ab424376d2721e8a6a50dfc6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2298122
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Use continues to reduce the amount of nesting in a loop. At the same
time, give the variable involved better names.
Bug: 1097674
Change-Id: I105ed4a99da783fb235e304bbad4edd1f8a38889
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2298659
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Original CL: https://crrev.com/c/2241792
Fix Windows use case by calling yapf directly without going through
yapf.bat.
Bug: 1062053,1095581
Change-Id: I31a9f09cba655d6ac1b4da9874a24a41aa007b17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2249606
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Use vpython or vpython3 to invoke yapf depending on the shebang line for
each file.
Bug: 1062053
Change-Id: I497fa48c08aa6052a2b06df7cc7f18e2154ab898
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2241792
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Commit messages are now sent to input_api in the exact format that user
has used
Bug: angleproject:4714
Change-Id: I30592aec75d57618f5c028bb63a18f95239976e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2239039
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Manh Nguyen <nguyenmh@google.com>
This is similar in spirit to the helper flags in git subcommands, e.g.
try `git branch --git-completion-helper`. It provides a list of long
flags that the subcommands support, without repeating it manually in the
completion script. Note that this special flag is not returned in help,
so there is no noise.
To see the result, source the script, then `git cl upload --<TAB>`.
Change-Id: I82e280ceac5178b0e5fa52611b9a4125e6943337
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2209926
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
* Call `os.path.normpath()` prior to comparing file paths
* Run Python files with `vpython`
* Pass `shell=True` for Windows commands, so that the PATH variable is
defined: https://stackoverflow.com/a/32799942
* While here, clean up similar call sites to drop an unnecessary cast.
Fixed: 1081763
Change-Id: I8096b3ad14a4675036a579fab537af1d94f12725
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2203422
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Ilya Sherman <isherman@chromium.org>
At least one contributor thought that --show-all would show all owners
for the current CL, so they used it with no files specified and got
confused by the lack of output. I was fooled to. The message printed
by "git cl help owners" makes it clear but it seems worth detecting the
no-files case and printing a helpful message, especially since most
(all?) of the other git cl owners commands apply to the current CL.
Bug: 1071967
Change-Id: I77bd2e30a3b3a6eb67cd40b93f5544b20facacb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2183219
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
This reverts commit 31a538a3a9.
Reason for revert:
Breaks ANGLE's workflow.
Original change's description:
> git-cl: turn GERRIT_SQUASH_UPLOADS into a warning
>
> Now that repos have dropped this from their codereview.settings file,
> change this logic to issue a warning if it's ever seen again.
>
> Drop checking local gerrit.override-squash-uploads config too since
> it's no longer relevant.
>
> Bug: 993518
> Change-Id: Id91bbc94b0890ca21c51a274f6acc41f2ae19b78
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1756159
> Commit-Queue: Mike Frysinger <vapier@chromium.org>
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
TBR=vapier@chromium.org,ehmaldonado@chromium.org,infra-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: Iaa8b3341b189f356082ae25a1557898e25820566
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 993518
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2182019
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Now that repos have dropped this from their codereview.settings file,
change this logic to issue a warning if it's ever seen again.
Drop checking local gerrit.override-squash-uploads config too since
it's no longer relevant.
Bug: 993518
Change-Id: Id91bbc94b0890ca21c51a274f6acc41f2ae19b78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1756159
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
The support for Dart in canned_checks.CheckPatchFormatted can be removed.
It was used in Chromium, when Chromium included a Dart SDK in its
checkout.
Dart was removed from Chromium years ago, and none of the current Dart
repositories use this in their presubmit.
Current repositories using Dart and depot_tools are
dart.googlesource.com/sdk and Flutter engine.
The SDK source tree has extensive custom code written for format checking
in the presubmit, and Flutter engine has none.
So adapting the exiting code to work with a new SDK location, or
searching the path for any Dart SDK (which would be too fragile) would
not be useful for these projects.
The support code was introduced in:
https://codereview.chromium.org/933383002
Bug: 1075502
Change-Id: I1ceed1ed6c1b4ff05071b0db1c52016f03c47c9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2168851
Reviewed-by: Anthony Polito <apolito@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
At the moment, specifying --dependencies to upload all dependent CLs
will always prompt for confirmation if --force was specified. This
means that there is no way to run this command in a batch way or from
another script, and it's also in contradiction to the --force flag
which is meant to answer 'yes' to all prompts.
This uses a pattern that is used several times in the script, which is
to check 'if not force: prompt()'.
Change-Id: I7d85b02b68d958a5b2d3295a04c4ced023d36ec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2139700
Auto-Submit: Jose Lopes <jabolopes@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
This is a reland of 87661afbfc
Set shell=True on Windows, so that vpython.bat can be executed.
Original change's description:
> git-cl: Execute clang-format-diff.py using vpython.
>
> When running git-cl using vpython3, sys.executable is python3.
> Execute clang-format-diff.py using vpython instead, since it has
> not been migrated already.
>
> Bug: 1066187
> Change-Id: I31556acb50ff4256706a313c1393eddad9f903f3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2130926
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Bug: 1066187
Change-Id: Ia482f13d0f30d625f2f6db3cb4202b7f3f95707b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2135330
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This reverts commit 87661afbfc.
Reason for revert: Still get:
OSError: Execution failed with error: [Error 2] The system cannot find the file specified.
Original change's description:
> Reland "git-cl: Execute clang-format-diff.py using vpython."
>
> This is a reland of beec66070e
>
> Append the clang-format directory to the front of PATH instead of
> overwriting it.
> This allows vpython to be invoked.
>
> Original change's description:
> > git-cl: Execute clang-format-diff.py using vpython.
> >
> > When running git-cl using vpython3, sys.executable is python3.
> > Execute clang-format-diff.py using vpython instead, since it has
> > not been migrated already.
> >
> > Bug: 1066187
> > Change-Id: I31556acb50ff4256706a313c1393eddad9f903f3
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2130926
> > Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> > Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
>
> Bug: 1066187
> Change-Id: I8b65549ef47587cef8492f8f76a037eb85a981fc
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2132972
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
TBR=ehmaldonado@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com
Change-Id: I22566c829a83991e3749a039d0bd0ba7d8a56812
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1066187
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2133588
Reviewed-by: John Budorick <jbudorick@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
This is a reland of beec66070e
Append the clang-format directory to the front of PATH instead of
overwriting it.
This allows vpython to be invoked.
Original change's description:
> git-cl: Execute clang-format-diff.py using vpython.
>
> When running git-cl using vpython3, sys.executable is python3.
> Execute clang-format-diff.py using vpython instead, since it has
> not been migrated already.
>
> Bug: 1066187
> Change-Id: I31556acb50ff4256706a313c1393eddad9f903f3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2130926
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Bug: 1066187
Change-Id: I8b65549ef47587cef8492f8f76a037eb85a981fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2132972
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This reverts commit beec66070e.
Reason for revert:
OSError: Execution failed with error: [Errno 2] No such file or directory: 'vpython'.
Original change's description:
> git-cl: Execute clang-format-diff.py using vpython.
>
> When running git-cl using vpython3, sys.executable is python3.
> Execute clang-format-diff.py using vpython instead, since it has
> not been migrated already.
>
> Bug: 1066187
> Change-Id: I31556acb50ff4256706a313c1393eddad9f903f3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2130926
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
TBR=ehmaldonado@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com
Change-Id: I555251d8dbb1582d7f03702b7910d70a11b75855
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1066187
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2130785
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
When running git-cl using vpython3, sys.executable is python3.
Execute clang-format-diff.py using vpython instead, since it has
not been migrated already.
Bug: 1066187
Change-Id: I31556acb50ff4256706a313c1393eddad9f903f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2130926
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
The old behavior was to set parent from the gerritsquashhash of the
parent branch, but now it's trying to set it from the gerritsquashhash
of the current branch (which doesn't exist yet).
As a result it's always saying `Upload upstream branch ... first`
Change-Id: I035ed128f46a49d09d563ea589e9ca9eb7b87db9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2128679
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This is a reland of e3a49aa405
GetRelativeRoot was fixed to use '.' instead of None
Original change's description:
> git-cl: Remove unused and duplicate functions.
>
> Remove unused functions, and use scm.GIT where possible to reduce
> duplication.
>
> Change-Id: I24f05e7b3ae04743e97b6665ee668f44d6acc294
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116938
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Change-Id: I54bd1d34d3501a38bf8af2f9e70059d58fa538a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2125293
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Normal weight colored text can be hard to read, especially over Chrome
Remote Desktop (video compression treats chroma harshly). Git colors can
be made more readable by editing .gitconfig, but git cl colors are hard
coded. This hard codes them to all be bold, for greater readability and
effective brightness, and changes the still-too-dim-over-CRD blue to red.
Magic bold code found here:
https://stackoverflow.com/questions/8924173/how-do-i-print-bold-text-in-python
Change-Id: If3a8684d1886291ca692d6fdbe7e30095a5acbc8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116941
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
On an initial upload, git-cl upload -t <title> should append <title>
before the change description.
This broke because options.squash is set to a default value very late
into code execution, so its value was not available when computing the
initial description.
options.squash is now set when parsing the options, early into code
execution.
Bug: 1064905
Change-Id: I04a18c572dd5b04a3013d39f71bc43d026ea85d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2122324
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This option lets users specify a format of the archive tags. E.g.
git cl archive -p 'archived/{issue}-{branch}'
makes tags in the format
archived/1234-foo-feature
Change-Id: Icb74cc68781cda21a70c802bd640543e92ae97a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116723
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Remove unused functions, and use scm.GIT where possible to reduce
duplication.
Change-Id: I24f05e7b3ae04743e97b6665ee668f44d6acc294
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116938
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
gclient_utils.AskForData will use raw_input on Python 2 and input on Python 3.
Bug: 1063976
Change-Id: I93c059c4e4454d01787716b5a0a2641ad5253f53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2116370
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
This is a reland of 9f29465e52
Original change's description:
> git-cl: Refactor CMDUploadChange
>
> Changes:
> - Add _GetDescriptionForUpload and _GetTitleForUpload.
> - Add ensure_change_id to ChangeDescription, that ensures the
> description has a particular Change-Id.
> - If more than a Change-Id was entered on new issue upload, remove
> all, and add a new one.
>
> Change-Id: I0eae474eb07ea3036973b18571f72a80da425b21
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2101811
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Change-Id: Ib2c0ad61b169f6b0c3141674591b0d3fa42bc664
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2103532
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
This reverts commit 9f29465e52.
Reason for revert:
line 2302, in CMDUploadChange
change_id = change_ids[0]
IndexError: list index out of range
Original change's description:
> git-cl: Refactor CMDUploadChange
>
> Changes:
> - Add _GetDescriptionForUpload and _GetTitleForUpload.
> - Add ensure_change_id to ChangeDescription, that ensures the
> description has a particular Change-Id.
> - If more than a Change-Id was entered on new issue upload, remove
> all, and add a new one.
>
> Change-Id: I0eae474eb07ea3036973b18571f72a80da425b21
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2101811
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
TBR=ehmaldonado@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com
Change-Id: Ibb76539066c103ec951fa8d02684bc10f84549bf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2103531
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Changes:
- Add _GetDescriptionForUpload and _GetTitleForUpload.
- Add ensure_change_id to ChangeDescription, that ensures the
description has a particular Change-Id.
- If more than a Change-Id was entered on new issue upload, remove
all, and add a new one.
Change-Id: I0eae474eb07ea3036973b18571f72a80da425b21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2101811
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
If the Change-Id in the description is different from the one fetched
from Gerrit, automatically set the right one instead of asking the
user to do so.
Change-Id: I0f681d9e7d98f3ed50adc4b6e4929981530e901c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2101368
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
CQ added support to project-scoped accounts instead of previously
hardcoded commit-bot@ for working with Gerrit.
R=ehmaldonado
Test: `git cl status` on this very CL :)
Bug: 911811
Change-Id: I8f48a7bdc9dad9a5b71d266ccf7e9a493aa94aa9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2095986
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Andrii Shyshkalov <tandrii@google.com>
Also refactor code to eliminate multiple calls to _create_description_from_log.
Change-Id: I113134fbd90f396bdb6d561ed0369ea5ee9c78ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2090448
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
When user.email is not configured in git, git-cl tries to call
presubmit support with --author None, which makes git-cl crash.
Bug: b/150870673
Change-Id: Idc42ba2b970340ed93e1e92f65850fc1a12336d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2090375
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>