From c87ffb2edf9f157080eb72325d524590f23a3395 Mon Sep 17 00:00:00 2001 From: vin01 Date: Sat, 5 Oct 2019 10:58:30 +0200 Subject: [PATCH 1/2] Use Byte stream for gitpython --- salt/utils/gitfs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index 98ae03097b13..0a6f757aa18b 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -1307,10 +1307,10 @@ def file_list(self, tgt_env): file_path = add_mountpoint(relpath(file_blob.path)) files.add(file_path) if stat.S_ISLNK(file_blob.mode): - stream = six.StringIO() + stream = six.BytesIO() file_blob.stream_data(stream) stream.seek(0) - link_tgt = stream.read() + link_tgt = salt.utils.stringutils.to_str(stream.read()) stream.close() symlinks[file_path] = link_tgt return files, symlinks @@ -1337,10 +1337,10 @@ def find_file(self, path, tgt_env): # this path's object ID will be the target of the # symlink. Follow the symlink and set path to the # location indicated in the blob data. - stream = six.StringIO() + stream = six.BytesIO() file_blob.stream_data(stream) stream.seek(0) - link_tgt = stream.read() + link_tgt = salt.utils.stringutils.to_str(stream.read()) stream.close() path = salt.utils.path.join( os.path.dirname(path), link_tgt, use_posixpath=True) From ddc969c957c34b4ac1e183f06a951eac8e447751 Mon Sep 17 00:00:00 2001 From: vin01 Date: Sat, 5 Oct 2019 11:09:45 +0200 Subject: [PATCH 2/2] Copy symlinks as symlinks in dest tree for tests --- tests/unit/fileserver/test_gitfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/fileserver/test_gitfs.py b/tests/unit/fileserver/test_gitfs.py index 09f08dc38e9e..10a62208edd9 100644 --- a/tests/unit/fileserver/test_gitfs.py +++ b/tests/unit/fileserver/test_gitfs.py @@ -401,7 +401,7 @@ def setUpClass(cls): log.error("Access error removeing file %s", TMP_REPO_DIR) elif exc.errno != errno.ENOENT: raise - shutil.copytree(INTEGRATION_BASE_FILES, TMP_REPO_DIR + '/') + shutil.copytree(INTEGRATION_BASE_FILES, TMP_REPO_DIR + '/', symlinks=True) repo = git.Repo.init(TMP_REPO_DIR)