From d40cda515b4167bf06555cd8ccdc02c0396e5427 Mon Sep 17 00:00:00 2001 From: Alexei Svitkine Date: Tue, 29 Aug 2023 21:24:41 +0000 Subject: [PATCH] Improve `git cl format` for metrics XML files. - Remove a reference to rappor, which doesn't exist anymore - Don't error if an XML file is found with a different name The error would happen because we'd try to run pretty_print.py without a filename argument. Change-Id: Ifa77af07dcd9113540890863a9d1d3198bae59a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4762087 Reviewed-by: Andy Perelson Commit-Queue: Alexei Svitkine --- git_cl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/git_cl.py b/git_cl.py index 00bedb47a..d2acf19c5 100755 --- a/git_cl.py +++ b/git_cl.py @@ -6093,8 +6093,11 @@ def CMDformat(parser, args): # $ python pretty_print.py metadata/UMA/histograms.xml # $ python pretty_print.py enums.xml - if (diff_xml.endswith('histograms.xml') or diff_xml.endswith('enums.xml') - or diff_xml.endswith('histogram_suffixes_list.xml')): + if xml_dir == os.path.join('tools', 'metrics', 'histograms'): + if os.path.basename(diff_xml) not in ('histograms.xml', 'enums.xml', + 'histogram_suffixes_list.xml'): + # Skip this XML file if it's not one of the known types. + continue cmd.append(diff_xml) if opts.dry_run or opts.diff: @@ -6124,7 +6127,6 @@ def GetMetricsDir(diff_xml): metrics_xml_dirs = [ os.path.join('tools', 'metrics', 'actions'), os.path.join('tools', 'metrics', 'histograms'), - os.path.join('tools', 'metrics', 'rappor'), os.path.join('tools', 'metrics', 'structured'), os.path.join('tools', 'metrics', 'ukm'), ]