Commit Graph

2531 Commits

Author SHA1 Message Date
Allen Li
70179d9d84 gerrit_util: Check user has set usehttppath for reauth
This is in the Git config so it's easy to go unnoticed.

Bug: 462126685
Change-Id: I1ccd21efce580aebfcc8a5a6bef2f7d78e5e75d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7265723
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
2025-12-17 16:58:11 -08:00
Alex Ovsienko
02f1c0f8b7 siso: rewrite the entire siso test to pytest.
With this tests will be easier to read and support.

Also have improved parameterized tests.

The reason why pytest was picked is because as my knowledge goes this is the most up to date and supported unit test framework in Python. The current parameterized tests state is primitive, and the parameterized library was last updated 2 years ago. pytest will help us adopt best practices that later perhaps we could spread to other unit tests in depot_tools.

Bug: 459690822
Change-Id: I67d16b56ff3c4dbd260ea0b07354ef766a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7246550
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
2025-12-17 16:05:19 -08:00
Allen Li
d3d038869a git_auth: Handle conflicting stale local config (reland)
As we prefer configuring the global config, it's possible to leave
stale local config behind if the user is swapping between emails.

Originally:
https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7213753

Fixed to skip clearing local config when not inside a repo (as that errors).

Bug: 466343784
Change-Id: I8b34d24ba3966c66aeebaf11bd0368dfb4b0da28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7265721
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
2025-12-16 17:19:31 -08:00
Josiah Kiehl
4244c70855 Handle Windows command line limits in CheckForCommitObjects.
On Windows, the command line has a character limit of 8191. When checking for commit objects in submodules, the `git ls-tree` command can become very long if many files are affected, potentially exceeding this limit.

This change modifies `CheckForCommitObjects` to check the estimated length of the `git ls-tree` command when running on Windows. If the command line with all affected files would exceed the limit, it falls back to using a recursive `ls-tree` (`-r`) instead of listing each file individually. This prevents command line overflow errors on Windows.

Change-Id: I6a340baefee57f5933473add0601a42ff1e61bb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7254474
Auto-Submit: Josiah Kiehl <kiehl@google.com>
Commit-Queue: Josiah Kiehl <kiehl@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
2025-12-11 18:23:44 -08:00
Alex Ovsienko
ecbf89e1da siso: remove redundant test and consolidate dead then healthy tests.
Bug: b/459690822
Change-Id: I7e3a342d3e5be7b5802275cdce0db2ec6a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7244732
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Reviewed-by: Philipp Wollermann <philwo@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
2025-12-09 22:48:30 -08:00
Alex Ovsienko
a6671ce6c7 siso: consolidate collector kill tests for posix and windows.
Bug: b/459690822
Change-Id: If23c54307a76ecba19e856da145e66736a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7244731
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Philipp Wollermann <philwo@google.com>
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
2025-12-09 22:19:50 -08:00
Alex Ovsienko
ff6558d2ee siso: remove usage of platform library from siso.py
Bug: b/455433899
Change-Id: Iff65cbfd920c93114b784bce8ded91ec6a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7237760
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Reviewed-by: Philipp Wollermann <philwo@google.com>
Commit-Queue: Philipp Wollermann <philwo@google.com>
2025-12-09 21:48:33 -08:00
Josiah Kiehl
7c09ebfd12 Optimize CheckForCommitObjects by batching git ls-tree operations
Significantly reduces the execution time of presubmit checks by
optimizing CheckForCommitObjects.

For CLs with fewer than 1000 affected files, run `git ls-tree` only on
specific files instead of scanning the full tree. This yields a ~70x
speedup (~0.97s -> ~0.01s) for typical CLs.

Change-Id: Ia8b89dbb14a5129ba79944282deba52a3558bdf2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7234371
Commit-Queue: Josiah Kiehl <kiehl@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
2025-12-09 15:07:14 -08:00
Josiah Kiehl
b48cbb3e60 Optimize CheckForCommitObjects presubmit check
This CL optimizes CheckForCommitObjects in two ways:
- Fast Path: If the raw `git ls-tree` output does not contain `160000` (gitlink mode), return early. This avoids parsing entirely for repositories without submodules at the cost of about 3ms.
- Iterative Parsing: For repositories with submodules, use an iterative find loop to locate gitlink entries instead of splitting the entire tree content.

