Commit Graph

1332 Commits (acdf15a20737d2727fdf80bcb65a38d25df0f8ba)

Author SHA1 Message Date
Allen Li 47701fdcd0 [git_cl] Fix creds_check new auth switch logic pt 3
Third time's the charm.  The issue is still the "multi-valued boolean"
logic.  I introduce a new "switched on" concept to clarify things.

If new auth is "switched off", then all new auth related things are
off.  Simple enough.

There are two ways for new auth to be "switched on".  Either it is
explicitly enabled in the user's config, or we rolled out the default
to on.

When it is "switched on", we still rely on the presence of .gitcookies
to determine whether we enable new auth for depot_tools.  HOWEVER, we
must use the new git cl creds-check, because that is the intended way
for users to remove their .gitcookies file.

                     | auth logic | creds-check |
switched off         | old        | old         |
switched on +cookies | old        | new         |
switched on -cookies | new        | new         |

Change-Id: I311089960d78d8be2cdffd00e4515bfebf0f8f58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6439385
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
3 weeks ago
Allen Li 50e0120582 [git_cl] Fix creds_check new auth switch logic pt 2
I got greedy with the first fix, with the assumption that the flag
enablement would not get rolled back.  As it would be easier to not
worry about this logic flip-flopping based on the default flag
flip-flopping.

Spoilers: it did get rolled back, so we end up with the new
creds-check with the newauth flag defaulting to off.  And this causes
a UX problem because new users would get prompted to run creds-check
to set up a gitcookies file, but the new creds-check logic doesn't do
that.

Based on our newfound experience, this should just follow the default
value.  There'll still be some friction whenever we flip-flop the default
value, but that's kind of unavoidable.

Change-Id: I0d81ed4123a8a9bced2fc4300214376cd3f1c9d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6434738
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
4 weeks ago
Gennady Tsitovich 6cc266569e git cl cherry-pick: Use base parameter to fix identical tree errors
The `git cl cherry-pick` command previously created chained CLs by
first cherry-picking a change onto the destination branch tip and then
rebasing the result onto the parent CL created in the previous step.

This approach failed when a sequence of cherry-picks resulted in an
intermediate state having an identical tree compared to its intended
base (e.g., commit 1 changes X->Y, commit 2 changes Y->X). Gerrit
would reject the second cherry-pick with an "identical tree" error
because the rebase is done after the cherry pick.

This change modifies the process to use the `base` parameter of the
Gerrit `cherrypick` REST API endpoint.

Changes:
- Modify `gerrit_util.CherryPick` to accept and pass an optional `base`
  commit hash in the API request body.
- Update `git_cl.CMDcherry_pick`:
  - Before each cherry-pick operation in the loop, fetch the commit hash
    of the latest patchset from the previously processed parent CL.
  - Pass this commit hash as the `base` parameter to `gerrit_util.CherryPick`.
  - Remove the subsequent, now redundant, call to `gerrit_util.RebaseChange`.

This ensures the correct parent commit is specified during the
cherry-pick operation itself, allowing Gerrit to handle the chaining
correctly and avoid failures caused by identical tree states in
intermediate steps.

Bug: 408388488
Change-Id: I84066d65bd6bb127b253bee6564dd0622148a0e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6433112
Commit-Queue: Gennady Tsitovich <gtsitovich@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
4 weeks ago
Allen Li 9e7aa23589 [git_cl] Fix creds_check new auth switch logic
The three-way logic here (explicitly on, default (which is now on),
explicitly off) was slightly off.

Bug: 408243787
Change-Id: Idc0b55e63627708fe257ea7ca5a7f5f5dd5e1c08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6431386
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
4 weeks ago
Allen Li 2bfa28f442 [newauth] Print warning for .gitcookies file
This will print a warning and disable new auth if .gitcookies file
exists.

This ensures we don't break bots once we default new auth on while
pushing human users away from .gitcookies.

