Commit Graph

1226 Commits (6359e82d133bc40d0b6af15346e513d63374602c)

Author SHA1 Message Date
Allen Li 6359e82d13 [git_cl] Add new auth support for creds check
Bug: b/348024314
Change-Id: I157380b19121a9fbcee2a1a13447df9c03f7bccc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5646659
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
10 months ago
Robert Iannucci 005e60ceda [git_cl] Make EnsureCanUploadPatchset work for all auth methods.
Previously EnsureCanUploadPatchset only had a working implementation
for the CookiesAuthenticator, relying on being able to parse the
user name out of the .gitcookies file.

Additionally, the previous implementation assumed that you would
always authenticate as your primary Gerrit account OR you had
a matching `user.email` gitconfig entry, even though neither of these
is a strict requirement for the upload to work.

The new implementation still short-circuits if issue_owner matches
the configured user.email, but other than this it just asks Gerrit
what the full list of linked emails is for the currently authenticated
account.

The new approach is not only correct, but will now work for all auth
schemes in exactly the same way.

When the accounts do mismatch, you will now see output like:

```
WARNING: Change 5590262 is owned by iannucci@chromium.org, but Gerrit knows you as:
  * user@example.org
  * other.user@example.com
  * primary@real.example.com (preferred)
Uploading may fail due to lack of permissions.
```

R=ayatane@chromium.org, yiwzhang@google.com

Bug: 336351842
Change-Id: I89c1b121c9110e00d1348884aaf025fc783542d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5590262
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
10 months ago
Robert Iannucci 6daca50597 [git_cl] Refactor EnsureAuthenticated logic.
This will allow us to implement EnsureAuthenticated for other
Authenticator implementations.

R=ayatane@chromium.org

Bug: 336351842
Change-Id: I5ff4efd45eb5baa6baa048842510ec6e18e1b8fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5588510
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
10 months ago
Allen Li 06673958a3 [git_cl] Fix comment about GetCodereviewServer
Previous comment was... lacking.  Actually, wrong.  It's doing the
exact opposite of lazy loading.  Maybe they were trying to use AI code
gen before it existed?

Bug: b/348024314
Change-Id: I068d43fe1abf757cb8b109890a14ca0cefe3fec0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5641090
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
10 months ago
Yiwei Zhang 66df2a3ec7 git cl upload: introduce commit-description option
This new option allows programatically providing new
description when uploading a new patchset.

Bug: 346174899
Change-Id: I6d7e361b7da0fd06675c04df4fd2f68c7954dd40
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5620640
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
11 months ago
Aleksey Khoroshilov 093f878224 Fix java format with --diff passed
Accidentally removed few parameters in [1].

1. https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5613673

Change-Id: I944370d13d86980a1dabadb8c9eda69d078de0f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5632781
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Aleksei Khoroshilov <akhoroshilov@brave.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
11 months ago
Aleksey Khoroshilov c0883c509e Fix git diff calls when a lot of files modified in a branch
Running a command line longer that 32k on Windows lead to issues (as
usual). We run git diff in multiple scenarios on a list of changed
files. This list is not partitioned and may lead to a command line
much longer than OS can allow.

This change replaces BuildGitDiffCmd with RunGitDiffCmd that splits
the file list internally and runs git diff multiple times if required.

Change-Id: Icfd8efc7520105b8d98125e90bb96c2bb9bd3a0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5613673
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: Aleksei Khoroshilov <akhoroshilov@brave.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
11 months ago
Ben Pastene fd85601398 git_cl: Remove support for '--clobber' arg
The chromium recipe (and only the chromium recipe?) currently reads this
prop to trigger a clobber build. But support for that in the recipe is
being removed in https://crrev.com/c/5620860. So this removes the
ability to set that arg via `git cl try`. Across all chrome/chromium
builders, that arg was only passed in six builds in the past year. So
it's very unlikely anyone depends on it, or will notice it's gone.

Bug: 346363294
Change-Id: Icf05c9a2fd6f2e9239c735e4c5507aee9a26e0e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5620634
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
11 months ago
Robert Iannucci 6427b94bc2 [git_cl] Refactor EnsureAuthenticated.
This will allow us to invert the main Authenticator API.

