From 1af7968d686d4492359a695eb57636f9d355f488 Mon Sep 17 00:00:00 2001 From: Sigurdur Asgeirsson Date: Mon, 30 Nov 2020 21:41:21 +0000 Subject: [PATCH] Reduce git cl split oversplitting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change, git cl split will create a separate CL for every file that has per-file owners rules. This is almost always the wrong thing to do. With this change, it will at least aggregate all such files to their parent directory. This may under-split, but is perhaps nearer the mark. Change-Id: Iea7997b36d053713fa00f1261ea032e09d9c2818 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2555729 Auto-Submit: Sigurður Ásgeirsson Commit-Queue: Dirk Pranke Reviewed-by: Dirk Pranke --- split_cl.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/split_cl.py b/split_cl.py index 65dede163..5ed8a57b2 100644 --- a/split_cl.py +++ b/split_cl.py @@ -152,6 +152,10 @@ def GetFilesSplitByOwners(owners_database, files): files_split_by_owners = collections.defaultdict(list) for action, path in files: enclosing_dir = owners_database.enclosing_dir_with_owners(path) + # Anything matching a per-file rule will return its own path. + # Aggregate up to the parent directory so as not to over-split. + if enclosing_dir == path: + enclosing_dir = os.path.dirname(path) files_split_by_owners[enclosing_dir].append((action, path)) return files_split_by_owners