Commit Graph

2483 Commits (c932af8f977a3280208d692b692c1ecce0d3c6af)

Author SHA1 Message Date
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>
2 months ago
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>
2 months ago
Scott Lee 927f7dad38 presubmit: use git diff -U0 for CheckPatchFormatted()
git cl format uses `git diff -U0` when it has to find the files
and ranges to format. Similarly, CiderG generates diffs with
-U0 and run presubmits for the checks.

However, the scm.py:GenerateDiff(), which CheckPatchFormatted() uses,
doesn't specify -U and it defaults to -U3.

This CL updates CheckPatchFormatted() to pass -U0 to
scm.py:GenerateDiff() so that Presubmit and git cl format are
always given diffs generated with -U0.

Bug: 386840832
Change-Id: I19479ab139b7dba8ba4e5e5fed89eca4d2e66412
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6952890
Auto-Submit: Scott Lee <ddoman@chromium.org>
Commit-Queue: Brian Ryner <bryner@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Brian Ryner <bryner@google.com>
2 months ago
Jiewei Qian 9d7425377e reauth: add reauth capabilities to HttpConn
This CL makes it possible to create HttpConn RPC calls with ReAuth
credential.

Callers can specify whether they want to fail when ReAuth token isn't
available, or fallback to access token.

Bug: 442666611
Change-Id: I748a01634eea8ebe321779c8ae4f52d7beed3407
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6938952
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
2 months ago
Jiewei Qian 024aacb38b auth.py: add ReAuth support
This CL adds ReAuth support to GerritAuthenticator. ReAuth token can be
obtained with a new get_authorization_header() call.

The task of obtaining such a token is delegated to different
authenticators to check if ReAuth is necessary, and if the existing
authentication token already satisfies ReAuth requirements.

Bug: 442666611
Change-Id: Ic661b868f1c61c653de0da43eb784ad5938342f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6914237
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
2 months ago
Scott Lee 077e02a769 presubmit: generate a diff with prefix a/ and b/
Historically, git_cl.py and presubmit_support.py generated diffs
inconsistently.

==== git_cl.py ====
1) git_cl.py:_RunClangFormatDiff() assumed the input diff was
generated with --no-prefix. Therefore, it hard-coded -p0 as a param
for clang_format_diff.py. If the diff was generated without --no-prefix,
it would have to pass -p1 instead.

2) git_cl.py _RunYapf() and _RunGoogleJavaFormat assumed that
the input diff was generated with prefixes. Therefore,
it parsed the diffs, assuming that the diff was generated with
a/ and b/ prefixes.

This discrepancy wasn't an issue because each of the Run functions
generated and consumed the diffs within themselves. It became an issue
when https://crrev.com/c/6931775 was developed. The CL consolidated
the diff generation into a common function, so that all _Run functions
need to agree with the presence of the prefixes.

The CL changed _RunClangFormatDiff() to use -p1 instead of -p0,
mainly because
- it's the p level for the default git-diff option
- it's the p level for the unix diff util
- CiderG Chromium also generates the diff with the prefixes to
emulate the default diff output.
- I highly believe that --no-prefix was chosen for no reasons.
It seems to be a random choice to work with -p0.
- Either Java/Python or Clang wrapper should be changed.

==== presubmit_support.py ====

presubmit_support.py can be given a diff_file via --diff_file.
Otherwise, it generates the diff based on --upstream_commit.

a) it doesn't enforce the presence of the prefixes in the input
diff_file. As stated above, the Chromium extension generates
a diff with prefixes.

b) in contrast, when it is not given --diff_file, it generates
the diff with --no-prefix, and I don't find any reasons for it.
I believe that it's from a copy-pasted random choice.

==== the problem ====

This discarepancy became a problem, when crrev.com/c/6937365
was landed. It enforces git_cl.py and presubmit_support.py to agree
for the format of the input diff. That is, the presence of
the prefixes must be agreed by all the following.
- presubmit_support.py with --diff_file /tmp/abc
- presubmit_suppory.py without --diff_file /tmp/abc
- git cl format
- git cl format --input_diff_file /tmp/abc

