فهرست منبع

[git_footers] remove param before_keys from add_footer

The param before_key used to be used in presubmit_support.py, but
it was removed in 2018, and has never been used anywhere since.
- https://crrev.com/c/1351509
- http://shortn/_YQUh4yC9Tc

This CL removes it to simplify the code before the next CL.
It hasn't been used for several years and will unlikely be used
in the future.

Bug: 379923433
Change-Id: Ib0da340235a991b6d8edca041eae811540d4aa60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6064306
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Scott Lee 8 ماه پیش
والد
کامیت
8e30250504
2فایلهای تغییر یافته به همراه3 افزوده شده و 37 حذف شده
  1. 3 12
      git_footers.py
  2. 0 25
      tests/git_footers_test.py

+ 3 - 12
git_footers.py

@@ -115,15 +115,13 @@ def add_footer_change_id(message, change_id):
                       after_keys=['Bug', 'Issue', 'Test', 'Feature'])
 
 
-def add_footer(message, key, value, after_keys=None, before_keys=None):
+def add_footer(message, key, value, after_keys=None):
     """Returns a message with given footer appended.
 
-    If after_keys and before_keys are both None (default), appends footer last.
+    If after_keys is None (default), appends footer last.
     If after_keys is provided and matches footers already present, inserts
     footer as *early* as possible while still appearing after all provided
-    keys, even if doing so conflicts with before_keys.
-    If before_keys is provided, inserts footer as late as possible while still
-    appearing before all provided keys.
+    keys.
 
     For example, given
         message='Header.\n\nAdded: 2016\nBug: 123\nVerified-By: CQ'
@@ -147,16 +145,9 @@ def add_footer(message, key, value, after_keys=None, before_keys=None):
             footer_lines.index(x) for x in footer_lines for k in after_keys
             if matches_footer_key(x, k)
         ]
-        before_keys = set(map(normalize_name, before_keys or []))
-        before_indices = [
-            footer_lines.index(x) for x in footer_lines for k in before_keys
-            if matches_footer_key(x, k)
-        ]
         if after_indices:
             # after_keys takes precedence, even if there's a conflict.
             insert_idx = max(after_indices) + 1
-        elif before_indices:
-            insert_idx = min(before_indices)
         else:
             insert_idx = len(footer_lines)
         footer_lines.insert(insert_idx, new_footer)

+ 0 - 25
tests/git_footers_test.py

@@ -208,31 +208,6 @@ My commit message is my best friend. It is my life.
                                    after_keys=['Some']),
             'Top\n\nSome: footer\nKey: value\nOther: footer')
 
-        self.assertEqual(
-            git_footers.add_footer('Top\n\nSome: footer\nOther: footer',
-                                   'Key',
-                                   'value',
-                                   before_keys=['Other']),
-            'Top\n\nSome: footer\nKey: value\nOther: footer')
-
-        self.assertEqual(
-            git_footers.add_footer(
-                'Top\n\nSome: footer\nOther: footer\nFinal: footer',
-                'Key',
-                'value',
-                after_keys=['Some'],
-                before_keys=['Final']),
-            'Top\n\nSome: footer\nKey: value\nOther: footer\nFinal: footer')
-
-        self.assertEqual(
-            git_footers.add_footer(
-                'Top\n\nSome: footer\nOther: footer\nFinal: footer',
-                'Key',
-                'value',
-                after_keys=['Other'],
-                before_keys=['Some']),
-            'Top\n\nSome: footer\nOther: footer\nKey: value\nFinal: footer')
-
     def testRemoveFooter(self):
         self.assertEqual(git_footers.remove_footer('message', 'Key'), 'message')