R=yiwzhang@google.com

Bug: 336351842
Change-Id: Iebe06f68373b99685809849bcd96371e7634d6ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5582406
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
11 months ago
Robert Iannucci c57b7ed364 [gerrit_util] Change Authenticator API to return proxy info.
This will be used with an upcoming SSOAuthenticator implementation
which will need to proxy all http requests for Googlers.

R=ayatane, gavinmak@google.com

Bug: 336351842
Change-Id: If8cbb8db51fce198e704f109232868421130b40c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5582100
Commit-Queue: Gavin Mak <gavinmak@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
11 months ago
Peter McNeeley dd0dd62997 Provide documentation for title option
Perhaps this is a linux convention but it was not obvious to me that
'y' would use the default.

Change-Id: I5aedcb365828015effa64d41153f6cb9c9318dfc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5580992
Commit-Queue: Peter McNeeley <petermcneeley@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
11 months ago
Robert Iannucci a85dcffff4 [git_cl] Refactor away a use of isinstance.
Previously when composing a debugging trace, it would use an
isinstance check to special-case inclusion of a gitcookies file.

This CL refactors this to be part of the Authenticator API, instead,
which means that we will always get some sort of authenticator log
file in a trace, even if it's empty.

This also provides an affordance to add debugging information for
the other authenticator types later.

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

Bug: 336351842
Change-Id: Idd6f45ea60b089f9b2391b5527c5281f67421043
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5571497
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
11 months ago
Robert Iannucci 3ea849f363 [git_cl.py] Remove all usage and messages around netrc.
netrc was already legacy in 2017:
fe30f18fc5

The removed gerrit-init.sh script was written in 2013 and no longer
works.

R=yiwzhang@google.com

Bug: 336351842
Change-Id: Ia8e845899973eb5ead66aee2f54078c09d80ef28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5564197
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
11 months ago
Robert Iannucci 2f779d3061 [git_cl] Minor type annotation and initialization cleanup.
Noticed that the comments around lazily initialization on settings
mentioned that it does logging or something like this, but in fact
the __init__ method is purely vanilla.

R=gavinmak@google.com

Bug: 336351842
Change-Id: I9d8120001690b2bbd52ac2172d346ce95e2dddd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5565083
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
11 months ago
Josip Sokcevic ab914fad1e Improve cloudtop error message on git cl failure
R=gavinmak@google.com

Fixed: 280621923
Change-Id: I856dc1eb4f3fcd65906196b66f358b1dd413012e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5547690
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
12 months ago
Yiwei Zhang d431e7606b requires files for git cl lint if called in cog
Reason: In cog, there's currently no way to get the file diff.

Bug: 339231299
Change-Id: Ibe1cf771fbc84a1710ce7f72d13250877d4d21a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5539168
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
12 months ago
Yiwei Zhang dc87892549 git cl commands fail gracefully when called in Cog
Bug: 339231299
Change-Id: Ia2713ac64cb52d1857ac4ae0cd9db22f73167150
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5539171
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
12 months ago
Scott Lee a76c50e296 [depot_tools] add google_java_format.py
google_java_format.py is a simple wrapper script that finds and
executes the google-java-format binary from Chromium tree.

This CL moves the corresponding function from git_cl.py so that
the logic can be executed without git_cl.py. This is the same strcture
used in git_cl.py for running other language formatters.
- clang_format.py
- swift_format.py
- rustfmt.py
- gn.py

With this patch, google-java-format can be used to run to formatter
a java file in a chromium tree that is located in a non git checkout.

Change-Id: I5f1b845040b28c0a8f15dd2e7c48c83ce2d9df97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5525851
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
12 months ago
Scott Lee 1619815af4 [depot_tools] add file parameter support in git cl lint
Currently, git cl lint runs git commands to retrieve a list of
the affected files and runs the lint tool against the files.

This CL updates the command line argument interface such that,
if file paths are given in positional arguments, git cl will
just run the lint tool against the given files w/o executing any
git commands.