Bug: b/404613530
Change-Id: Ia2d05bb7e5d2bf11e5605a26ef492954acbd9833
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6367723
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
1 month ago
Allen Li a2c6f107c3 [git_auth] Move config wizard to creds-check
Bug: b/404613530
Change-Id: Ie0b8fd675b66739a129d5eeeda895473a8a49eeb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6368999
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
1 month ago
Allen Li 8fecc592a2 Add auth config wizard
Make this available for testing first.

This should be functionally roughly analogous with the current auto
configuration logic, and it prints all actions it performs so it
should be pretty safe to play with, even if it hypothetically
misbehaves.

Bug: b/401338175
Change-Id: I803c7e167e355ec8cca1f5959099138c2fee305e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6334614
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
2 months ago
Scott Lee 330c155fd0 Revert "pass -sort-includes to clang-format-diff.py by default"
This reverts commit 764c8c0616.

Reason for revert: Please find https://g-issues.chromium.org/issues/402201301#comment10

Original change's description:
> pass -sort-includes to clang-format-diff.py by default
>
> clang-format-diff takes a diff output as input, and formats
> the input file, but the changed lines only.
>
> In crbug.com/402201301, it was found that it sometimes breaks
> includes grouping because it tries to format the changed include
> lines only.
>
> This CL is to pass "-sort-includes" to clang-format-diff.py so that
> it always formats the include blocks, even if they are not part of
> the changes included.
> https://source.chromium.org/chromium/chromium/src/+/main:third_party/clang-format/script/clang-format-diff.py;l=70-75;drc=d2bee6477349e500ed274b15a9da8e062a0fcf27
>
> Bug: 402201301
> Change-Id: I214ae15202469dd5c7d55c2eb43c4cce39ad731b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6343956
> Commit-Queue: Scott Lee <ddoman@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>

Bug: 402201301
Change-Id: Ibfc70b68a9153d242bc011dfe17a73d671760842
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6355303
Commit-Queue: Scott Lee <ddoman@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 months ago
Scott Lee 764c8c0616 pass -sort-includes to clang-format-diff.py by default
clang-format-diff takes a diff output as input, and formats
the input file, but the changed lines only.

In crbug.com/402201301, it was found that it sometimes breaks
includes grouping because it tries to format the changed include
lines only.

This CL is to pass "-sort-includes" to clang-format-diff.py so that
it always formats the include blocks, even if they are not part of
the changes included.
https://source.chromium.org/chromium/chromium/src/+/main:third_party/clang-format/script/clang-format-diff.py;l=70-75;drc=d2bee6477349e500ed274b15a9da8e062a0fcf27

Bug: 402201301
Change-Id: I214ae15202469dd5c7d55c2eb43c4cce39ad731b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6343956
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 months ago
Peter Wen 5d5ea66f01 git_cl: Add flag for owners override
This allows setting OO+1 with `git cl upload --enable-owners-override`.

R=sokcevic@chromium.org

Bug: None
Change-Id: Iddac69653a539a15beee38ea4957be1a9b19b57a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6340467
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
2 months ago
Devon Loehr 9dc0551d52 [git cl split] Add new cluster-based splitting algorithm
This CL adds a new way of generating splittings, which clusters files
based on their directory structure (while respecting `set noparent` in
OWNERS files). The user provides a minimum and maximum acceptable
number of files per CL, and the algorithm attempts to create CLs in
that range with a single unique reviewer for each. I've tested it on
some example CLs, and it seems to work well -- certainly better than
the existing algorithm.

Usage of the new algorithm is triggered by passing the
`--target-range` option to `git cl split`. A second new argument,
`--expect-owners-override`, may also be used to ignore OWNERS during
the clustering algorithm.

Bug: 389069356
Change-Id: I321e6424b2bdb7624b370af23b73759fda261161
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6324373
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
2 months ago
Josip Sokcevic dbfdedfa08 Fix root path on Windows
User may use lowercase drive letter when entering gclient workspace.
In such case, path should be corrected to real path value.

