Commit Graph

964 Commits (8b4eeffd4628a54e47ccd44e7a3f426b3218bad2)

Author SHA1 Message Date
Daniel McArdle 8b4eeffd46 git-cl: Fix "git cl tree" issues with Python 3.
* 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>
5 years ago
Lei Zhang b8c62cf5f4 Add default filters to git cl lint.
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>
5 years ago
Lei Zhang 379d1ad115 Simplify a block of conditionals for git cl lint.
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>
5 years ago
Carlos Caballero 81923d6d2c Fix git_cl -r compatibility issue with Python 3
iterkeys is no longer a thing in Python 3

Change-Id: I4d88d2a486db1e552ecac27f123219ac1e03bcaf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2276208
Commit-Queue: Carlos Caballero <carlscab@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes b7db183f02 git-cl: Use shell=True when running yapf using vpython on Windows.
Bug: 1097215
Change-Id: Ibdae2d84a661442e6dcaa54e975bb5f1009cce83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2254740
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Peter Wen d939992589 Support formatting python3 scripts (reland)
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>
5 years ago
Liviu Rau f82b08b1e2 Revert "Support formatting python3 scripts"
This reverts commit 2ba05f1672.

Reason for revert: yapf formatting broken on windows  https://crbug.com/1095581

Change-Id: Ifad1009ab8d83a05cd5763bb95910647940cbaf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2246152
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Peter Wen 2ba05f1672 Support formatting python3 scripts
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>
5 years ago
Manh Nguyen 77463bb188 Preserve raw commit message
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>
5 years ago
Aaron Gable 6e7ddb698b Remove agable from depot_tools OWNERS and TODOs
Change-Id: I0667af4562208a111ab3673f3fca6aab655f5f26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2218962
Auto-Submit: Aaron Gable <agable@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Anthony Polito <apolito@google.com>
5 years ago
Ng Zhi An cdaf0be1f4 Add git completion helper to cl upload
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>
5 years ago
Ilya Sherman 7aed4bb802 Fix `git cl format` for metrics XML files on Windows
* 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>
5 years ago
Ilya Sherman b67e60cd33 Add git cl format support for "structured" metrics
This matches the support for the other metrics subdirectories.

R=ehmaldonado@chromium.org

Bug: none
Change-Id: Ibf84e1d1b33e38843b8a11ff3299d4c0c3aa5eb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2173743
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Ilya Sherman <isherman@chromium.org>
5 years ago
Bruce Dawson 97ed44ada9 Warn when --show-all is used with no files listed
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>
5 years ago
Edward Lesmes 4de54135e8 Revert "git-cl: turn GERRIT_SQUASH_UPLOADS into a warning"
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>
5 years ago
Mike Frysinger 31a538a3a9 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>
5 years ago
Takuto Ikuta 26b02c109b Revert "git_cl: add --parallel for yapf"
This reverts commit 8533236d09.

Reason for revert:
https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2163086/4#message-dcd4603d5914c681d0e1ad498e7bb9b59576a24d

Original change's description:
> git_cl: add --parallel for yapf
> 
> see
> https://github.com/google/yapf#usage
> 
> Bug: 1073708
> Change-Id: I09a327e44bfcf5cf9a59c4e8d470a8886fc9f44b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2163086
> Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
> Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=agable@chromium.org,tikuta@chromium.org,ehmaldonado@chromium.org,infra-scoped@luci-project-accounts.iam.gserviceaccount.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1073708
Change-Id: Ib8245dca57a11a386e78089630df61ff773b1789
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2168971
Reviewed-by: Aaron Gable <agable@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
5 years ago
Edward Lesmes 259d6bb191 git-cl: Remove formatting support for dart.
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>
5 years ago
Josip Sokcevic 5e18b605d3 Fix git cl upload on Windows
Use ISO8601 time format standard to avoid localized result and need to
encode.

R=ehmaldonado@chromium.org

Bug: 1074002
Change-Id: I95c2ddd55a9661351f2b45601f7bba24c2951c31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2163401
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
5 years ago
Takuto Ikuta 8533236d09 git_cl: add --parallel for yapf
see
https://github.com/google/yapf#usage

