[Replicant] [vendor_replicant-scripts] [PATCH 1/2] replicant_prepare_patch.py: make generate_patches more modular

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Thu Aug 27 16:12:09 UTC 2020


This enables to add more arguments later on by constructing the git command
to be executed.

Doing that with the current design of that function would end up having
to handle a power of two of the possible conditions:

With one condition (subject_prefix), we have 2 commands to generate.

With two conditions, we would have 4 commands to generate:
- subject_prefix False, New condition False
- subject_prefix False, New condition True
- subject_prefix True, New condition False
- subject_prefix True, New condition True

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 patches/replicant_prepare_patch.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/patches/replicant_prepare_patch.py b/patches/replicant_prepare_patch.py
index 079b4a2..5fd02c3 100755
--- a/patches/replicant_prepare_patch.py
+++ b/patches/replicant_prepare_patch.py
@@ -139,13 +139,13 @@ def get_subject_prefix(config, revision):
 
 def generate_patches(config, git_revision, nr_patches, patches_revision):
     subject_prefix = get_subject_prefix(config, patches_revision)
-    if subject_prefix == None:
-        patches = git('format-patch',
-                      git_revision, '-{}'.format(nr_patches)).split(os.linesep)
-    else:
-        patches = git('format-patch', git_revision, '-{}'.format(nr_patches),
-                     '--subject-prefix={}'.format(
-                         subject_prefix)).split(os.linesep)
+
+    git_arguments = ['format-patch', git_revision, '-{}'.format(nr_patches)]
+
+    if subject_prefix != None:
+        git_arguments.append('--subject-prefix={}'.format(subject_prefix))
+
+    patches = git(*git_arguments).split(os.linesep)
 
     patches.remove('')
 
-- 
2.28.0



More information about the Replicant mailing list