R=wfh@chromium.org

Fixed: 401141847
Change-Id: I0b08985ec5c911a315922858d248ff53a10ed682
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6336450
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
2 months ago
Devon Loehr f0b8c3b16c [git cl split]: Allow users to override reviewer assignment
This CL adds a --reviewers flag, which allows users to specify that CLs
should all be sent to the same (possibly empty) set of reviewers. This
can be useful for LSCs where OO+1 is available.

Bug: 389069356, 40269201
Change-Id: Ic6202b280bb676f75a71c4ccf0c41b32483d5c6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6298664
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
2 months ago
Devon Loehr 4629c3474e [git cl split]: Deprecate $directory in favor of $description
`git cl split` allows users to parameterize their CL descriptions
by including the string $directory, which is replaced by the list of
directories covered by each generated CL. However, as we add more ways
of generating splittings, a list of directories may not always be the
most appropriate description. For example, the --from-file option lets
users write arbitrary description strings.

This CL renames the $directory string to $description, to reflect this
new generality, and refactors all places in the code that expected a
directory list instead of a string. Since users may beused to the
current version, it does not remove $directory, but instead notes that
it is deprecated and emits a warning when it is used. After some time,
we can remove it entirely.

Bug: 389069356
Change-Id: If8c947fdcbbb4897675b015a377cf21123e51467
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6299688
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
2 months ago
Devon Loehr 158b6837dc [git cl split] Add summarize option during dry runs
Currently, the dry run setting causes the script to print out extremely
detailed information about the splitting it generated. While this is
sometimes useful, often users only care about the overall shape of the
splitting. This CL adds a flag which lets them see the same brief
summary that's printed during full runs.

Bug: 389069356
Change-Id: I473740e50f382e63b1289101f3253ff8ae9e6bbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6298096
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 months ago
Scott Lee f945c74073 git_cl: sets opts.full if format-full-by-default is set
settings.GetFormatFullByDefault() looks up a git config to find if
format-full-by-default is set.

RunClangFormatDiff() and RunGoogleJavaFormat() uses the function to
determine whether it should format a given document full or not, and
it makes it difficult to make the wrapper functions git-op free.

To remove git dependencies from the Run functions, this CL simply sets
opts.full if the default is set.

Note that this CL makes a behaviour change to the Python Runner.

RunYapf() doesn't honor settings.GetFormatFullByDefault().
It just looks at opts.full only to determine how to format the file.
If this CL is landed, RunYapf() will take account of the git config to
determine whether it should format the full document or a part.

Bug: 386840832
Change-Id: Ibd7210e20897d354bd3eddf84927cf22105b7255
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6256552
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
2 months ago
Alex Gough 74e3dea38d Add .test-mojom to mojom formatted types
These files are testonly but can still be formatted by the
mojom formatter, so add to the matched extensions.

Bug: 397343888
Change-Id: I60352e8400e68426f262eb5601b76c17c0f0b912
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6279546
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Andy Perelson <ajp@google.com>
Commit-Queue: Alex Gough <ajgo@chromium.org>
2 months ago
Devon Loehr 0822fcc141 `git cl split`: Save and load splittings from files
This CL implements the proposal (from the design doc in the cited bug)
to allow `git cl split` to save the generated splitting to a
human-readable and editable text file. This allows users to save the
splitting in case something goes wrong and they need to retry, and also
lets them tweak a generated splitting if they get something mostly, but
not quite, usable.

It also allows users to edit the generated splitting interactively, like
they do for e.g. CL descriptions during `git cl upload`.

Bug: 389069356
Change-Id: I8ae21f2eb7c022ba181ae5af273ce09605b5acec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6235727
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
3 months ago
Gavin Mak 912a744103 Add next steps to 'git cl presubmit' cog error message
This updates the presubmit error message when running on Cog to
include instructions on how to trigger presubmits. This also
standardizes the messaging across git cl presubmit/web/presubmit.

