metrics_xml_format checks the given file path to ensure that
it's an XML under tools/metrics with the following steps.
1. convert the input file path as a real path.
2. check the real path starts with
GetPrimarySolutionPath() + "/tools/metrics"
This doesn't work as intended if GetPrimarySolutionPath() returns
a symblink.
This patch converts GetPrimarySolutionPath() as a realpath to ensure
it runs the check based on the realpath of the git checkout.
Bug: 396182402
Change-Id: I3207eba7ed52d09a01b38d65fcf7c314622d95cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6279842
Auto-Submit: Scott Lee <ddoman@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This reverts commit bfe1a9282d.
Reason for revert: reland with a fix.
- Find the diff between ps#1 and ps#2.
- Tested at https://paste.googleplex.com/4670451708854272
Original change's description:
> Revert "Support formatting metrics xml(s) in the subfolders."
>
> This reverts commit 597ba08be5.
>
> Reason for revert: it broke git_cl.py. Need further patch
>
> Original change's description:
> > Support formatting metrics xml(s) in the subfolders.
> >
> > https://crrev.com/c/6072565 assumed that the XMLs are located under
> > tools/metrics/{actions,ukm,structured,histograms} directly, such as
> > tools/metrics/histograms/enums.xml.
> >
> > However, its subfolders may have XML files, and it should format
> > the files. This CL fixes it.
> >
> > Bug: 384940858
> > Change-Id: I56484144e6f72f41eb5bc37a5ad462a0de1ec0e3
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111994
> > Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> > Auto-Submit: Scott Lee <ddoman@chromium.org>
> > Commit-Queue: Scott Lee <ddoman@chromium.org>
>
> Bug: 384940858
> Change-Id: I322573ad6d2d758cd3d2de872efdbba4fd9330c2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111996
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Scott Lee <ddoman@chromium.org>
Bug: 384940858
Change-Id: Ibe20d5e46c519d7fdbd1114565ec3856e5bf928e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111997
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
This reverts commit 597ba08be5.
Reason for revert: it broke git_cl.py. Need further patch
Original change's description:
> Support formatting metrics xml(s) in the subfolders.
>
> https://crrev.com/c/6072565 assumed that the XMLs are located under
> tools/metrics/{actions,ukm,structured,histograms} directly, such as
> tools/metrics/histograms/enums.xml.
>
> However, its subfolders may have XML files, and it should format
> the files. This CL fixes it.
>
> Bug: 384940858
> Change-Id: I56484144e6f72f41eb5bc37a5ad462a0de1ec0e3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111994
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
> Auto-Submit: Scott Lee <ddoman@chromium.org>
> Commit-Queue: Scott Lee <ddoman@chromium.org>
Bug: 384940858
Change-Id: I322573ad6d2d758cd3d2de872efdbba4fd9330c2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111996
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
https://crrev.com/c/6072565 assumed that the XMLs are located under
tools/metrics/{actions,ukm,structured,histograms} directly, such as
tools/metrics/histograms/enums.xml.
However, its subfolders may have XML files, and it should format
the files. This CL fixes it.
Bug: 384940858
Change-Id: I56484144e6f72f41eb5bc37a5ad462a0de1ec0e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6111994
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Scott Lee <ddoman@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
metrics_xml_format.py has a check to ensure that the given xml
is located in the current checkout using GetPrimarySolutionPath().
The problem is that GetPrimarySolutionPath() adds "src" if the path
doesn't end with "src".
https://source.chromium.org/chromium/chromium/tools/depot_tools/+/main:gclient_paths.py;l=78-79
The workspace in Cog doesn't have "src" in the path. Instead, it creates
a workspace at /..../$workspace_name/$repo_name, which doesn't match
GetPrimarySolutionPath() because the workspace root doesn't end with
'src'.
This must be a common problem in other modules, and Cog gets around
this issue by creating a symlink, 'src', to the workspace root.
This CL replaces os.path.abspath() with os.path.realpath() so that
the check is done properly.
Bug: b/369827156
Change-Id: Iaf56de0a9ccbd168004c4c80672c9dd18211bf5e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6094779
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
git cl format supports formatting certain xml files under tools/metrics.
This CL adds metrics_xml_formatter so that the formatter can be run
with git cl format.
Bug: b/369827156
Change-Id: I5922cd79304aa8e06917aacc9f2d9bd3ed548c2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6072565
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>