==== possible solutions ====
Obviously, there are 3 choices.

1) update the regex and parsers of git_cl.py to auto detect the best
-p{num}.
This was the least preferred option, as it can be fragile.

2) update Chromium extension and git_cl.py to use --no-prefix.
i.e.,
- update the Chromium CiderG to generate diffs without the prefix.
- update the regex used in _ComputeFormatDiffLineRanges() to assume
that the input is generated with --no-prefix.
- change _RunClangFormatDiff() to pass -p0 instead of -p1.

3) update presubmit_support.py to generate diff without --no-prefix.

==== What this CL does ====
It implements (3).
- That is the default option for git-diff.
- I don't find obvious reasons to use --no-prefix.
- CiderG has been generating diffs with prefixes for weeks.
- It implies that presubmit_support.py works fine with a prefixed diff.

Bug: 386840832
Change-Id: Iac8a4fc30f101e70e3ccc56f9f8ee48198dfa833
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6939737
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
2 months ago
Scott Lee 363e910475 git_cl: update the clang, java, and yapf formatters to be git-free
This makes the formatter runners to be git-free if --input_diff_file
is given. They still run `git diff`, if --diff is given. However,
for the purpose of making the presubmit check for format verification
git-free, it's ok as --diff is not used by the presubmit check.


Bug: 386840832
Change-Id: If5ab68fa4e2fec1aafa22e15ddeabb744993342b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6931775
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
2 months ago
Scott Lee 5ed7fd0ea5 git_cl: add --input_diff_file for git cl format
If the option is given, git cl format uses the input diff file to
determine the files and sections to format instead of git-diff.

The intended use case is to remove git dependencies in case
presubmit_support.py is executed with a diff file and it calls
presubmit_canned_checks.CheckPatchFormatted().

Bug: 386840832
Change-Id: Ia1eacd1bdb81731e07753df19ebf1d2470c9f1aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6912693
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
2 months ago
Allen Li e46459f0d3 git cl: Handle URL variations more robustly
Bug: 429002243
Change-Id: I0638da9f7ddf8f82078b13331d5890ad8b2421ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6917276
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
3 months ago
Fumitoshi Ukai 0f565fa858 siso: add .sisorc support
if build/config/siso/.sisorc exists, it will add global flags
or subcmd flags.

global flags is line starting with "-"
e.g.
--credential_helper=gcloud

subcmd flags are line starting with subcmd name.
e.g.
ninja --verbose_failures=false -k=0

Bug: b/269554009
Change-Id: I4691b9e17571721dd5b70f6ffb063e2d2f0ac4e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6910278
Reviewed-by: Scott Lee <ddoman@chromium.org>
Reviewed-by: Philipp Wollermann <philwo@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
3 months ago
Fumitoshi Ukai f80f5bc99e autoninja: support running from outside of workspace
gclient_paths.GetPrimarySolutionPath() finds primary
solution path from current directory, so it would fail
if it is invoked from outside of workspace.

Pass directory to gclient_paths.GetPrimarySolutionPath
so it could find workspace correctly if it is invoked
ninja outside of workspace.

Bug: 441240584
Change-Id: I873f7883873e143ec8a64ee0e636042ac2336a2a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6898614
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
3 months ago
Scott Lee f88b25b610 Reland "presubmit: emit errors instead of warnings for bad copyright headers"
This reverts commit eb60ab38de.

Reason for revert: re-landing with an additional patch

-------------
* Problem
Browser infra runs ci.*-presubmit builders, such as linux-presubmit,
with --all to ensure that the entire chromium/src passes
presubmit checks.

crrev.com/c/6842238 changed the finding type for License Check
from warning to error, but the CI presubmit builders failed because
there are many files without valid CopyRight.