Bug: 394615879
Change-Id: Iaa8857268cd43219f7502eb34388034890a919dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6240212
Reviewed-by: Andy Perelson <ajp@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
3 months ago
Alexander Cooper 682a6e1194 Add git cl squash-closed behavior
Introduces a new git cl command `squash-closed`. Similar to archive,
this will operate on all closed branches. Unlike archive, rather than
removing these branches and potentially leaving their downstreams in a
wedged state, this will squash the branch and appropriately reparent the
downstream. This makes this a good function to run in preparation of a
`git rebase-update`, especially if there are chained git branches, as
this will then shrink any merged branches to a single commit which
should cleanly apply and drop off.

Bug: 40264739
Change-Id: I1836f944d43f5f3dcebbebf06437bef890da96ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6230362
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
3 months ago
Gary Tong cf5b6bd0cb Update message on how to format changes
Bug: 379902295
Change-Id: I6d4b2753664c20887f7063865536ce071252844d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6226155
Reviewed-by: Scott Lee <ddoman@chromium.org>
Auto-Submit: Gary Tong <gatong@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
3 months ago
Gennady Tsitovich 0d8b87d190 Fix cherry-picking in a non-git environment.
None was always passed to urlparse causing "Unable to determine host" error.

Bug: b/391547354
Change-Id: I58b63b4a33135952cae102e8446eea7cb3a82531
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6226685
Commit-Queue: Gennady Tsitovich <gtsitovich@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
3 months ago
Scott Lee c60f8194a5 lucicfg: format star files if --lucicfg
Bug: 390409288
Change-Id: Ida238f3a903c4f1dd31c8fa007e0a8823aeaf1aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6219826
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
3 months ago
Arthur Milchior d3717ed04d [Depot tools][Split]Clarify max depth
Looking at split’s documentation it was not clear what was the
behavior when the max-depth flag was missing. As it’s the default,
this seems like an important information. Especially when a warning
state to use it. Also, I thought the depth was counted starting from
the file, not the root. E.g. for file a/b/c/d/e.cc, the depth 1 would
mean using a/b/c/d/OWNERS, and not a/OWNERS. I believe that an example
would make it clearer to future users of LSC how to use this value.

Bug: None
Change-Id: I5d2b4f2fefceb8a4ec86ee1c508fb7848f69e44f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6179836
Auto-Submit: Arthur Milchior <arthurmilchior@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Arthur Milchior <arthurmilchior@chromium.org>
3 months ago
Gennady Tsitovich 45716abe5c Allow using `git cl cherry-pick` in a non-git environment.
This includes:
- adding `--host` parameter to `git-cl cherry-pick`
- adding `GetCommitMessage` to gerrit_util to be able to switch from `git show` used to get the commit message for a change

Bug: b/391547354
Change-Id: I9af227a78af5aaa1bdc98fc2520d98b413f0f3ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6180633
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gennady Tsitovich <gtsitovich@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
3 months ago
Joanna Wang a1fd773224 Remove unnecessary RunHook call for squash mode.
RunHook being called at the beginning of the git cl upload command, is necessary for non-squash mode, but is an extra and unnecessary call for squash mode. This Runhook call can be moved later down the call stack as well, but would require a lot more changes to tests (in what needs to be mocked)

Change-Id: I0373c5de84d98c4e8c39dece95a247227562ab82
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6181588
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
3 months ago
Scott Lee 6bd1b66c51 Fix computing diffs in git_cl.py
The modified lines are corresponding to the following codes in
clang-format-diff.py
: https://source.chromium.org/chromium/chromium/src/+/main:third_party/clang-format/script/clang-format-diff.py;l=124-135

This CL fixes the following two issues.

1) if lines are simply removed w/o replacements in the original text,
_ComputeFormatDiffLineRanges() returns values that result in
--line $start:$start, which formats the start line number of the secion
in the new text, whcih is not the removed line.

