[Replicant] [vendor_replicant-scripts] [PATCH] replicant_prepare_patch.py: fix crash when not using -C

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Sun Nov 8 00:43:25 UTC 2020


Without that fix we have:
    $ ./patches/replicant_prepare_patch.py HEAD 1
    Traceback (most recent call last):
      File "./patches/replicant_prepare_patch.py", line 231, in <module>
        repo = GitRepo(config, directory)
      File "./patches/replicant_prepare_patch.py", line 97, in __init__
        self.directory = re.sub('/+$', '', directory)
      File "/usr/lib/python3.8/re.py", line 210, in sub
        return _compile(pattern, flags).sub(repl, string, count)
    TypeError: expected string or bytes-like object

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

diff --git a/patches/replicant_prepare_patch.py b/patches/replicant_prepare_patch.py
index 57f8d6c..c1f52e7 100755
--- a/patches/replicant_prepare_patch.py
+++ b/patches/replicant_prepare_patch.py
@@ -94,8 +94,10 @@ def get_config():
 class GitRepo(object):
     def __init__(self, config, directory):
         self.config = config
-        self.directory = re.sub('/+$', '', directory)
-        if self.directory:
+        self.directory = None
+
+        if directory:
+            self.directory = re.sub('/+$', '', directory)
             self.git = sh.git.bake("-C", self.directory)
         else:
             self.git = sh.git.bake()
-- 
2.29.0



More information about the Replicant mailing list