Not only the existing files, all the new files that are added with
`Bypass-Check-License: <reason> footer could also cause the presubmit
builder to fail.

* This CL

In addition to the original patch from crrev.com/c/6842238,
this CL makes additional patches to turn the CopyRight errors into
warnings, if --file or --all is given.

The same approach is used in
https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:presubmit_canned_checks.py;l=982-987;drc=eb60ab38deeda6975c9b0fef883978f2a9f69120


Bug: 435696543,40237859
Original change's description:
> Revert "presubmit: emit errors instead of warnings for bad copyright headers"
>
> This reverts commit fa62515ecb.
>
> Reason for revert: it seems that the existing files without valid copyright headers are causing linux-presubmit builds to fail. b/438791294
>
> Bug: 435696543,40237859
> Original change's description:
> > presubmit: emit errors instead of warnings for bad copyright headers
> >
> > This is an effective revert of https://crrev.com/c/4895337 with
> > additional patches to support a footer.
> >
> > https://crrev.com/c/3887721 updated CheckLicense() to emit errors
> > for bad copyright headers. However, https://crrev.com/c/4895337
> > was changed the finding type from error to warning, claiming that
> > the check is N/A for moved third files, but it's not so easy
> > to programatiically distinguish moved third-party files.
> >
> > After discussions, it was decided to change the finding type back
> > to error to prevent accidental submissions for new files without
> > correct CopyRight headers.
> >
> > To mitigate moved, third-party files, this CL adds support for
> > "Bypass-Check-License: <reason>" footer.
> >
> > If the check should be ignored in a given CL, CL authors should
> > use the footer instead.
> >
> > Bug: 435696543,40237859
> > Change-Id: I177915c65932a3d76ea60ee6a0e396f726bc400d
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6842238
> > Reviewed-by: Gavin Mak <gavinmak@google.com>
> > Commit-Queue: Scott Lee <ddoman@chromium.org>
>
> Bug: 435696543,40237859
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Change-Id: Ibedf8d13e3742249947e29e625a14cceaf89879c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6852377
> Commit-Queue: Scott Lee <ddoman@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Gavin Mak <gavinmak@google.com>

Bug: 435696543,40237859
Change-Id: Iafdb29b928c016eb3949e29fd43a2ba5f53e0ba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6852108
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
3 months ago
Scott Lee eb60ab38de Revert "presubmit: emit errors instead of warnings for bad copyright headers"
This reverts commit fa62515ecb.

Reason for revert: it seems that the existing files without valid copyright headers are causing linux-presubmit builds to fail. b/438791294 

Bug: 435696543,40237859
Original change's description:
> presubmit: emit errors instead of warnings for bad copyright headers
>
> This is an effective revert of https://crrev.com/c/4895337 with
> additional patches to support a footer.
>
> https://crrev.com/c/3887721 updated CheckLicense() to emit errors
> for bad copyright headers. However, https://crrev.com/c/4895337
> was changed the finding type from error to warning, claiming that
> the check is N/A for moved third files, but it's not so easy
> to programatiically distinguish moved third-party files.
>
> After discussions, it was decided to change the finding type back
> to error to prevent accidental submissions for new files without
> correct CopyRight headers.
>
> To mitigate moved, third-party files, this CL adds support for
> "Bypass-Check-License: <reason>" footer.
>
> If the check should be ignored in a given CL, CL authors should
> use the footer instead.
>
> Bug: 435696543,40237859
> Change-Id: I177915c65932a3d76ea60ee6a0e396f726bc400d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6842238
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Commit-Queue: Scott Lee <ddoman@chromium.org>

Bug: 435696543,40237859
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Ibedf8d13e3742249947e29e625a14cceaf89879c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6852377
Commit-Queue: Scott Lee <ddoman@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
3 months ago
Scott Lee fa62515ecb presubmit: emit errors instead of warnings for bad copyright headers
This is an effective revert of https://crrev.com/c/4895337 with
additional patches to support a footer.

https://crrev.com/c/3887721 updated CheckLicense() to emit errors
for bad copyright headers. However, https://crrev.com/c/4895337
was changed the finding type from error to warning, claiming that
the check is N/A for moved third files, but it's not so easy
to programatiically distinguish moved third-party files.

After discussions, it was decided to change the finding type back
to error to prevent accidental submissions for new files without
correct CopyRight headers.

To mitigate moved, third-party files, this CL adds support for
"Bypass-Check-License: <reason>" footer.

If the check should be ignored in a given CL, CL authors should
use the footer instead.

Bug: 435696543,40237859
Change-Id: I177915c65932a3d76ea60ee6a0e396f726bc400d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6842238
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
3 months ago
Scott Lee 7ada09631a presubmit_support: allows description only run
This CL allows presubmit_support to run without any files in diff mode
if it's given --description "..."


Bug: 436813955
Change-Id: I43252c0fdbd1a87b6099d2c9cd19e4b0f9b7f64f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6838150
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
3 months ago
Jiewei Qian 59e46a5d18 Add luci-auth-fido2-plugin
This plugin handles FIDO2 security keys for doing auth and integrates
with luci-auth (specifically git-credential-luci).

(It's in Python because tl;dr the Python library is much better.)

Bug: 433851494
Change-Id: Ib956b614588aad8ad4fda7619bfbae17a670438f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6804585
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
3 months ago
Allen Li 342cd35666 [git_auth] Add useHttpPath config for Gerrit auth
This is needed to pass the repo path to the credential helper, so we
can distinguish repos that need ReAuth.

Change-Id: I5aa72d6ec0421dcbff610f48f34129b8962050f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6822598
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
3 months ago
Scott Lee 4fd484473c depot_tools: add create_temp_file.py
It takes text from stdin and dump the read text to a temp file.

Bug: 428193406
Change-Id: I268dc4905e157d619d1af7d0b96f711f224f39db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6789063
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
4 months ago
Andy Perelson 615f4a2f03 Remove support for RobotComments, which have been removed from Gerrit.
Bug: 428171766
Change-Id: I38ddbf4a934f80897301d2fd04d8b83a799b1bd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6690195
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Andy Perelson <ajp@google.com>
5 months ago
Ben Pastene 52de072b5f Add *.star files as source file from presubmit's PoV
By not considering *.star files as source files, various pan-project
checks (like the copyright header check) weren't running on them.

But *.star files are pretty much python files, so should be treated the
same.

Bug: 428926694
Change-Id: If3f7ff45d9fa825008e6a86b13d60d44ad8387c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6697693
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
5 months ago
Fumitoshi Ukai 6a1451c0c0 autoninja: disable siso native by --reapi_address=
siso v1.3.1 changed the way to enable reapi.
It allows empty project and empty reapi_instance.

Under reclient mode to disable siso native,
set reapi_address empty.

Bug: 427569563
Change-Id: Ib653186c5200605032de5c0fddab0b64412db85c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6668613
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Fumitoshi Ukai <ukai@google.com>
Auto-Submit: Fumitoshi Ukai <ukai@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
5 months ago
Gavin Mak 21c86aad65 Specify full dirmd path in CheckDirMetadataFormat
If dirmd_bin` is not provided, default to an absolute path to dirmd.
Otherwise, some builders can fail with a `No such file or directory:
'dirmd'.` like:
https://ci.chromium.org/ui/p/chromium/builders/ci/linux-presubmit/27711/infra