If lines are simply removed, no formatting is necessary in the new text.

2) incorrect line counts in the next text.
The line count includes the starting line. Therefore, if the hunk has
12:1, it corresponds to the single, 12th line. However, the existing logic
translates it as 12th and 13th lines.

In most cases, the above issues won't make visible changes. Even if
they do, engineers wouldn't notice, as it would just format one additional
line below the changes that they made.

However, this CL is to match the same behaviour implmented in
clang-format-diff.py


Change-Id: Ifd2a19c8801c836f8e0799410b372a0f258fd476
Bug: 379902295
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6172780
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
4 months ago
Devon Loehr 24d9ad69fa split_cl: Make description file optional during dry runs
I frequently find myself running `git cl split` just to see how the
files are going to be split up, without actually intending to submit the
resulting CLs immediately. Doing so requires creating a file, putting a
dummy description in it, and passing that to the command line, which is
unnecessary work. This CL simply allows dry runs to use a dummy
description if none is provided, to make checking the tool's output
easier.

Bug: None
Change-Id: I47e06c6e6da26701e07dcae81ab605edac2e2ca6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6163904
Reviewed-by: Andy Perelson <ajp@google.com>
Commit-Queue: Devon Loehr <dloehr@google.com>
Reviewed-by: Brian Ryner <bryner@google.com>
4 months ago
Scott Lee 88bc812650 Reland "Support formatting metrics xml(s) in the subfolders."
This reverts commit bfe1a9282d.

Reason for revert: reland with a fix.
- Find the diff between ps#1 and ps#2.
- Tested at https://paste.googleplex.com/4670451708854272

Original change's description:
> Revert "Support formatting metrics xml(s) in the subfolders."
>
> This reverts commit 597ba08be5.
>
> Reason for revert: it broke git_cl.py. Need further patch
>
> Original change's description:
> > Support formatting metrics xml(s) in the subfolders.
> >
> > https://crrev.com/c/6072565 assumed that the XMLs are located under
> > tools/metrics/{actions,ukm,structured,histograms} directly, such as
> > tools/metrics/histograms/enums.xml.
> >
> > However, its subfolders may have XML files, and it should format
> > the files. This CL fixes it.
> >
> > Bug: 384940858
> > Change-Id: I56484144e6f72f41eb5bc37a5ad462a0de1ec0e3
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111994
> > Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> > Auto-Submit: Scott Lee <ddoman@chromium.org>
> > Commit-Queue: Scott Lee <ddoman@chromium.org>
>
> Bug: 384940858
> Change-Id: I322573ad6d2d758cd3d2de872efdbba4fd9330c2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111996
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Scott Lee <ddoman@chromium.org>

Bug: 384940858
Change-Id: Ibe20d5e46c519d7fdbd1114565ec3856e5bf928e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111997
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
4 months ago
Scott Lee bf32de3167 add metrics_xml_formatter
git cl format supports formatting certain xml files under tools/metrics.
This CL adds metrics_xml_formatter so that the formatter can be run
with git cl format.

Bug: b/369827156
Change-Id: I5922cd79304aa8e06917aacc9f2d9bd3ed548c2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6072565
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
5 months ago
Allen Li 522f5a4bd1 gerrit_util: Use git-credential-luci instead of luci-auth
git-credential-luci is very similar to luci-auth, except that it is
expressly for git/Gerrit.  Therefore, it hard codes the scopes needed
for git/Gerrit.  It's also a separate binary, which makes it more
convenient for us to configure it for ReAuth later.

Bug: b/382341041
Change-Id: I7de56d3922adac7eb4671849eb6e30be310d4de7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6073043
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
5 months ago
Allen Li d2fdba4e78 Improve printed info in git cl creds-check
May help user to diagnose/debug some issues.

