Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle bytes when using gitpython with python3.x #54900

Merged
merged 11 commits into from
Jan 4, 2020
8 changes: 4 additions & 4 deletions salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1295,10 +1295,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
Expand All @@ -1325,10 +1325,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)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/fileserver/test_gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ def setUpClass(cls):

shutil.copytree(
salt.ext.six.text_type(RUNTIME_VARS.BASE_FILES),
salt.ext.six.text_type(cls.tmp_repo_dir + '/')
salt.ext.six.text_type(cls.tmp_repo_dir + '/'),
symlinks=True
)

repo = git.Repo.init(cls.tmp_repo_dir)
Expand Down