On the Chromium repo:
- Speed: The parsing step is ~7.7x faster (0.04s vs 0.30s).
- Memory: Saves ~78 MB of memory per run by avoiding the creation of ~300,000 string objects during the split.

I also added tests now that it's more than a simple loop.

Change-Id: I903effc50aaedb9130772491ad38385b22477d58
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7231149
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Josiah Kiehl <kiehl@google.com>
2025-12-09 10:55:42 -08:00
Josiah Kiehl
82130f468a Speed up presubmit by caching code-owners check
Currently, presubmit queries the gerrit server every run to check if the
code-owners plugin is enabled.

This CL caches that result in a /tmp file per repository.

This saves as much as 1.5s per `git cl presubmit`.

Change-Id: I1a3631074d1bcbb1a254caa6654fd8434f069aa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7227749
Commit-Queue: Josiah Kiehl <kiehl@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
2025-12-09 10:50:31 -08:00
Lauren Minchin
f520a9305e Add canned check for AyeAye analyzers
Bug:b/464253715
Change-Id: I86bff67eac3aeae00cac9798cb9237e7c5364b10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7237916
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Lauren Minchin <lminchin@google.com>
2025-12-09 10:46:52 -08:00
Alex Ovsienko
6cd31a3b57 siso: have siso.py control if collector creates socket file.
Bug: b/455433899
Change-Id: Ic02cd97ef3db59263859eeab5cd70f986a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7231248
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
2025-12-09 01:16:10 -08:00
Alex Ovsienko
fc502860ed siso: integrate collector call.
Bug: b/455433899

Change-Id: Id72ff71e1b4269b828658c90461ba4b46a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7205886
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
2025-12-09 01:01:29 -08:00
Alex Ovsienko
ac1b095b09 siso: do not restart the collector if projects don't match.
The correct project is set at runtime by siso.

Bug: b/455433899
Change-Id: Ibe1d348729e53425f27812e83a5c7f466a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7234199
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
2025-12-07 20:39:43 -08:00
Alex Ovsienko
f8cc59a94b siso: create _start_collector function.
It will run only when collector subcommand is present and attempt at handling the start and restart when needed.

Bug: b/455433899
Change-Id: I9a8b8001aec29b6ca3db61ec6150deb86a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7183447
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
2025-12-07 15:57:33 -08:00
jj
80d6ca1b1a Replace deprecated ast types with ast.Constant
ast.Str et al. have been deprecated since Py3.8 and have been
completely removed in 3.14. Replace their usage with ast.Constant.

This change should not have any functional impact, since
according to [1]:
> Changed in version 3.8: Class ast.Constant is now used for
> all constants.
> Deprecated since version 3.8: Old classes ast.Num, ast.Str,
> [...]  instantiating them will return an instance of a
> different class.

[1] https://docs.python.org/3/library/ast.html

Bug: 40283283
Change-Id: I0ed8ef3910f921483bff118976f516c5a935e0fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7228507
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: jj <jj@chromium.org>
2025-12-05 11:47:42 -08:00
Yiwei Zhang
e0a877ed8f Revert "git_auth: Handle conflicting stale local config"
This reverts commit e96cff71c9.

Reason for revert: causing https://issues.chromium.org/466343784

Original change's description:
> git_auth: Handle conflicting stale local config
>
> As we prefer configuring the global config, it's possible to leave
> stale local config behind if the user is swapping between emails.
>
> Change-Id: I86e2cda33a90b603e52d525fcb564fb0a5a68eab
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7213753
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Commit-Queue: Allen Li <ayatane@chromium.org>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Iec8ce86a6d17b26e5cc3940a38c6510ad3f855be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7231141
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-12-05 09:56:59 -08:00
Alex Ovsienko
f2ac99f082 siso: make sure we don't try to kill process 0 if it gets returned.
Bug: b/455433899
Change-Id: I8d4e6df5a374e97c0d790fe608964c6f6a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7220270
Auto-Submit: Alex Ovsienko <ovsienko@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
2025-12-04 21:36:50 -08:00
Allen Li
e96cff71c9 git_auth: Handle conflicting stale local config
As we prefer configuring the global config, it's possible to leave
stale local config behind if the user is swapping between emails.