Bug: 416037494
Change-Id: Ibe3c0a80f2b605583321cce95241de62edcaec4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6533317
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
6 months ago
Jordan Brown 977c37458f Change readme updating to be on by default for roll_dep.py
Change-Id: Id6d5a365e55ad0a79e512af24e72f141f8b9a60a
Bug: b/390067679
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6521682
Reviewed-by: Rachael Newitt <renewitt@google.com>
Reviewed-by: Andy Perelson <ajp@google.com>
Commit-Queue: Jordan Brown <rop@google.com>
6 months ago
Aleksei Khoroshilov 998f7bfaf2 Improve ensure_gsutil reliability
The current gsutil download code silently fails when the connection
drops mid-download, as read() returns an empty buffer instead of raising
an exception. This may lead to errors such as "zipfile.BadZipFile: File
is not a zip file" on Chromium sync with freshly-bootstrapped
depot_tools when downloading gcs deps.

This change solves this by hardening the process:
- Use retry mechanism with exponential backoff for gsutil download
- Switch to urlretrieve, which looks at Content-Length
- Compare MD5 of the downloaded file with the value from API
- Move exponential_backoff_retry from git_cache.py to gclient_utils.py

Change-Id: I25242948399e01373eb2afd9352e5c78a889051d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6485485
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Auto-Submit: Aleksei Khoroshilov <akhoroshilov@brave.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
7 months ago
Scott Lee b128c9967e split: update SelectReviewersForFiles to work with repository root
The current implementation relies on the current working directory,
when it traverses the file tree to find the nearest OWNERS. It also
causes an infinite loop when it cannot find any OWNERS.