Bug: 1073708
Change-Id: I09a327e44bfcf5cf9a59c4e8d470a8886fc9f44b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2163086
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Andrii Shyshkalov 8aebb60a8d git cl patch: support short CL URLs.
Change-Id: I71ae8e94ec0cc5d880c002c7187351ac6ee2c2b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2152218
Auto-Submit: Andrii Shyshkalov <tandrii@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Jose Lopes 3863fc52b9 Do not prompt on --dependencies if --force.
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>
5 years ago
Edward Lesmes 89624cdfd7 Reland "git-cl: Execute clang-format-diff.py using vpython."
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>
5 years ago
Peter Kasting cd454025b3 Revert "Reland "git-cl: Execute clang-format-diff.py using vpython.""
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>
5 years ago
Edward Lesmes 87661afbfc 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>
5 years ago
Edward Lesmes 43d002a2ca Revert "git-cl: Execute clang-format-diff.py using vpython."
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>
5 years ago
Edward Lesmes beec66070e 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>
5 years ago
Edward Lesmes a680c23e78 git-cl: Fix checking if parent branch has been uploaded.
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>
5 years ago
Edward Lesmes 50da7706ce Reland "git-cl: Remove unused and duplicate functions."
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>
5 years ago
Bruce Dawson b73f8a96ec Make git cl status use bold colors
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>
5 years ago
Edward Lesmes 0dd5482c52 depot_tools: Restore appending title before change description.
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>
5 years ago
Tibor Goldschwendt 7c5efb2a7e Add format string option to git cl archive
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>
5 years ago
Edward Lesmes cba460828f Revert "git-cl: Remove unused and duplicate functions."
This reverts commit e3a49aa405.

Reason for revert:

TypeError: expected str, bytes or os.PathLike object, not NoneType

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>

TBR=ehmaldonado@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com

Change-Id: I334a6289eb2c1f3e20feddd428307542d2aa38a9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2119411
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lesmes e3a49aa405 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>
5 years ago
Edward Lesmes ae3586b538 depot_tools: Use gclient_utils.AskForData instead of raw_input.
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>
5 years ago
Edward Lemur c81db8c596 git-cl: Remove GetIsGerrit.
It's always true.

Change-Id: I96a53c032de705724e61c64ee37e9a14b596cbd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2113250
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur 5a644f8276 Reland "git-cl: Refactor CMDUploadChange"
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>
5 years ago
Edward Lesmes c48fb8427c Revert "git-cl: Refactor CMDUploadChange"
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>
5 years ago
Edward Lemur 9f29465e52 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>
5 years ago
Edward Lemur 2c62b334ea git-cl: Stop using Change class from presubmit support.
Bug: 1042324
Change-Id: I72db082f086f69bf49256d0613c39dc92ae0a07f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2101471
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
5 years ago
Edward Lemur 5fb2224974 git-cl: Set the right Change-Id footer automatically.
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>
5 years ago
Andrii Shyshkalov 1ee78cdaac git cl: use short URLs in `git cl status`.
This also applies to git map-branches.

R=ehmaldonado

Change-Id: Ica9bc92660716c15cbdd6bfd77b93f08bd0d8f9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2099329
Commit-Queue: Andrii Shyshkalov <tandrii@google.com>
Auto-Submit: Andrii Shyshkalov <tandrii@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Andrii Shyshkalov 8aa9d62e8e git cl: better detection of messages from CQ.
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>
5 years ago
Edward Lemur a12175c2a7 git-cl: Use _create_description_from_log instead of GetLocalDescription
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>
5 years ago
Edward Lemur 57d4742bbb git-cl: Tell users to set SKIP_GCE_AUTH_FOR_GIT=1 when running on cloudtop.
Bug: 1059141
Change-Id: I0a4501946014bd567548fb5396c3dd761606a9bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2091584
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
5 years ago
Quinten Yearsley ee8be8a368 git-cl: Don't throw AttributeError in git cl upload --retry-failed
Bug: 1057745
Change-Id: Ic1b977634e15b163e627c0f389047a26f7b0c7d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2083677
Commit-Queue: Quinten Yearsley <qyearsley@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
5 years ago
Edward Lemur 99df04e8aa git-cl: Check if author exists before adding to presubmit command line.
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>
5 years ago
Quinten Yearsley 777660f33f depot_tools: git-cl: Rename try job to tryjob for consistency
Change-Id: I3310db47604dafead241db4d8d3540277daeb07c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2083675
Commit-Queue: Quinten Yearsley <qyearsley@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur b7f759f6bc git-cl: Use open instead of file.
file does not exist on Python 3.

Change-Id: I9392fd797b730784cff4d1144c5a3ab1027c7dd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2086493
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago
Edward Lemur 1a83da1f41 git-cl: Fix Python 3 bugs
- Don't encode description when calling presubmit,
  codecs.open already takes care of that.
- Don't use raw_input on Python 3
- Encode stdin when calling clang-format.

Bug: 1058318, 1058318
Change-Id: I825422e160c00b33b2c52b6e64e5f0a3e44606f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2086631
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
5 years ago