Change-Id: I86e2cda33a90b603e52d525fcb564fb0a5a68eab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7213753
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
2025-12-04 15:15:29 -08:00
Josiah Kiehl
4b799c1e8d Fix presubmit feedback message unit test for cog environments.
Add a test case to verify the presubmit feedback message when running in
a cog environment.

Change-Id: I82baf94f53a53108abb32069d3dcf714222a3353
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7229612
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Josiah Kiehl <kiehl@google.com>
2025-12-04 14:39:20 -08:00
Peter Wen
04f3706a63 git_cl.py: Process comments as threads
Refactor GetCommentsSummary to group individual comments into threads. A
thread is considered unresolved if and only if its last comment is
unresolved.

This fixes a bug where a resolved thread (one that had been replied to
and the resolved box checked in the reply) would still appear with the
--unresolved flag, because the initial comment in the thread is
permanently marked as unresolved.

This change also introduces a CommentInfo dataclass to improve
ergonomics for handling comment data from the Gerrit API.

The display of comments have not been made thread-aware to reduce the
scope of this change.

R=agrieve@chromium.org

Bug: 463411949
Fixed: 463411949
Change-Id: I966f011140ee3874b54d8afbbe00caed7bbe14eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7200823
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
2025-12-03 06:16:04 -08:00
Allen Li
1acf6d271e git_auth: Configure both variations of Gerrit hosts
ChromeOS sometimes uses -review URLs, so we should support both

Bug: 419182970
Change-Id: I9a3836f5544a8422ccda8ded6e9d88d5a10edda2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7173365
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
2025-12-02 16:35:21 -08:00
Ben Joyce
a99ce048b9 Add structured test id upload support to resuldb uploader
Not sure how to roll this to src after landing.
This is similar to changes for structured-test-ids in changes such as:
https://source.chromium.org/chromium/chromium/src/+/main:testing/scripts/common.py;l=203?q=common.py&ss=chromium

Bug:418015486
Change-Id: I742a6a9e7b04735e31aa1b893a1cbffc9d6e3188
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7173696
Commit-Queue: Benjamin Joyce (Ben) <bjoyce@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
2025-12-02 14:08:33 -08:00
Alex Ovsienko
db99cc40f5 siso: do not have _is_subcommand_present print to stdout.
Bug: b/455433899
Change-Id: I20a840669538c1a48a645226b949b37f6a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7205887
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
2025-12-01 17:09:47 -08:00
Alex Ovsienko
f32e176f94 Add an extra check that gcert is installed on machine to make sure that the user is googler.
Bug: b/462556449
Change-Id: I2afff69ee202659e23d822c59dd4cc166a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7201883
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
2025-12-01 17:01:18 -08:00
Alex Ovsienko
4d6030e6b1 siso: create function to kill potentially running collector.
It checks running processed for what ports they occupy and kills the first process that occupies otlp_health_port that is known from config and quits.

Bug: b/455433899

Change-Id: Ib588be4c44021e55c67f1601040ac72a6a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7183397
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
2025-12-01 16:53:57 -08:00
Adam Norberg
3d401c263f Caffeinate fetches on Mac.
Since fetches involve multiple subprocess calls, any of which can be
slow, the per-subprocess caffeination strategy does not seem suitable --
the Mac might sleep as soon as the wake lock is dropped, before it
starts a new one. This instead implements a context manager to allow
caffeinating a scope.

To allow flag control, caffeinate.scope takes an argument that decides
whether or not it should actually do anything useful; it looks silly,
but the alternative is to interfere with flag parsing more or to require
users to write separate codepaths to decide whether to enter the context
manager scope or not; the "use the context manager in a mode where it
does not do anything" prevents this.

Bug: 462507017
Change-Id: Icc5bb9cadda30b5a120f112b10bf96ffd3b6550f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7183647
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Adam Norberg <norberg@google.com>
2025-11-21 14:01:25 -08:00
Fumitoshi Ukai
a40c63a40b siso: fix GOOGLE_API_USE_CLIENT_CERTIFICATE
GOOGLE_API_USE_CLIENT_CERTIFICATE=false was not passed
to siso process.

Change-Id: I44e1d63c7fbf8184822d9d888495b4818b511eac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7171141
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Alex Ovsienko <ovsienko@google.com>
2025-11-18 23:49:18 -08:00
Allen Li
02f950a7cd git_auth: Add test for url rewrite override case
To prevent possible future regressios