This CL changes the implementation so that it works
no matter what the cwd is.

Bug: 412904761
Change-Id: Ic4e25217aa64bd2eb6514ccdd486fe3b57a82312
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6484531
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
7 months ago
Yiwei Zhang d49e17e19f presubmit: add location data to presubmit result
This will help us to display preusbmit result as findings both in
Gerrit and in Cider workspaces.

Change-Id: I0f5a9c503c1b14dc8dcbf9794cc556ef215a46a2
Bug: 404837554
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6469939
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
7 months ago
Allen Li d28539d200 [git_auth] Move gitcookies to free backup name
Bug: 410576093
Change-Id: Ib2d9db97f4e4e1e8cfe1914ba7ffb881f9e16bbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6453918
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
7 months ago
Allen Li 3b66d05bd8 [git_auth] Inject Changelist dependency into ConfigWizard
Otherwise it creates a dependency cycle.  This is needed if we want to
recurse into submodules.  Maybe this should be refactored more, but
this should be an improvement for now.

Change-Id: I4641e9ce1952bba81f717acbeefd59dd687d87ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6448579
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
7 months ago
Gavin Mak 9c0db48c84 Make sure _UpdateMirrorIfNotContains fetches the specified revision
_UpdateMirrorIfNotContains populates the mirror if a given rev
isn't found in the mirror, but if this rev is invalid, it's never
fetched at all. Check that we've actually fetched it after
populating the mirror.

Bug: 407864212
Change-Id: Id66695636e749c4f7372aa522ab03ec4ec8feb52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6441962
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
7 months ago
Allen Li 848643d8b5 [git_cl_test] Fix test mocking for git_auth.AutoConfigure
Bug: 404613530
Change-Id: I307637ccd5ac5e59ca13588572dd0cb0bf691d03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6431247
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
8 months ago
Allen Li 79b74c9be8 [git_cl_test] Delete broken mocked tests
These tests get broken by If0a214fe074d7e7591b5d37417ca447525c983b6 so
delete them.

Now, you might raise your eyebrows at that, but hear me out.

These tests are so heavily mocked that I argue that they aren't
providing any value.  What's the point of tests?  To save time by
catching regressions early.

Being dumped a large list of expected mocked calls like:

  @10: (['os.path.isfile', 'TEMP_DIR/trace-packet'],)
  @11: (['FileRead', 'TEMP_DIR/trace-packet'],)
  @12: (['FileWrite', 'TEMP_DIR/trace-packet', 'git-hash: 012345\ngit-hash: abcdea\n'],)
  @13: (['make_archive', 'TRACES_DIR/20170316T200041.000000-traces', 'zip', 'TEMP_DIR'],)
  @14: (['FileWrite', 'TEMP_DIR/git-config', <ANY>],)

provides little value.  Like, what the heck is this even supposed to
be testing?

I argue that:

the cost of potentially having a regression in the future, fixing it,
and adding a new, sane test for that case

is LESS than:

the cost of someone looking at one of these tests failures and
trying to figure out what exactly broke, whether it is an actual
breakage or do they just need to wade into the mess of expected mocked
calls and figure out how to update the mocked calls to reflect a
perfectly fine change that they are trying to make

Bug: 404613530
Change-Id: Id8e2f5ebb9ad55ee32291c2f70b2d26fb479b195
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6428049
Reviewed-by: Gregory Nisbet <gregorynisbet@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
8 months ago
Allen Li a71f255604 [git_cl_test] Fix getAccountDetailsMock
Bug: 404613530
Change-Id: Iefc2f0456182e4e6eb816be2b3605685528d82f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6428048
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Allen Li <ayatane@chromium.org>
8 months ago
Jordan Brown 4373d97c21 roll_dep: Update README.chromium when rolling submodules
Attempt to update the README.chromium file with the new submodule
revision after rolling it in a DEPS update. This update is flag-guarded
and will only run when explicitly specified.

