# HG changeset patch # User Serhii Ilin # Date 2024-01-09 15:16:26 # Node ID a578d58dff3e9018232ad8922fa0e2d02a6d5cb6 # Parent a8552e75dc607c1040f28c0d845b33192a188851 fix(LFS): added git lfs push --all option into sync_push. Fixes: RCCE-9 diff --git a/vcsserver/remote/git_remote.py b/vcsserver/remote/git_remote.py --- a/vcsserver/remote/git_remote.py +++ b/vcsserver/remote/git_remote.py @@ -461,10 +461,18 @@ class GitRemote(RemoteBase): url_obj = url_parser(safe_bytes(url)) authinfo = url_obj.authinfo()[1] + def _convert_to_strings(data): + if isinstance(data, bytes): + return safe_str(data) + elif isinstance(data, tuple): + return tuple(_convert_to_strings(item) for item in data) + else: + return data + if authinfo: # create a password manager passmgr = urllib.request.HTTPPasswordMgrWithDefaultRealm() - passmgr.add_password(*authinfo) + passmgr.add_password(*_convert_to_strings(authinfo)) handlers.extend((httpbasicauthhandler(passmgr), httpdigestauthhandler(passmgr))) @@ -483,7 +491,7 @@ class GitRemote(RemoteBase): if not test_uri.endswith('info/refs'): test_uri = test_uri.rstrip('/') + '/info/refs' - o = self._build_opener(test_uri) + o = self._build_opener(url=url) o.addheaders = [('User-Agent', 'git/1.7.8.0')] # fake some git q = {"service": 'git-upload-pack'} @@ -821,7 +829,7 @@ class GitRemote(RemoteBase): return remote_refs @reraise_safe_exceptions - def sync_push(self, wire, url, refs=None): + def sync_push(self, wire, url, refs=None, **kwargs): if not self.check_url(url, wire): return config = self._wire_to_config(wire) @@ -830,6 +838,12 @@ class GitRemote(RemoteBase): wire, ['push', url, '--mirror'], fail_on_stderr=False, _copts=self._remote_conf(config), extra_env={'GIT_TERMINAL_PROMPT': '0'}) + if kwargs.get('sync_large_objects'): + self.run_git_command( + wire, ['lfs', 'push', url, '--all'], + fail_on_stderr=False, + _copts=self._remote_conf(config), + ) @reraise_safe_exceptions def get_remote_refs(self, wire, url):