Change-Id: I873be512b621f57f1dd9f54a68d093cd65228bf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7164718
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
2025-11-18 15:43:06 -08:00
Scott Lee
039035332b bug fix for diff hunk parsing
The diff hunk can omit the number of lines after the line position.
For example, the following hunks are all valid
- @@ -1,2 +1,3 @@
- @@ -1 +1,3 @@
- @@ -1,2 +1 @@
- @@ -1 +1 @@

However, the existing regex assumes that the number of lines is always
given. It wasn't a problem before crrev.com/c/6952890, because -U3 was
applied always. However, since it changed the context lines to -U0,
git diff started generating hunks without the number of lines, if
a given changed section contains only a single line.

This CL fixes the regex.

Bug: 453641840
Change-Id: I67f680bc1d8fa046e373b065e8ccbb6ce652eb3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7158599
Auto-Submit: Scott Lee <ddoman@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
2025-11-17 09:06:06 -08:00
Alex Ovsienko
926832f6db siso: extract command line args handling into _process_args.
Add tests for _process_args to make sure all flags operate as expected.

Bug: b/459690822
Change-Id: I98086cb0a274420f440b2ac3490473566a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7161336
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
2025-11-16 23:38:15 -08:00
Alex Ovsienko
ca5576a48f siso: cover apply_metrics_labels and apply_telemetry_flags functions with tests.
Bug: b/459690822

Change-Id: Iccb5b83e8572afa8d6a66252fc69cf766a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7141140
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
2025-11-16 21:57:17 -08:00
Alex Ovsienko
c527a62fe0 siso: create simple function to check if subcommand is present is siso using help.
That will help with starting collector from subcommand when clients may have older siso versions installed.

Bug: b/455433899

Change-Id: I5949b46017619a1717ef87781d8430b56a6a6964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7155815
Commit-Queue: Alex Ovsienko <ovsienko@google.com>
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
2025-11-16 19:03:44 -08:00
Jiewei Qian
240cd02c29 reauth: implement GitCreds credential pre-flight checks
This CL implements ensure_authenticated() for GitCredsAuthenticator, and
adds ReAuth support.

This check performs best-effort credential checks before performing
expensive operations such as presubmit hooks. This allows us to fail fast when an ReAuth token is missing for a contributor subject to
ReAuth requirements.

If you suspect this CL has caused a breakage on CL upload, please
revert.

Bug: 451651615
Change-Id: I42f3ffe3c830ed7bd2322f6cf2ad8adbba7e7251
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7036772
Reviewed-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
2025-11-04 11:38:19 -08:00
Jiewei Qian
5567ad1ea0 gerrit_util: add ReAuth support to ensure_authenticated
This CL makes it possible for ensure_authenticated to check whether
the current credential would satisfy ReAuth requirement.

Right now, only GitCredsAuthenticator performs additional ReAuth
check. For other Authenticator, either ReAuth is not relevant
(e.g. SSO), or not supported or implied (e.g. .gitcookies).

This CL does nothing on its own, because ensure_autheticated with
ReAuth is opt-in. Subsequent CL will update callsites to pass in
ReAuthContext to make the check effective.

Bug: 451651615
Change-Id: Idb1e70c52aaa844e672331fad8d462a2a7577d45
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7104363
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
2025-11-04 11:21:10 -08:00
Jiewei Qian
1faea18c64 git-cl-test: rename auth parameter to creds
This avoids a import name clash in future CLs.

Bug: 451651615
Change-Id: Ie35cbe58f36ec98b33c48a70e61a2678a9ce52db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7104382
Auto-Submit: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
2025-11-04 11:05:03 -08:00
Milad Fa
a4fa14bf0d remove ppc and s390 from the host_arch list
We only support ppc64 and s390x.

Change-Id: I1ec46bbfc0bdd266b84336e5af46b0503efd4751
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7100932
Auto-Submit: Milad Farazmand <mfarazma@ibm.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Brian Ryner <bryner@google.com>
2025-11-03 09:28:07 -08:00
Jiewei Qian
52dbf26660 git_common: bump minimum git version
For ReAuth to work, git must be >=2.46.0. Updating depot_tools check according to:

https://chromium.googlesource.com/chromium/src/+/main/docs/gerrit_reauth.md#latest-git