The intent of this CL is to make git cl lint runnable out of Git
checkouts.

Bug: 324595694
Change-Id: I0a68e33931f84c2441da53bf880a2d18a5526ae4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5454166
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
12 months ago
mlcui 979678ce51 git_cl: Fix format dry-run not signalling patch not formatted
This fixes the issue that presubmits were not catching unformatted C++
files.

Presubmit hooks run `git cl format --dry-run`, which is expected to
exit with a code of 2 if the patch needs formatting.

When `clang-format-diff.py` is run by `git cl format --dry-run`, it will
catch any non-zero exit codes and exit the entire `git cl` invocation
with code 1.

However, as of https://github.com/llvm/llvm-project/pull/70883,
`clang-format-diff.py` - now exits with a code of 1 when there are
formatting issues. This will cause the entire `git cl` invocation to
exit with code 1 - not code 2!

Fix the issue by specifying `error_ok=True` in the `RunCommand()` call
to ignore the new exit code returned by `clang format-diff.py`.

Bug: None
Change-Id: I874e5f0710155cd665dfeb4e60d375d6f945ca24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5492806
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Michael Cui <mlcui@google.com>
1 year ago
Yiwei Zhang 85e409e69a git cl: fix a bug that may output stale upstream branch
git cl upstream will run `git branch --set-upstream-to xxx` command
which modifies the git config. However, it doesn't invalidate config
cache. I think an ideal fix would be the git scm exposes method to
invalidate cache and the caller of git command needs to explicitly
invalidate the cache right after git command invocation. However,
I decide to take a "clever" approach here because this seems to
be the only place in git cl that requires explicit cache eviction.
It may not be worth to expose the existence of cache just for this
reason. The "clever" approach swaps the order of subseqent config
modification and config reading. The config modification will always
invalidate the cache. Therefore, It will ensure we are always reading
up-to-date upstream branch name from the fresh config cahce.

Bug: 40942309
Change-Id: I3786fd37799092ce269c7c4d3945c51d077335cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5479950
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
1 year ago
Alexander Schulze b0e2e28a95 Support --target_branch=refs/meta/config branch
This simplifies the administration of repositories which is currently
done via the Gerrit UI instead of the CLI.

Bug: None
Change-Id: I0af3d77fb611e0c89dc455a5a215129b5c51c5ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5472843
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Alexander Schulze <alexschulze@chromium.org>
1 year ago
Will Harris 246580c7b8 Explicitly call vpython3 to launch the mojom formatter
Before this change, on Windows launching the .py file would open it
with the system default handler (none, or notepad.exe) instead of
launching it with python.

This CL fixes this issue. Tested manually on Linux and Windows and
seems to work on both OS.

BUG=332935377

Change-Id: I8ef348c59dd08a4b5c2099f04968622aaa0927d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5427704
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Will Harris <wfh@chromium.org>
1 year ago
Joanna Wang 8ce0983f79 Revert "Print presubmit command during git cl upload."
This reverts commit 913bda46ea.

Reason for revert: no longer needed

Original change's description:
> Print presubmit command during git cl upload.
>
> Bug: 329231688
> Change-Id: I45d0afbebf01ea1cba4d7fdf32843a8e11eb424c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5401481
> Auto-Submit: Joanna Wang <jojwang@chromium.org>
> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
> Commit-Queue: Joanna Wang <jojwang@chromium.org>

Bug: 329231688
Change-Id: I588b0c1a588d663a170cfd218f5338af8e9d1080
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5413953
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
1 year ago
Alex Rudenko b57ec522d0 Revert "git_cl: format .nc file with clang-format"
This reverts commit e545830db2.

Reason for revert: https://crbug.com/332481520

Original change's description:
> git_cl: format .nc file with clang-format
>
> This is for
> https://crrev.com/c/5197064/58/.clang-format#50
>
> Bug: 329138753
> Change-Id: I0938e1d610580e59a66409eb4fea4a1dad138bf1
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5409735
> Reviewed-by: Joanna Wang <jojwang@chromium.org>
> Commit-Queue: Takuto Ikuta <tikuta@chromium.org>

