##// END OF EJS Templates
fix(LFS): fixed LFSOidStorage, enbled LFS fetching on repo fetch, fixed tests and python3 transition related leftovers. Fixes: RCCE-8
ilin.s -
r1194:a8552e75 default
parent child Browse files
Show More
@@ -44,4 +44,4 b' def _assert_valid_config(config):'
44 44 config = config.copy()
45 45
46 46 # This is what git needs from config at this stage
47 config.pop(b'git_update_server_info')
47 config.pop('git_update_server_info')
@@ -118,7 +118,9 b' class LFSOidStore:'
118 118 def __init__(self, oid, repo, store_location=None):
119 119 self.oid = oid
120 120 self.repo = repo
121 self.store_path = store_location or self.get_default_store()
121 defined_store_path = store_location or self.get_default_store()
122 self.store_suffix = f"/objects/{oid[:2]}/{oid[2:4]}"
123 self.store_path = f"{defined_store_path.rstrip('/')}{self.store_suffix}"
122 124 self.tmp_oid_path = os.path.join(self.store_path, oid + '.tmp')
123 125 self.oid_path = os.path.join(self.store_path, oid)
124 126 self.fd = None
@@ -22,6 +22,7 b' from webtest.app import TestApp as WebOb'
22 22 from vcsserver.lib.rc_json import json
23 23 from vcsserver.str_utils import safe_bytes
24 24 from vcsserver.git_lfs.app import create_app
25 from vcsserver.git_lfs.lib import LFSOidStore
25 26
26 27
27 28 @pytest.fixture(scope='function')
@@ -118,7 +119,7 b' class TestLFSApplication:'
118 119
119 120 def test_app_batch_api_download(self, git_lfs_app, http_auth):
120 121 oid = '456'
121 oid_path = os.path.join(git_lfs_app._store, oid)
122 oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path
122 123 if not os.path.isdir(os.path.dirname(oid_path)):
123 124 os.makedirs(os.path.dirname(oid_path))
124 125 with open(oid_path, 'wb') as f:
@@ -209,7 +210,7 b' class TestLFSApplication:'
209 210
210 211 def test_app_verify_api_size_mismatch(self, git_lfs_app):
211 212 oid = 'existing'
212 oid_path = os.path.join(git_lfs_app._store, oid)
213 oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path
213 214 if not os.path.isdir(os.path.dirname(oid_path)):
214 215 os.makedirs(os.path.dirname(oid_path))
215 216 with open(oid_path, 'wb') as f:
@@ -225,7 +226,7 b' class TestLFSApplication:'
225 226
226 227 def test_app_verify_api(self, git_lfs_app):
227 228 oid = 'existing'
228 oid_path = os.path.join(git_lfs_app._store, oid)
229 oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path
229 230 if not os.path.isdir(os.path.dirname(oid_path)):
230 231 os.makedirs(os.path.dirname(oid_path))
231 232 with open(oid_path, 'wb') as f:
@@ -249,7 +250,7 b' class TestLFSApplication:'
249 250
250 251 def test_app_download_api(self, git_lfs_app):
251 252 oid = 'existing'
252 oid_path = os.path.join(git_lfs_app._store, oid)
253 oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path
253 254 if not os.path.isdir(os.path.dirname(oid_path)):
254 255 os.makedirs(os.path.dirname(oid_path))
255 256 with open(oid_path, 'wb') as f:
@@ -268,6 +269,6 b' class TestLFSApplication:'
268 269 assert json.loads(response.text) == {'upload': 'ok'}
269 270
270 271 # verify that we actually wrote that OID
271 oid_path = os.path.join(git_lfs_app._store, oid)
272 oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path
272 273 assert os.path.isfile(oid_path)
273 274 assert 'CONTENT' == open(oid_path).read()
@@ -178,9 +178,13 b' class GitRemote(RemoteBase):'
178 178 params = [
179 179 '-c', 'core.askpass=""',
180 180 ]
181 ssl_cert_dir = config.get('vcs_ssl_dir')
182 if ssl_cert_dir:
183 params.extend(['-c', f'http.sslCAinfo={ssl_cert_dir}'])
181 config_attrs = {
182 'vcs_ssl_dir': 'http.sslCAinfo={}',
183 'vcs_git_lfs_store_location': 'lfs.storage={}'
184 }
185 for key, param in config_attrs.items():
186 if value := config.get(key):
187 params.extend(['-c', param.format(value)])
184 188 return params
185 189
186 190 @reraise_safe_exceptions
@@ -757,7 +761,7 b' class GitRemote(RemoteBase):'
757 761 return remote_refs
758 762
759 763 @reraise_safe_exceptions
760 def sync_fetch(self, wire, url, refs=None, all_refs=False):
764 def sync_fetch(self, wire, url, refs=None, all_refs=False, **kwargs):
761 765 self._factory.repo(wire)
762 766 if refs and not isinstance(refs, (list, tuple)):
763 767 refs = [refs]
@@ -807,6 +811,12 b' class GitRemote(RemoteBase):'
807 811 fail_on_stderr=False,
808 812 _copts=self._remote_conf(config),
809 813 extra_env={'GIT_TERMINAL_PROMPT': '0'})
814 if kwargs.get('sync_large_objects'):
815 self.run_git_command(
816 wire, ['lfs', 'fetch', url, '--all'],
817 fail_on_stderr=False,
818 _copts=self._remote_conf(config),
819 )
810 820
811 821 return remote_refs
812 822
@@ -245,10 +245,10 b' class GitLFSHandler:'
245 245
246 246 def create_git_lfs_wsgi_app(repo_path, repo_name, config):
247 247 git_path = settings.GIT_EXECUTABLE
248 update_server_info = config.pop(b'git_update_server_info')
249 git_lfs_enabled = config.pop(b'git_lfs_enabled')
250 git_lfs_store_path = config.pop(b'git_lfs_store_path')
251 git_lfs_http_scheme = config.pop(b'git_lfs_http_scheme', 'http')
248 update_server_info = config.pop('git_update_server_info')
249 git_lfs_enabled = config.pop('git_lfs_enabled')
250 git_lfs_store_path = config.pop('git_lfs_store_path')
251 git_lfs_http_scheme = config.pop('git_lfs_http_scheme', 'http')
252 252 app = GitLFSHandler(
253 253 repo_path, repo_name, git_path, update_server_info, config)
254 254
General Comments 0
You need to be logged in to leave comments. Login now