Bug: b/372552465
Change-Id: Ia9fc4fd49c8ee80bccd98442ed5589324d0b23b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6068966
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Allen Li <ayatane@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
5 months ago
Matt Stark 46ade108f8 Update the error message for detached head.
This allows for better support for both jj and git-branchless, both of which require no branches.

Change-Id: I63d9273ed5f38f6b6bb24a1ba2ecd559983120a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6002155
Commit-Queue: Matt Stark <msta@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
6 months ago
Joanna Wang 9bf2a2011a Improve message about why someone might want to use --force during `git cl patch`
Change-Id: I1c96164049513edb8e907928053b1eb09be2040f
Fixes:b/375594912
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5979029
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
6 months ago
Scott Lee 136e7e7594 [cpplint] add stdin support in stdin
Cpplint can already process input from stdin (when the filename is '-'),
but `git cl lint` currently lacks this capability.

Adding stdin support to `git cl lint` would enable seamless integration
with IDEs like Visual Studio. Linters could then operate directly on
unsaved code within the editor.

Bug: 372288610
Change-Id: Ib2d5a3534ac0c5afcfcac64b708becde41612881
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5917767
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
7 months ago
Anne Redulla 1291794f5e Check git version
On `git cl upload` and when running a command on all deps
using `gclient` in a non-Cog env, prints/logs a warning if git
should be updated. Non-blocking; command should still be
attempted as usual.

Bug: b/360206460
Change-Id: I8ebef4cb8b520124bc34ade7f0f2179874b470a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5874690
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
7 months ago
Allen Li 4b94130034 [gerrit_util] Add fallback if missing Gerrit account
Bug: b/366261039
Change-Id: I7d22c4f03ad9bd837190dee7a511af3437a30434
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5869050
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
7 months ago
Joanna Wang d43a3eb748 Add end_commit for calculating GitChange diffs.
Bug: b/365162784

Change-Id: I97b69b1ae5183bbdaa7d4de0b1f23e62f4e1d8d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5853908
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Joanna Wang <jojwang@chromium.org>
8 months ago
Gavin Mak 43691064b4 Remove commits-to-cherry-pick only after a cherry-pick is created
If `git cl cherry-pick` fails to cherry-pick a CL, it should print
out the commit it failed to cherry-pick. Right now, that commit
is missing from the "print_any_remaining_commits" output
since commits get popped from the dict regardless of whether or
not a CL is created.

Bug: 364375259
Change-Id: Iac61f50b8f8f226b9e70bc2d0fa235f39c27d91e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5829953
Auto-Submit: Gavin Mak <gavinmak@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
8 months ago
Arthur Eubanks 5eca5541e8 [git-cl] Only ignore deleted files for formatting purposes
Multiple people have complained that we should format files when changing class names. That seems better than not formatting moved/copied files (you can always format a file separately before moving it to workaround the issue of moving unformatted files and presubmit complaining).

This CL essentially reverts https://crrev.com/c/4904205, meaning we will again run clang-format on files that were copied/moved.

https://crrev.com/c/5199134 is probably the proper fix by only looking at lines that were actually changed, but does not yet work with non-C++ formatters.

Checked locally that previously we wouldn't format a moved file, and with this change we now do.

Bug: 737568
Change-Id: Ie12c802316d5e293f2946c532e1600c342caaf59
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5840596
Commit-Queue: Arthur Eubanks <aeubanks@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
8 months ago
Gavin Mak 9e91079582 Use the cherry picked CL's Change-Id
If a CL and its cherry pick share a change ID, Gerrit will link to each
other in the UI.

Bug: 364692466
Change-Id: I6740ddfd813124d5876b29b05c4b8f91822faa57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5838865
Auto-Submit: Gavin Mak <gavinmak@google.com>
Reviewed-by: Matt Jones <mdjones@google.com>
Commit-Queue: Matt Jones <mdjones@google.com>
8 months ago
Gavin Mak 2836a02f55 Make "git cl cherry-pick" handle failed cherry picks better
"Better" means:
1. Retrying a failed gerrit_util.CherryPick only once instead
   of 5 times for faster feedback since more retries don't help.
