This CL provides minimal `git cl format` support to enforce correct Rust
formatting in presubmit checks. For now the files are always fully
formatted - there is no support at this point for formatting only the
changed lines.
Manual tests (after temporarily, artificially introducing a formatting
error to one of .rs files under build/rest/tests):
*) git cl presubmit
Result: The src directory requires source formatting.
Please run: git cl format
*) git cl format --dry-run
Result: Pretty/colorful diff printed out.
*) git cl format
Result: Temporary formatting errors are fixed.
Bug: chromium:1231317
Change-Id: I114ece90630476f27871ebcd170162caa92c0871
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3054980
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Adrian Taylor <adetaylor@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: danakj <danakj@chromium.org>
cl/398464215 changed the weblink name from "gitiles" to "browse",
BUG=1254111
R=linxinan@chromium.org, sokcevic@google.com
Change-Id: I1aa5b47657b5c5619f7b56c53e3593d2f2e391f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3194121
Auto-Submit: Michael Moss <mmoss@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
It is occasionally useful to be able to run git cl format against some
specific upstream without having to configure branches in git. As
CMDformat can't easily take "git-diff-like" args, add an explict
--upstream argument.
This has come up a few times in the past and hopefuly the new arg will
be discoverable enough in --help for git cl format to help people.
Bug: 832295, 1082520
Change-Id: I2f3a33d719104ffd97cfa388178e38bfe8731c0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3124674
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Tomasz Śniatowski <tsniatowski@vewd.com>
depot_tools supports extracting information from branch name. E.g. if
branch contains fix-\d or bug-\d, commit description will contains
appropriate git footers.
However, such behavior should happen only on initial CL upload. Should
user decide to delete such footer, we shouldn't set bug / fix on any
following PS.
R=ehmaldonado@chromium.org
Bug: 1225663
Change-Id: I66adfdca070083ab66727d132919d47feb7ddd43
Fixed: 1225663
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3010709
Auto-Submit: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Andy Perelson <ajp@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
We found that in the bot environment sometimes we'd check the
full format setting before doing a lazy config update. Adds an
explicit call to ensure the lazy update. Fixes the problem of
the bot environment not running the same format checks in some
cases.
Bug: 1219863
Change-Id: I970d97da462972300f52cbcb382f7da3929b73e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3009534
Auto-Submit: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
In the previous commit https://crrev.com/c/2532835 the option
to order branches by date was added. This CL adds a git config
variable cl.date-order than can be set to achive the same effect.
Change-Id: Iaf24c46c5f7b63b1e518c18aedc455808a2dc752
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2992887
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
This CL adds a new field to the codereview.settings file used by
git_cl for project-wide defaults. If `USE_PYTHON3` is set to True,
then we will run the PRESUBMIT checks under Python3 by default
instead of Python2, unless the PRESUBMIT.py file contains
`USE_PYTHON3 = False` on a line by itself
(as opposed to now, where we'll use Python2 by default unless the
file contains `USE_PYTHON3 = True`).
This will allow us have Python3 be the default for new files
and to eventually eliminate any uses of `USE_PYTHON3` from the
individual presubmit files. Of course, you will have to go in and
explicitly add `USE_PYTHON3 = False` to any Py2-only files prior
to enabling this.
Bug: 1207012
Change-Id: Id8ec45b43940e5bcffeee196398c711c541e733e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2917747
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Quick run is only set when the -q flag is passed. It is not set to 0 by
other flags because only Chromium has Quick run and there are other
depot_tools users. We rely on the CQ to set the flag back to 0.
Bug: 1192827
Change-Id: I3310c9f005343f7d3eea56eaad5f19c7ba751921
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2927818
Commit-Queue: Gregory Guterman <guterman@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
If git push refs/for/ errors out, inspect stdout message to detect
uploadvalidator rejection. If present, present user a solution.
R=ajp@google.com
Change-Id: I70aee7615f3d905127a31bd5679968ade75c234a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2888475
Reviewed-by: Andy Perelson <ajp@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Users sometimes type in "y" to confirm the default patchset message,
resulting in a patchset being uploaded with "y" as the message.
We can make a fair assumption that no-one would willingly use a patchset
message of "y", so this CL uses the default patchset message whenever
this happens.
(I have personally done this myself and have seen at least one other
person do the same.)
Bug: None
Change-Id: Iad314d35aa830b62152ab2910eb37d876b7e450b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2861643
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Commit-Queue: Michael Cui <mlcui@google.com>
This CL adds support for running PRESUBMIT.py under either Python2
or Python3 as specified in each PRESUBMIT.py file.
To run the checks under Python3, the PRESUBMIT.py file must contain
a line exactly matching "^USE_PYTHON3 = True$". If the file
does not contain this string, the checks will run under Python2.
Different PRESUBMIT.py files in a single CL may thus contain
a mix of 2- and 3-compatible checks, but each individual file will
only be run in one or the other (it doesn't likely make sense to run
them in both by default).
Bug: 1157663
Change-Id: Ic74977941a6519388089328b6e1dfba2e885924b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2832654
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
I recently encountered an error where I forgot to add a changeid locally to
some-but-not-all commits in a stack of commits. When attempting to upload
these commits via `git cl upload --no-squash`, I received a confusing message
instructing me to install the Gerrit commit-msg hook even after the hook was
installed. In order to debug this problem locally, I added the ability to
prevent `git cl upload ...` from attempting to change the contents of
messages. If the --no-add-changeid flag is passed, then the command will
simply fail quasi-informatively.
BUG=None
TEST=attempted to upload this CL via `git cl upload --no-squash --no-add-changeid`, confirm that it fails.
Change-Id: Id5f721c18143448db801095946f490880bb61786
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2828775
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Gregory Nisbet <gregorynisbet@google.com>
When uploading a large-scale change, many users are automatically CC'ed
on a change. This adds a warning if this is the case and links to a more
appropriate approval for a large-scale change.
Bug: 1194514
Change-Id: Icd336ebdffbccbc9f30a89a33e244a788a768cfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2798963
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
code-owners plugins wants a git ref in Gerrit (e.g. refs/heads/master)
while Depot Tools wants a local git ref (e.g. refs/remotes/origin/main,
or a git hash).
Add an upstream parameters to be used by Depot Tools, separate from
a Gerrit ref expected by owners_client.
Change-Id: Ieed97a186e3140b3f82830efa189dbe3e4d8c806
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2730049
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Will be used in a follow-up CL to initialize code-owners client.
Recipe-Nontrivial-Roll: build
Change-Id: Iefe9176320b4d1ae7715e88a8db132e815be76ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2717979
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This change also adds a target_ref flag to presubmit_support.py.
Recipe-Nontrivial-Roll: build
Change-Id: I6de6bb87fc1482b88d9fbebe5e4ad1dbd8ce9748
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2702792
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
When using "git cl patch -b branch_name issue_number" to resolve merge
conflicts in an uploaded CL the cherry-pick stage will probably fail due
to the expected merge conflicts. If you resolve the conflict and then
upload the now-merged CL you will actually create a new CL. This happens
because the SetIssue step is skipped when the cherry-pick fails.
This change sets the issue whenever a new branch is created. This is
safe (the new branch is not being used for anything else) and will
improve the situation in many cases.
crrev.com/c/2636593 is an example of a CL that was accidentally uploaded
as new when it was just supposed to be a resolving of merge conflicts on
an existing CL.
This change was manually tested with crrev.com/c/2107132.
Change-Id: Icb5b8e38feb6f0fa4a007d3924c4d69d2ee4937c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2638979
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Some bots use git-cl to upload changes to Gerrit.
Add an option so those can set Bot-Commit+1 on upload
instead of TBR and CR+1.
Change-Id: I5e80ddadedf6c4fe277f8984c35a603da923de5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2679780
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
When using git cl upload --message-file, the text editor prompts the
user to edit the description. This change suppresses the editor when
a message file is passed in.
Change-Id: Ifa568e155e72eeb49f55ded0ddac1b5a940687af
Bug:916230
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2643781
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
This is a reland of 968b1fe7d7
Original change's description:
> [git-cl] Use owners client when processing --[tb]r-owners.
>
> Change-Id: Id094bce2aa731359cd8af16f10ce79ae7e02bd85
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2572809
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Change-Id: I9f93d755b10517c5296f7095f735ec2295be34e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2632840
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
This reverts commit 968b1fe7d7.
Reason for revert: Appears to be breaking git cl upload for the recipe autoroller with https://logs.chromium.org/logs/infra-internal/buildbucket/cr-buildbucket.appspot.com/8858802226988308224/+/steps/infra/0/steps/git_cl_upload/0/stdout.
Original change's description:
> [git-cl] Use owners client when processing --[tb]r-owners.
>
> Change-Id: Id094bce2aa731359cd8af16f10ce79ae7e02bd85
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2572809
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
TBR=ehmaldonado@chromium.org,apolito@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: Id561a059eaf1419cbda52b7c0c6a45b5c6f2bd1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2611219
Reviewed-by: Stephen Martinis <martiniss@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Stephen Martinis <martiniss@chromium.org>
git cl format can't accept branch name as argument as those are reserved
for files that need to be formatted. This CL clarifies what user needs
to do in case git cl is not able to determine upstream branch.
R=apolito@google.com, ehmaldonaldo@chromium.org
Bug: 832295
Change-Id: If6ff517d633b7e70a33dff48f3779f82df30f214
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2571838
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
git fetch --prune removes all references that no longer exist on remote
server. This allows git cl to upload changes to correct destination
branch.
R=ehmaldonado@chromium.org
Bug: 1149640
Change-Id: I66bf8d2209242b08991c2dae0d3a7fbc892cef87
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2606613
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
subprocess.DEVNULL was introduced in Python3 to serve same purpose
as subprocess2.VOID, so rename VOID to DEVNULL in subprocess2.
Change-Id: I6dade3306ffc3bc2441ac6083f362b099c2427e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2587758
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
- Remove GetChangeApprovalStatus and GetFilesApprovalStatus.
- Make host, project and branch part of GerritClient.
- Rename ListOwnersForFile to ListOwners.
Change-Id: I1f610a64f0217ce54e5ce4a210026535adc1c2e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2587268
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
logging.warn is deprecated and should be replaced with logging.warning.
Bug:1097402
Change-Id: I55ce007bec47608eeafcf3cd9ac2b90f60073115
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2575621
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Hidden ascii art in git_cl.py needs to be decoded to utf-8 to print correctly.
Bug:1106660
Change-Id: Ie41490c789534ea6cb589bbc96aa06cd251943f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2575620
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>