pyright doesn't like assigning random functions to function
attributes, as you might imagine.
The new implementation is much cleaner if I say so myself.
The memoize tests also pass FWIW.
Change-Id: Ie37b14f48004b81270c08b4d073c323b8b4ebd54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5762788
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
This will be useful for writing tests which rely on shared 'global'
config between different working directories.
This also adds support for mocking 'system' (global, immutable) and
'workspace' (local, mutable). The workspace scope I think is a bit iffy
though, given how `git cl` is actually built - currently scm.GIT doesn't
really know about clone vs. workspace, and afaik no config adjustements
actually apply to the workspace scope.
Adds tests for mocked git config implementation, including bug fixes
to the current implementation revealed by the tests.
R=ayatane, yiwzhang
Change-Id: Ia56d2a81d8df6ae75d9f8d0497be0d67bdc03651
Bug: 355505750
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5759163
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
In order to make reproduction steps appear on the bot_update step it
needs to have a tag that matches the instruction set on the invocation.
Bug: 349529661
Change-Id: Idcf75715ea4a64a5c6d9571f4f5485613864b7da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5754258
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Struan Shrimpton <sshrimp@google.com>
Previously there was an error where you could have:
global: {"key": ["something"]}
local: {}
And called SetConfig("key", None, missing_ok=False) - this would end
up raising CalledProcessError(returncode=5) because the caching
layer would see that "key" was not missing, then call into the
storage layer which would do `git config --local ...` which was
missing "key" (and therefore fail).
R=ayatane, yiwzhang
Change-Id: Idc9dc63a1b1c0a4a203c403dbb3c2ea521099b26
Bug: 342644760
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5744333
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Tested by running `vpython3 gerrit_client.py` so at least everything
loads with 3.11
Change-Id: I925fce1ce3fd4c427a57fb590c991bf49b99c1be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5741852
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
So that it allows depot tools has the ability to write the cipd pkgs
outside of the repo.
windows support will be added in a follow-up change.
Bug: 355430412
Change-Id: I7fabed7ecac8216ba3f3f639217d9e36746241f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5742434
Reviewed-by: Gregory Guterman <guterman@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Adds support to report line numbers when validation fails.
Change-Id: Iba94c5b3582d7e51f15d266d188909d3a82b75cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5740963
Reviewed-by: Jordan Brown <rop@google.com>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Anne Redulla <aredulla@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>
Otherwise pyright assumes a ton of values here are bytes
Bug: b/351071334
Change-Id: Ib360c27f6f82d35bcf885c5918b6def4ca26825f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5744594
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Some depot_tools commands now fail explicitly on cog. Skip their
non-supported tests too if on cog.
Bug: b/333744051
Change-Id: Ifa4116d1f8951d4cc28826570c4ea06773a71502
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5742101
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
NewContents always reads from cache, but it is sometimes useful flush
cache and use NewContents as a way to read the updatedcontents of a
file.
For example, some presubmit checks run formatters and check if any files
are modified. Many of these use `git diff` but that isn't available in
a non-git workspace, so checks will have to rely on reading contents
directly.
Bug: b/333744051
Change-Id: I3b3f4c88cc130607020ad599bbc15616d559725c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5740609
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
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>
In the event that `git-remote-sso` doesn't yield the expected
cookies, run `git ls-remote` on chromium/All-Projects.
This operation is fairly quick and robust - this fallback code
should only execute at most 1/day.
R=ayatane, yiwzhang
Change-Id: I5290f47e56341e9c4fd3b295ae117650f592dc7c
Bug: 342644760
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5741848
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
To use build id/invocation id consistently, reclient_helper will set AUTONINJA_BUILD_ID as RBE_invocation_id as is.
The host name information will be added as a metrics label.
Bug: 355127782
Change-Id: I5609ef38d897b19029795adf1b288898986c7c70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5737676
Auto-Submit: Junji Watanabe <jwata@google.com>
Reviewed-by: Michael Savigny <msavigny@google.com>
Commit-Queue: Michael Savigny <msavigny@google.com>
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>
Currently, {autoninja, autoninja.bat} scripts generate AUTONINJA_BUILD_ID by calling `python3 -c "import uuid; print(uuid.uuid4())"`.
This CL moves the logic at the beginning `autoninja.py`.
This also reduces the overhead of starting Python interpreter, which
takes around 60ms on my Windows workstaion.
```
> hyperfine python3
Benchmark 1: python3
Time (mean ± σ): 63.4 ms ± 7.8 ms [User: 25.7 ms, System: 33.7 ms]
Range (min … max): 51.0 ms … 80.2 ms 41 runs
```
Change-Id: I93d5b65f3c5542c3a93a3de1f27a5aa5d06c09a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5737673
Reviewed-by: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
Auto-Submit: Junji Watanabe <jwata@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>