Currently, only README.chromium files with a single "Revision:" line are
supported. Multiple lines and files with the divider are not handled.
These are left as future TODOs.

Bug: 390067679
Change-Id: Ib776564ae94360cc72dd633fc7ed7b3f84b5b9d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6173767
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Jordan Brown <rop@google.com>
Reviewed-by: Jiewei Qian <qjw@chromium.org>
8 months ago
Allen Li 5dcf92389b Fix git_map_test.py
I think the latest Git version changed this behavior.

Change-Id: Id10c3ec41daf4e6700fc8168373cae9482502231
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6422996
Commit-Queue: Allen Li <ayatane@chromium.org>
Feels: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
8 months ago
Sky Malice c214cd9faf Add android resource files to DEFAULT_FILES_TO_CHECK.
The existing licence regex assumed each line would start with an unknown
and optional comment delimiter, followed by a required space. However
the standard way to write the licence in XML files uses a multi-line
comment, each individual line simply starts with the licence text, no
delimiter or space. The license check thus needed to be updated to make
the space optional as well.

Bug: 407060754
Change-Id: I4a83dd9408de890593952e441ba6b650f726907c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6409392
Commit-Queue: Sky Malice <skym@chromium.org>
Reviewed-by: Andy Perelson <ajp@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
8 months ago
Allen Li a0d13c9549 [git_auth] Use pathless URL for cred helper
The credential helper rules should not have a path, while the URL
rewrite rules should.

Reland of I79b52ab4af62367363617b2a9afa03a67f5ea0b9

Bug: b/401338175
Bug: b/403635929
Change-Id: Ib89d9e855ca5eba29cc67f8846bb7ca0cb3622ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6363080
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
8 months 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>
8 months ago
Josip Sokcevic 948edc4382 Revert "[git_auth] Use pathless URL for cred helper"
This reverts commit ce47e785fa.

Reason for revert: fatal: --local can only be used inside a git
repository.

Original change's description:
> [git_auth] Use pathless URL for cred helper
>
> The credential helper rules should not have a path, while the URL
> rewrite rules should.
>
> Bug: b/401338175
> Change-Id: I79b52ab4af62367363617b2a9afa03a67f5ea0b9
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6345631
> Commit-Queue: Allen Li <ayatane@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>

Bug: b/401338175
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: Ifa887eeb7a7049665570e865431b41ac18649b90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6357165
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
8 months ago
Allen Li ce47e785fa [git_auth] Use pathless URL for cred helper
The credential helper rules should not have a path, while the URL
rewrite rules should.

Bug: b/401338175
Change-Id: I79b52ab4af62367363617b2a9afa03a67f5ea0b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6345631
Commit-Queue: Allen Li <ayatane@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
8 months ago
Anton Bershanskyi ab918ca0bc Reland "Add AffectedFile.Extension() in presubmit_support"
This is a reland of commit d447f41294

This reland excludes the change to PRESUBMIT.py which originally
caused regression and because of which the original commit was
reverted.

Original change's description:
> Add AffectedFile.Extension() in presubmit_support
>
> Add convenience method AffectedFile.Extension() for extracting file
> extension in a standard way. Add a test for this new functionality.
> Add a similar test for AffectedFile.UnixLocalPath().
>
> Bug: None
> Change-Id: If591e751fb2e4fb5355ad0b6f93f310667849d68
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6273341
> Commit-Queue: Anton Bershanskyi <bershanskyi@gmail.com>
> Reviewed-by: Dirk Pranke <dpranke@google.com>
> Reviewed-by: Gavin Mak <gavinmak@google.com>

Bug: None
Change-Id: Ie5fc551b9c0818dfd9a1c571cc247cc157dbc8b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6335512
Commit-Queue: Anton Bershanskyi <bershanskyi@gmail.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
8 months ago
Josip Sokcevic f61e11c19f roll_dep_test: fix tests
This partially reverts commit 1221440015.