Change-Id: I95a5bcc336e287d150140d35878ae8521e8817a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7094398
Auto-Submit: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
2025-10-29 11:17:20 -07:00
Gavin Mak
f5117c0007 Make CheckLicense warn locally
Only emit errors on standard CQ runs. Keep as warning for local runs to
reduce friction, and for full-tree CI checks to avoid breakage from
legacy files.

Bug: 454681814
Change-Id: I621ecc75cf5df40e4fd33ff439bfdc4f4c62e4fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7092462
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
2025-10-29 09:58:56 -07:00
Allen Li
da1bb1b99d git_auth: Delete unused ConfigChanger
All usages have been removed a while ago.

Bug: 446999231
Change-Id: I40de9de7dc027c22652dd45ad75bbba3377bd923
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7082062
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
2025-10-28 14:00:42 -07:00
Jiewei Qian
e2bb3cd558 tests: refactor CookiesAuthenticator mock
This CL refactors _test_gerrit_ensure_authenticated_common by splitting
it into:

- The actual mock and common code path
- Test case specific setup (e.g. scm.GIT.SetConfig)

In addition, fixes a few issues with the existing code:

- _Authenticator.get() is now mocked correctly, so a CookiesAuthenticator
  is returned in relevant tests. Previously it returned the "production"
  ChainedAuthenticator, which could call other authenticators (such as
  GitCredsAuthenticator based on the runtime environment)
- Adds mock patch cleanup functions. Previously, cleanup functions
  aren't registered, so the mock leaks and got overwritten by other test
  cases.
- Rewrite 'Bearer' in Authorization header check to be more robust.
  Previously, the test case raise a KeyError exception when the
  Authorization header isn't set at all in request headers.

This is a preparation CL for implementing ensure_authenticated() method
in ChainedAuthenticator and GitCredsAuthenticator in future CLs.

Bug: 348024314
Change-Id: I28a7fabbc6cf2dc33dccc1339b89d20a22dc12ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7082265
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
2025-10-27 15:45:01 -07:00
Jiewei Qian
32bbdf42e7 gerrit_util: only require ReAuth for Code-Review label
Only Code-Review label is subject to review enforcement. Setting other
labels don't need to ReAuth.

Bug: 450326417
Change-Id: I0d46ecc64dec847d82219fb069d8172ffc43d736
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7033952
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Joey Scarr <jsca@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
2025-10-14 19:05:51 -07:00
Gavin Mak
8d28f8ce96 Fix git cl patch for sso:// URLs
URL normalization logic incorrectly compares sso:// and https:// URLs.
Unify the logic to treat both schemes identically.

Bug: 450461206, 429002243
Change-Id: I912b286d787a43b34304ed3be521d9d6927ba414
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7031038
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
2025-10-13 13:29:42 -07:00
Jiewei Qian
73e46667ed Reland "git-cl: make SetReview ReAuth capable"
This is a reland of commit 6da6aecbb4