2. Gracefully handling GerritErrors raised by gerrit_util.CherryPick

This CL also fixes a minor bug where the "Remaining commit(s) to
cherry pick" message would always print even if there were no more
commits left.

Bug: 341792235
Change-Id: I1712a6b080b14396463f3bceeeac84772f1253b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5825626
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Joanna Wang <jojwang@chromium.org>
8 months ago
Robert Iannucci b46b033bd7 [git-cl] Make quick Gerrit RPC at the top of CMDupload.
This prevents the following scenario:

$ git cl upload ...
<runs `git status`>  # slow operation
<runs `git cl presubmit`>  # slow operation
<runs $EDITOR /commit/message> # requires thinking
CRASH!! You need to authenticate!!
$ <authenticate>
$ git cl upload ...
<runs `git status`>  # slow operation
<runs `git cl presubmit`>  # slow operation
<runs $EDITOR /commit/message> # opens new, fresh, editor :(

Now it will do:

$ git cl upload ...
CRASH!! You need to authenticate!!
$ <authenticate>
$ git cl upload ...
<runs `git status`>  # slow operation
<runs `git cl presubmit`>  # slow operation
<runs $EDITOR /commit/message> # requires thinking

R=ayatane, sokcevic@google.com

Change-Id: Icada2b69b3f4ddaff810dc82d54d65f3918d1434
Bug: 351071334
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5826970
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
8 months ago
Gavin Mak aaaca2863c Make git cl cherry-pick use a unique change ID
If a commit's Change-Id identifies more than one change, git cl
cherry-pick will get an error when trying to rebase the cherrypick:
"Multiple changes found for <change-id>"

Make sure the command only uses a CL's unique ID.

Bug: b/362514041
Change-Id: Ia84053fc8a49eadfc0f1e732929fb58e507a6bb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5818412
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
8 months ago
Gavin Mak d4c6d40d50 Reduce RebaseChange max tries from 6 to 2
On failure, gerrit_util always retries HTTP requests the maximum
number of times. This doesn't always make sense, e.g. for RebaseChange
which gets 409 on a merge conflict and can't be retried into
succeeding.

Bug: b/341792235
Change-Id: I6f9e212c5b0365236a99768f056bab2eb60cddc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5773566
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
9 months ago
Gavin Mak ec800aa077 Add "git cl cherry-pick" for cherry picking a chain of CLs via Gerrit
Users who want to upload multiple cherry picks usually run "git
cherry-pick" locally, multiple times. Gerrit does not recognize
these changes as cherry picks and neither do other services that
query cherry pick info from Gerrit, e.g. rubber stamper.

For Gerrit to identify a change as a true cherry pick, you need to
use their Cherry Pick Revision REST API endpoint. This new command
uses it to create a chain of cherry pick CLs recognized by Gerrit.

Bug: b/341792235
Change-Id: I4ba75da3901f6ea68c1debd65820e802da681798
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5756161
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
9 months ago
Allen Li 40cece20d0 [git_cl] Fix some type checking errors
Bug: b/351071334
Change-Id: I15b8c7658c5959dbf88168e278525c2b8e2e4b2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5754255
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
9 months ago
Allen Li 72c2f2b6a5 [git_cl] Fix parse_args type checking
Bug: b/351071334
Change-Id: I1387d88196d06ce6c10fdff3253cebcc21428bbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5754388
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
9 months ago
Allen Li be5ff1a6c4 [git_auth] Move auto configure logic
Bug: b/351071334
Change-Id: Ic6574f86208b22e406e36f8cd45a564ea74ec7f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5742793
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
9 months ago
Allen Li db74f93ff9 [git_auth] Rename configure functions
Bug: b/351071334
Change-Id: Ic0378590bd678226db2563e9180076f87dafdc66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5739678
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
9 months ago