Commit Graph

12 Commits (f4e8e13e8bc5673347f86e1be3ec4ccbf1a440c2)

Author SHA1 Message Date
Gavin Mak edba22d4eb Fix multiline comment formatting
Many incorrectly formatted comments exist from the switch to
4 space indent: https://crrev.com/c/4836379

Bug: 1514505
Change-Id: I6366f9da812919bd35b999f18fa8a49b7a66c09b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5153633
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Gavin Mak f936d540e1 Remove __future__ imports
All __future__ imports (unicode_literals, print_function) are already
mandatory in py3. Also remove an outdated py2 comment in
presubmit_canned_checks.py

Bug: 1475402
Change-Id: I27cf6a8268f6dd1081f22af782c4c29a975376ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4867135
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
1 year 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
Aravind Vasudevan bb14391a50 Remove unused imports from depot_tools scripts
This change removes some unused imports across depot_tools scripts.

Change-Id: Ic1112065ad1020fc4a3573d3fb9f137915ef439c
Bug: 1475776
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4812185
Auto-Submit: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2 years ago
Josip Sokcevic 4de5deacd4 Explicitly run everything with python3
R=aravindvasudev@google.com, gavinmak@google.com

Change-Id: Iaa5e960c6226dea3a0814c7cb778d952eafb1502
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3525960
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
3 years ago
Jesse McKenna 6f9b1bfd48 setup_color: Disable colorama on pre-Windows-10
This change disables colorama wrapping on versions of Windows prior to
10.

Currently, this wrapping causes "TypeError: cannot use a string
pattern on a bytes-like object" on Windows 7 and 8.1 when running
`gclient sync`, `gclient fetch`, and other utilities that use
colorama.

Bug: 1114548
Change-Id: Id6b4a6f9a8ae0721765da34b5625b4524b9d36b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2485882
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
4 years ago
Raul Tambre 73ec83f0fe setup_color: Don't output an error if GetConsoleMode fails
Turns out GetConsoleMode fails if the user's console isn't native. This is sometimes the case for Git Bash.

Also moved the checking code out of the if block so it applies in generic console cases too.
This went unnoticed, because setup_color.py is currently only really used in Git scripts, which are piped.

Bug: 1001187
Change-Id: I93357e479f84122f759e419d15c02500809657d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1785605
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Commit-Queue: Raul Tambre <raul@tambre.ee>
Auto-Submit: Raul Tambre <raul@tambre.ee>
6 years ago
Raul Tambre ca1eb7d167 setup_color: Use native ANSI support on Windows 10
Windows 10 has support for native ANSI control codes.
This means we don't have to wrap stdout/stderr with Colorama, which uses old CMD APIs to handle these sequences.

This change inadvertently also works around an issue on Python 3 where Colorama errors when bytes are output by gclient_utils.CheckCallAndFilter due to not wrapping sys.stdout.buffer.

Bug: 942522
Change-Id: Ic7dde620b01bd94eb50de353bfc0276cad045a45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1735566
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
6 years ago
Raul Tambre 70eba7d2d1 setup_color: Don't fill created string buffer with nulls
This causes an error since Python 3.5 due to a regression (https://bugs.python.org/issue32745):
Traceback (most recent call last):
  File "C:\Google\depot_tools\metrics.py", line 267, in print_notice_and_exit
    yield
  File "C:\Google\depot_tools\gclient.py", line 3153, in <module>
    sys.exit(main(sys.argv[1:]))
  File "C:\Google\depot_tools\gclient.py", line 3136, in main
    setup_color.init()
  File "C:\Google\depot_tools\setup_color.py", line 70, in init
    buf = ctypes.create_string_buffer('\0', 1024)
  File "C:\Program Files\Python38\lib\ctypes\__init__.py", line 63, in create_string_buffer
    raise TypeError(init)
TypeError: <Unicode console <stderr>>.write: ArgumentError("argument 2: <class 'ValueError'>: embedded null character")

Simply not filling the buffer with NULLs doesn't change the behaviour.

Bug: 942522
Change-Id: I1feb81555e995597b0b70f4aee9151fea755510c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1701402
Auto-Submit: Raul Tambre <raul@tambre.ee>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
6 years ago
Raul Tambre b946b2389c Improve gclient Python 3 compatibility
This enables gclient sync and gclient runhooks to run, barring hook script failures.
git cl upload also now works.

The scripts still work with Python 2.
There are no intended behaviour changes.

Bug: 942522
Change-Id: I2ac587b5f803ba7f5bb5e412337ce049f4b1a741
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1524583
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
6 years ago
Andrii Shyshkalov 9c0930ef20 setup_color.py should not be executable, as it pollutes $PATH.
R=iannucci@chromium.org

Change-Id: Ieb9d76736203a346d8364c6c0448d9bb4391a3f7
Reviewed-on: https://chromium-review.googlesource.com/475832
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
8 years ago
iannucci@chromium.org 596cd5c95d Fix coloring madness in depot_tools.
'setup_color' now contains logic to correctly detect:
  * cmd
  * cmd pipe
  * msys bash
  * msys pipe
  * cmd running inside msys bash (git-command)
  * cmd pipe running inside msys bash (git-command > outfile)

R=brucedawson@chromium.org, dnj@chromium.org
BUG=600049

Review URL: https://codereview.chromium.org/1851283002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299682 0039d316-1c4b-4281-b951-d872f2087c98
9 years ago