Bug: 329138753
Change-Id: I696eeb3b12540af86e7af0cddfa42f79b27f99f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5412633
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Alex Rudenko <alexrudenko@chromium.org>
1 year ago
Takuto Ikuta e545830db2 git_cl: format .nc file with clang-format
This is for
https://crrev.com/c/5197064/58/.clang-format#50

Bug: 329138753
Change-Id: I0938e1d610580e59a66409eb4fea4a1dad138bf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5409735
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
1 year ago
Joanna Wang 913bda46ea Print presubmit command during git cl upload.
Bug: 329231688
Change-Id: I45d0afbebf01ea1cba4d7fdf32843a8e11eb424c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5401481
Auto-Submit: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
1 year ago
Andrew Grieve 56581348a2 git cl format: Remove unused imports & excessive blank lines
google-java-format will only change the lines given by --lines, which
means that:
a) Unused imports are not removed (assuming they were existing imports)
b) Excessive blank lines between methods are not removed

To address this, run google-java-format a second time with
--fix-imports-only, include deleted lines in ranges, and expand ranges
by 2 lines on each side.

Bug: 1462204
Change-Id: Ia12af6def28d9fe11e8315a951d45908f7cee725
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5362198
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
1 year ago
Tomasz Śniatowski fe6a359a80 Fix git cl format --diff --dry-run for Java files
A recent change added --diff support for Java files in git cl format,
but unfortunately it broke the behavior when both --dry-run and --diff
are passed, and made git cl format indicate that all changed files need
to be reformatted.

Fix so that --diff overrides --dry-run when running google-java-format,
as passing --dry-run makes the formatter only output file names which
then confused the diff creation code. This makes behavior for Java in
line with C++ where --dry-run doesn't change much if --diff is used.

Change-Id: I7f8eecb13064a0046935489e6c5cf3af566f7f56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5357818
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Tomasz Śniatowski <tomasz.sniatowski@xperi.com>
1 year ago
Aleksey Khoroshilov 78bef266ac Display diff on `git cl format --diff` when formatting Java files.
Google Java Format does not support `--diff` parameter, but we can simulate it by manually diffing the output of the tool with the current
file on disk.

All git cl-triggered format tools should support --diff output, because there're situations where a change in a file might be required, but it's unclear what exactly should be changed, because a developer might not have access to the host OS which only runs the check.

We at Brave want to run `git cl format --diff` as a part of CI run when a format check fails.

Change-Id: I2feee60219a54ad44b93bc10f5488a9c05715a4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5351216
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Aleksey Khoroshilov <akhoroshilov@brave.com>
1 year ago
mlcui de6a9a9692 git_cl: Add JSON output flag for `git cl presubmit`
This allows scripts to use `git cl presubmit` to get JSON output from
the presubmit hook.

See https://crrev.com/c/5302055/comment/5b78090c_24935055/ for more
context.

Bug: None
Change-Id: I5aaee016b74f8b7375eaf9c5d10cb0af8d86bad8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5320109
Commit-Queue: Michael Cui <mlcui@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
1 year ago
Eric Leese 875647ed03 Allow refs/branch-heads
This is necessary for uploading v8 changes.

Bug: None
Change-Id: I2847c4bcddacf1985c0c230b892716942ae2b031
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5332374
Auto-Submit: Eric Leese <leese@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Eric Leese <leese@chromium.org>
1 year ago
mlcui cc3373c0e4 git_cl: Fix Python type annotations for Pylance
Pylance does not like the ending bracket on its own line. As
`UploadAllSquashed` above uses inline type annotations, rewrite
`_UploadAllPrecheck`s type annotations inline as well.

Bug: None
Change-Id: I9b34cb4834530fffb9cb1788cd690f34d805f96f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5333896
Commit-Queue: Michael Cui <mlcui@google.com>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
1 year ago
Aravind Vasudevan af26c1dfaa [git-cl] Skip EnsureAuthenticated check for sso:// schemes
Bug: 40276698
Change-Id: I40414607a75287adcacee2ff47f8ba8db4c285c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5325207
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
1 year ago
Gavin Mak b1b1a43f07 Move LSC check into pan project presubmit checks and check num files
git cl upload prompts a user if they upload a particularly large change,
determined by the number of CCs added on the change. With the watchlists
analyzer and eventual removal of CCing watchers from git cl, this check
needs to be updated to work without knowing the number of CCs.