Change-Id: Ib2e9d41b3871004376a952e643e13a7e67eb750e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6340427
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Allen Li <ayatane@chromium.org>
8 months ago
Allen Li b0d4f7c473 [gerrit_util] Add CheckShouldUseSSO function
This exposes the reason for the SSO detection, to be used in the auth
config wizard.

There are some minor changes to fix pyright (type checking) errors on
these lines.

Bug: b/401338175
Change-Id: Ibf63a1a078a9ae82598796e329d075f19de58ea7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6334613
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Allen Li <ayatane@chromium.org>
8 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>
8 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>
8 months ago
Yiwei Zhang cbf61c7044 CheckNewDEPSHooksHasRequiredReviewers checks approval from required
reviewers

The check mandates approval from required reviewers during submission.
Without it, the CL author could land the CL without explicitly
approval from required reviewers.

Bug: 396736534
Change-Id: I4671f123419b8f94a969b6caccf13a2064511a0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6313625
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
9 months ago
Devon Loehr 5825f91d8c [git cl split] Add trie structure for clustering
This CL defines a trie-based datastructure for representing files based
on their path. It directly mirrors the structure of a file system,
keeping track of directories and the files inside them. It also stores
some information about OWNERS files, for use during clustering (we
won't cluster files together if there's a "break" in ownership due to
`set noparent). Optionally, the ownership information can be overridden;
this will be done via a command-line flag when the algorithm is fully
implemented.

Bug: 335797528
Change-Id: I5dcdf36695a1da5714ec021e5e18b6c36855a4f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6321290
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
9 months ago
Devon Loehr c48f866fcf Select a minimal number of owners for a set of files
This CL adds a function which takes a set of files, and attempts to
select a single owner for all of them. If it cannot, it falls back to
the standard owner selection algorithm, which may result in more owners
being chosen than necessary, but guarantees that a valid set of owners
is always returned.

Bug: 389069356
Change-Id: I985804040f149a02bfb5b3c6b946602a81334e7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6321289
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
9 months ago
Devon Loehr 20193073f8 [git cl split] Make Emit and EmitWarning variadic
This better matches the print function which they replace, and prevents
errors from passing the wrong number of arguments. We also change
printing in one function to be more user-friendly.

Bug: 389069356
Change-Id: Ia41d256b441bffa063f5d0b5ab4eb20725aaeaf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6322690
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Devon Loehr <dloehr@google.com>
9 months ago
Yiwei Zhang 191c73e7a2 CheckNewDEPSHooksHasRequiredReviewers computes reviewers from OWNERS
Instead of taking reviewers as input args, it computes the reviewers
from the top-level OWNERS file because otherwise, all callers will
basically do the same thing at the callsite.

Bug: 396736534
Change-Id: I3ea83b8285fab8b75cb77b40b10414c6a3dea6b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6313624
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
9 months ago
Yiwei Zhang 1221440015 roll_dep_test: remove file:// scheme in the git url
roll_dep_test is currently using file:///path/to/repo as git url.
Interestingly, the test is not failing in presubmit bot but
failing locally because it is trying to clone using sso protocol
(see: b/391455129#comment11). I think the presubmit bot is not
equipped with git-remote-sso so the tests are able to pass. However,
on a local workstation, git-remote-sso is available but it should
not be used as the file:// scheme should indicate using local
transport protocol. Quoted from
https://git-scm.com/docs/git-clone#_git_urls
> When Git doesn’t know how to handle a certain transport
protocol, it attempts to use the remote-<transport> remote helper,
if one exists.

Removing the file:// scheme appears to fix the issue even though
the only difference is the usage of --local flag according to the
doc.

fwiw, I did try to inject `--local` flag but it gives me a warning
`--local is ignored`. I haven't dig deep enough to figure out why
the flag is ignored.

Bug: 391455129
Change-Id: I8fab9aee5198b2eedfacdb60161197b58f7533ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6313297
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
9 months ago