There's no change from the original CL and this reland. The revert was
addressed by adding ReAuth support to machine / bot authenticators,
namely GceAuthenticator (https://crrev.com/c/6965527) and
LuciContextAuthenticator (https://crrev.com/c/6967915).

The above changes should stop gerrit_util.SetReview from raising ReAuthRequired errors.

Bug: 442666611

Original change's description:
> git-cl: make SetReview ReAuth capable
>
> This CL changes SetReview to be ReAuth capable.
>
> This is a potential breaking change if an downstream script relies on
> gerrit_util.SetReview but hasn't implemented ReAuth.
>
> If this caused breakage, please refer to https://chromium.googlesource.com/chromium/src.git/+/HEAD/docs/gerrit_reauth.md#Troubleshooting for troubleshooting instructions.
>
> If the above doesn't work, please report a bug, then add `LUCI_BYPASS_REAUTH=1` to the environment to disable ReAuth for now.
>
> Bug: 442666611
> Change-Id: I7724f15f166f9975fc88be5d8e1c93be4e1ec302
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6939308
> Reviewed-by: Allen Li <ayatane@chromium.org>
> Reviewed-by: Scott Lee <ddoman@chromium.org>
> Commit-Queue: Jiewei Qian <qjw@chromium.org>

Bug: 442666611
Change-Id: I53636e54c732ec399b053500d664097ebacca05e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6967916
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
2025-09-24 20:59:02 -07:00
Jiewei Qian
e028bec84c reauth: add LuciContextAuthenticator support
This CL implements attempt_authenticate_with_reauth in LuciContextAuthenticator according to the base _Authenticator's
interface definition.

This allows LuciContextAuthenticator to be used where an action that needs to meet ReAuth requirement (instead of raising an exception
saying "ReAuth
is required").

Luci context access tokens should already satisfy ReAuth requirement.

Bug: 442666611
Change-Id: I2e4d43a75b230932fc779c805f75b5828c9d0980
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6967915
Reviewed-by: Allen Li <ayatane@chromium.org>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
2025-09-24 16:45:20 -07:00
Jiewei Qian
dfd4523a42 reauth: add GceAuthenticator support
This CL implements attempt_authenticate_with_reauth in GceAuthenticator
according to the base _Authenticator's interface definition.

This allows GceAuthenticator to be used where an action that needs to
meet ReAuth requirement (instead of raising an exception saying "ReAuth
is required").

GceAuthenticator's credential already satisfies ReAuth requirement.
ReAuth is satisfied if the GCE bot is trusted (controlled by Gerrit
server side config).

Bug:442666611
Change-Id: I9a801e3fd6ab9fb446e7842a93bcd9ee1ff953c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6965527
Reviewed-by: Allen Li <ayatane@chromium.org>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
2025-09-24 16:31:36 -07:00
Allen Li
06da8b2a8f git_cl: Delete usages of AutoConfigure
Has been no-op for a while, remove it now

Bug: 446999231
Change-Id: I9f4e5b9cbd6a5cb8e84fba2f0ebb949b2a88d9ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6981220
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
2025-09-24 16:06:55 -07:00
Andrew Grieve
9d57bd01e8 git cl comments: Add --unresolved & improve --json-file
* Don't output to non-json format when --json-file is passed
* Format individual comments as JSON when --json-file is used
* Add "unresolved" field to comments
* --unresolved flag will show only unresolved comments
* Better error message when no issue is associated with the branch

I intend to use this to have gemini-cli fix comments:
https://chromium-review.googlesource.com/c/chromium/src/+/6944524

Change-Id: I3b4d594b065751a600661a89925c69ffbf22aed5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6944465
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
2025-09-17 11:28:23 -07:00
Jacek Dobrowolski
c932af8f97 Revert "git-cl: make SetReview ReAuth capable"
This reverts commit 6da6aecbb4.

Reason for revert: Breaks official chrome release.

Original change's description:
> git-cl: make SetReview ReAuth capable
>
> This CL changes SetReview to be ReAuth capable.
>
> This is a potential breaking change if an downstream script relies on
> gerrit_util.SetReview but hasn't implemented ReAuth.
>
> If this caused breakage, please refer to https://chromium.googlesource.com/chromium/src.git/+/HEAD/docs/gerrit_reauth.md#Troubleshooting for troubleshooting instructions.
>
> If the above doesn't work, please report a bug, then add `LUCI_BYPASS_REAUTH=1` to the environment to disable ReAuth for now.
>
> Bug: 442666611
> Change-Id: I7724f15f166f9975fc88be5d8e1c93be4e1ec302
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6939308
> Reviewed-by: Allen Li <ayatane@chromium.org>
> Reviewed-by: Scott Lee <ddoman@chromium.org>
> Commit-Queue: Jiewei Qian <qjw@chromium.org>

Bug: 442666611
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I7b7e769b5a8011d45e976e471d0f2e43f186e0c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6955930
Commit-Queue: Alex Kravchuk <alexanderkr@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Ben Mason <benmason@chromium.org>
2025-09-17 03:52:50 -07:00
Jiewei Qian
6da6aecbb4 git-cl: make SetReview ReAuth capable
This CL changes SetReview to be ReAuth capable.

This is a potential breaking change if an downstream script relies on
gerrit_util.SetReview but hasn't implemented ReAuth.

If this caused breakage, please refer to https://chromium.googlesource.com/chromium/src.git/+/HEAD/docs/gerrit_reauth.md#Troubleshooting for troubleshooting instructions.

If the above doesn't work, please report a bug, then add `LUCI_BYPASS_REAUTH=1` to the environment to disable ReAuth for now.

Bug: 442666611
Change-Id: I7724f15f166f9975fc88be5d8e1c93be4e1ec302
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6939308
Reviewed-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
2025-09-16 17:00:01 -07:00