This change does two things:
1. Moves the check from git cl upload to a pan-project presubmit check.
2. Update the heuristic of a LSC from > 100 CCs to > 100 files modified.

Bug: 324562917
Change-Id: I6bd0db9fde942273acebc320c8b52e81b02bd42f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5296199
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
1 year ago
Gavin Mak 32769fe939 Revert "Deprecate --bypass-watchlists flag"
This reverts commit e98e458a9f.

Reason for revert: keep depot_tools CCing watchers while b/324466185 is open

Original change's description:
> Deprecate --bypass-watchlists flag
>
> CCing watchers is now handled by the Watchlists AyeAye analyzer on
> all Gerrit projects that use it, and not CCing watchers locally has
> no effect. Rely on that instead of logic in git cl.
>
> Bug: 41494851, 40242793
> Change-Id: I58fdf8c0a741a9189cccec3b3b56d0a8a1c44058
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5276660
> Reviewed-by: Scott Lee <ddoman@chromium.org>
> Commit-Queue: Gavin Mak <gavinmak@google.com>

Bug: 41494851, 40242793
Change-Id: Ied75beb163b2628343d4dcac5819b5bd77854de8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5281700
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Gavin Mak <gavinmak@google.com>
1 year ago
Gavin Mak e98e458a9f Deprecate --bypass-watchlists flag
CCing watchers is now handled by the Watchlists AyeAye analyzer on
all Gerrit projects that use it, and not CCing watchers locally has
no effect. Rely on that instead of logic in git cl.

Bug: 41494851, 40242793
Change-Id: I58fdf8c0a741a9189cccec3b3b56d0a8a1c44058
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5276660
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
1 year ago
Peter Boström 74a6ca92bb Clean up stacked-changes dogfood
This removes logspam from `git cl` when a user (like me) hasn't opted
either in or out. DOGFOOD_STACKED_CHANGES=1 is the codified behavior.
This removes the DOGFOOD_STACKED_CHANGES=0 opt-out.

Bug: b/265929888
Change-Id: Ia159f898512d815e3a4b76cc8859c599016a7bec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5274266
Auto-Submit: Peter Boström <pbos@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
1 year ago
Aravind Vasudevan 1f441eb375 [fix_encoding] Remove fix_encoding
The fix_encoding module within depot_tools was included back in the python2[1] days to as a be all encoding fix boilerplate that is called across depot_tools scripts.

However, now that depot_tools officially deprecated support for py2 and support >= 3.8[2], the boilerplate is not needed anymore.

* `fix_win_codec()`[3] The 'cp65001' codec issue this fixes is fixed in python 3.3[4].
* `fix_default_encoding()`[5] python3 defaults to utf8.
* `fix_win_sys_argv()`[6] sys.srgv unicode issue is fixed in python3[7].
* `fix_win_console()`[8] Fixed[9].

[1] https://codereview.chromium.org/6721029
[2] https://crrev.com/371aa997c04791d21e222ed43a1a0d55b450dd53/README.md
[3] https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:fix_encoding.py;l=123-132;drc=cfa826c9845122d445dce4f51f556381865dbed3
[4] https://github.com/python/cpython/issues/57425#issuecomment-1093559969
[5] https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:fix_encoding.py;l=29-66;drc=cfa826c9845122d445dce4f51f556381865dbed3
[6] https://crsrc.org/d/fix_encoding.py;l=73-120;drc=cfa826c9845122d445dce4f51f556381865dbed3
[7] https://github.com/python/cpython/issues/46381#issuecomment-1093409968
[8] https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:fix_encoding.py;l=315-344;drc=cfa826c9845122d445dce4f51f556381865dbed3
[9] https://github.com/python/cpython/issues/45943#issuecomment-1093402603

