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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
"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>
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>
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>
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>
To prevent import cycles when moving the auth functions to git_auth
Bug: b/351071334
Change-Id: Idfb474b9a738d5db51dcd82ffde5d047cc36af9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5742790
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
Adds new Git auth configuration logic which sets up a global config
which applies to all repos for a Gerrit host, as well as a local
config if the current repo has a different user set up (e.g., someone
with multiple emails used across different repos for the same Gerrit
host).
Bug: b/351071334
Change-Id: I3a73a50b7ecc80ba22442de808b7f20a488ffc6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5723271
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
There's going to be a use case to clear auth configuration even after
we remove the old auth stack.
Renumbering is safe because this enum is not stored outside of runtime.
Bug: b/351071334
Change-Id: Ib6522ffa6f1c8d817a37cce48d1abf2fcd7be339
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5727083
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Make the name more accurate, this mode is specific to auth config
GitAuthConfigMode would be more accurate, but too verbose IMO
Bug: b/351071334
Change-Id: If5c7c07ee5fa62d3ac1026b04654650c1b7043f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5723270
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
Moves the dependency on Git+cwd up the call stack
Bug: b/351071334
Change-Id: Ia313f9d4720ee10398b757217c333118e9fc7341
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5723091
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
We need to be able to do this from different dirs later.
Bug: b/351071334
Change-Id: I18dd2c71ea52d79a56ccaee88a12be97465b9d2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5723089
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>