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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This patch adds functionality for --dependencies if new stack change is
used. However, the user must ensure that parent branch didn't diverge by
running git rebase-update [-n].
Bug: 1441132
Change-Id: Ib2e3e841b6dd22bbdefdc7844d5d157b1d1241d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5095961
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
It turns out that we need forward slashes in one place and back
slashes in two other places, so neither path by itself will work.
This CL changes things to do the slash substitution as needed.
Bug: 1502689
Change-Id: I05681ca5aff9f02a1c4ecc14c3c4e877312118ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5074657
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Diff paths are no longer normalized, and we can use forward slashes as
separators regardless of the platform.
R=dpranke
Fixed: 1502689
Change-Id: I75a2fe824972f0d98b28eb2146c6f05ee4ae2d75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5038641
Commit-Queue: Dirk Pranke <dpranke@google.com>
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
This removes necessity of URL modification to open the settings.
Change-Id: I22314d3e04eac476499773a8680dec32a1886eb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4970438
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
This allows users to click the URL from terminal.
Change-Id: I0b5c2b9d5a8221c41d5152b529edcf82f97464c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4969974
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
The file is conditionally downloaded in chrome, and we do not want to
have "git cl format" fail when editing a .java file on non-linux /
non-android checkouts.
Bug: 1462204
Change-Id: I5fc3b74484e1d9304089118449678acb506d5831
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4943676
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
A missing google-java-format should not break older chromium branches
and non-chromium projects. This causes the formatting step to skip .java
files when google-java-format is not available, and introduces an
environment variable GOOGLE_JAVA_FORMAT_PATH to set a custom path.
Bug: 1491627
Change-Id: I5e3155553630ddc59c1a8d197e96079f6a372454
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4930437
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Removes --google-java-format and adds --no-java.
Does not provide a way to fallback to clang-format, since there is no
established way for projects to declare which formatters they prefer to
use.
Bug: 1462204
Change-Id: Ie116e73ccad0fbd55c968248ae2ebeca130a3f80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4905866
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
This reverts commit 36d937d16d.
Reason for revert: Not sure the best way to notify you about this, but suspect this is the root cause of https://chat.google.com/room/AAAAXGgrwSo/hZDeSAsoQ4k
Verified via rolling back depot_tools
Original change's description:
> Clear existing Change-Ids from description if issue is 0
>
> git cl upload may not create a new change even if issue is 0 because
> of a leftover Change-Id footer in the commit message.
>
> Bug: 1484251
> Change-Id: Ibee0542e0f5a2cbf930b1882892fbb7640054b69
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4880971
> Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
> Commit-Queue: Gavin Mak <gavinmak@google.com>
Bug: 1484251
Change-Id: Ic3230fd7432f57bf9f3d0266b2e2c0df6a7e9bae
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4893199
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
git cl upload may not create a new change even if issue is 0 because
of a leftover Change-Id footer in the commit message.
Bug: 1484251
Change-Id: Ibee0542e0f5a2cbf930b1882892fbb7640054b69
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4880971
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>