Bug: 1501984
Change-Id: I1d512a4b1bfe14e680ac0aa08027849b999cc638
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5263016
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
1 year ago
Josip Sokcevic 371aa997c0 Delete py2 checks
No script can run on py2 (due to print syntax change), so those
checks are useless (will never be printed).

Change-Id: I9cc7bc8b2665dd09cc7f8939ba255956f96af88a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5262958
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
1 year ago
Robert Sesek 911e2a0893 Add `git cl format --mojom` for .mojom file formatting
This is not enabled by default because it is new and should be
considered beta.

Bug: 780263
Change-Id: I7a4813c7ac4cef7441c5373dff4bb1289e7b99b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5259981
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
1 year ago
Mike Dougherty 68c511349d Improve git cl split warning if more than 10 CLs will be created.
This CL updates the warning printed when more than 10 CLs will be
created to be shown whether or not the CLs are being sent to the CQ
and provides guidance on adjusting the number of CLs using the max-depth
flag. This makes the tool more user friendly by preventing a new user
from unknowingly creating many CLs without realizing there is a
supported option to customize the depth.

Additionally, it sets the default for the cq-dry-run option to False
instead of None and logs the value of cq_dry_run when running a git cl
split dry run.

Change-Id: I6feba24d06dd5e88d9005345d5b0a1e15c53e197
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5234543
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
1 year ago
Brian Ryner 3d6dda8241 Always run yapf with vpython3.
The version we are using now does not run under python 2.7.

Add an explicit python_version 3.8 to the inline spec so that we don't
rely on vpython's default version. This is a no-op change when running with vpython3. We should run yapf under 3.11, but this needs additional testing and likely an update of zipp, so we'll do it separately.

Change-Id: If1fccbe6b13c77a770bd1a8c9de0789d543ba890
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5198109
Auto-Submit: Brian Ryner <bryner@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Lukasz Anforowicz 388f822682 Explicitly specify `--config-path` when invoking `rustfmt`.
This prevents `rustfmt` from looking up directory-specific configs (e.g.
`third_party/rust/chromium_crates_io/vendor/tinyvec-1.6.0/rustfmt.toml`)
and using them instead of the Chromium config.

Fixed: 1517348
Change-Id: I5231443479f1f417608ecac263808dc91963948f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5185319
Reviewed-by: danakj <danakj@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
1 year ago
Josip Sokcevic 0cba8dd68e [owners] Limit number of concurrent Gerrit connections
R=gavinmak@google.com

Fixed: 319469729
Change-Id: I955fa17c80cee25bc2163a8bca0234cdbb659f62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5186760
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Josip Sokcevic cd076ba1b0 [git_cl] Limit number of concurrent connections
When git cl status is executed, it's possible that Gerrit will throttle
some requests. This change sets upper bound of concurrent connections to
20.

R=gavinmak@google.com

Fixed: b/319248186
Change-Id: I51b1d87109447efc8c86d615f12bcafe8c317a90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5181274
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
1 year ago
Josip Sokcevic 450aa8d76c [git_cl] Force lookup CL number
UploadAllSquashed doesn't have access to `cl` object and can't update
the issue number. When a new cl is uploaded with --dependencies flag,
`cl` that is passed to upload_branch_deps is outdated - GetIssue returns
None.

Instead of passing cl, or overriding cl in CMDupload with one generated
by UploadAllSquashed, simply unset lookedup_issue which forces GetIssue
to read value from git config.

R=gavinmak@google.com

Fixed: 1514055
Change-Id: I8a55807b097d464379aade20d9cfa3c01f1db69a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5148352
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
1 year ago
Josip Sokcevic 31a99001bd Remove dead code
R=gavinmak@google.com

Change-Id: If27b290ebb575db5ec93b4abcb7f432bedd6f18a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5153638
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
1 year ago
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
Helmut Januschka 6444de14d1 fix crash in case HEAD exists as a file
Bug: 1428373
Change-Id: If9d988d542345dbfa0e02f7c3d6f935b48372df4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5018937
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Helmut Januschka <helmut@januschka.com>
1 year ago