Show More
@@ -44,4 +44,4 b' def _assert_valid_config(config):' | |||||
44 | config = config.copy() |
|
44 | config = config.copy() | |
45 |
|
45 | |||
46 | # This is what git needs from config at this stage |
|
46 | # This is what git needs from config at this stage | |
47 |
config.pop( |
|
47 | config.pop('git_update_server_info') |
@@ -118,7 +118,9 b' class LFSOidStore:' | |||||
118 | def __init__(self, oid, repo, store_location=None): |
|
118 | def __init__(self, oid, repo, store_location=None): | |
119 | self.oid = oid |
|
119 | self.oid = oid | |
120 | self.repo = repo |
|
120 | self.repo = repo | |
121 |
|
|
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 | self.tmp_oid_path = os.path.join(self.store_path, oid + '.tmp') |
|
124 | self.tmp_oid_path = os.path.join(self.store_path, oid + '.tmp') | |
123 | self.oid_path = os.path.join(self.store_path, oid) |
|
125 | self.oid_path = os.path.join(self.store_path, oid) | |
124 | self.fd = None |
|
126 | self.fd = None |
@@ -22,6 +22,7 b' from webtest.app import TestApp as WebOb' | |||||
22 | from vcsserver.lib.rc_json import json |
|
22 | from vcsserver.lib.rc_json import json | |
23 | from vcsserver.str_utils import safe_bytes |
|
23 | from vcsserver.str_utils import safe_bytes | |
24 | from vcsserver.git_lfs.app import create_app |
|
24 | from vcsserver.git_lfs.app import create_app | |
|
25 | from vcsserver.git_lfs.lib import LFSOidStore | |||
25 |
|
26 | |||
26 |
|
27 | |||
27 | @pytest.fixture(scope='function') |
|
28 | @pytest.fixture(scope='function') | |
@@ -118,7 +119,7 b' class TestLFSApplication:' | |||||
118 |
|
119 | |||
119 | def test_app_batch_api_download(self, git_lfs_app, http_auth): |
|
120 | def test_app_batch_api_download(self, git_lfs_app, http_auth): | |
120 | oid = '456' |
|
121 | oid = '456' | |
121 |
oid_path = |
|
122 | oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path | |
122 | if not os.path.isdir(os.path.dirname(oid_path)): |
|
123 | if not os.path.isdir(os.path.dirname(oid_path)): | |
123 | os.makedirs(os.path.dirname(oid_path)) |
|
124 | os.makedirs(os.path.dirname(oid_path)) | |
124 | with open(oid_path, 'wb') as f: |
|
125 | with open(oid_path, 'wb') as f: | |
@@ -209,7 +210,7 b' class TestLFSApplication:' | |||||
209 |
|
210 | |||
210 | def test_app_verify_api_size_mismatch(self, git_lfs_app): |
|
211 | def test_app_verify_api_size_mismatch(self, git_lfs_app): | |
211 | oid = 'existing' |
|
212 | oid = 'existing' | |
212 |
oid_path = |
|
213 | oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path | |
213 | if not os.path.isdir(os.path.dirname(oid_path)): |
|
214 | if not os.path.isdir(os.path.dirname(oid_path)): | |
214 | os.makedirs(os.path.dirname(oid_path)) |
|
215 | os.makedirs(os.path.dirname(oid_path)) | |
215 | with open(oid_path, 'wb') as f: |
|
216 | with open(oid_path, 'wb') as f: | |
@@ -225,7 +226,7 b' class TestLFSApplication:' | |||||
225 |
|
226 | |||
226 | def test_app_verify_api(self, git_lfs_app): |
|
227 | def test_app_verify_api(self, git_lfs_app): | |
227 | oid = 'existing' |
|
228 | oid = 'existing' | |
228 |
oid_path = |
|
229 | oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path | |
229 | if not os.path.isdir(os.path.dirname(oid_path)): |
|
230 | if not os.path.isdir(os.path.dirname(oid_path)): | |
230 | os.makedirs(os.path.dirname(oid_path)) |
|
231 | os.makedirs(os.path.dirname(oid_path)) | |
231 | with open(oid_path, 'wb') as f: |
|
232 | with open(oid_path, 'wb') as f: | |
@@ -249,7 +250,7 b' class TestLFSApplication:' | |||||
249 |
|
250 | |||
250 | def test_app_download_api(self, git_lfs_app): |
|
251 | def test_app_download_api(self, git_lfs_app): | |
251 | oid = 'existing' |
|
252 | oid = 'existing' | |
252 |
oid_path = |
|
253 | oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path | |
253 | if not os.path.isdir(os.path.dirname(oid_path)): |
|
254 | if not os.path.isdir(os.path.dirname(oid_path)): | |
254 | os.makedirs(os.path.dirname(oid_path)) |
|
255 | os.makedirs(os.path.dirname(oid_path)) | |
255 | with open(oid_path, 'wb') as f: |
|
256 | with open(oid_path, 'wb') as f: | |
@@ -268,6 +269,6 b' class TestLFSApplication:' | |||||
268 | assert json.loads(response.text) == {'upload': 'ok'} |
|
269 | assert json.loads(response.text) == {'upload': 'ok'} | |
269 |
|
270 | |||
270 | # verify that we actually wrote that OID |
|
271 | # verify that we actually wrote that OID | |
271 |
oid_path = |
|
272 | oid_path = LFSOidStore(oid=oid, repo=None, store_location=git_lfs_app._store).oid_path | |
272 | assert os.path.isfile(oid_path) |
|
273 | assert os.path.isfile(oid_path) | |
273 | assert 'CONTENT' == open(oid_path).read() |
|
274 | assert 'CONTENT' == open(oid_path).read() |
@@ -178,9 +178,13 b' class GitRemote(RemoteBase):' | |||||
178 | params = [ |
|
178 | params = [ | |
179 | '-c', 'core.askpass=""', |
|
179 | '-c', 'core.askpass=""', | |
180 | ] |
|
180 | ] | |
181 | ssl_cert_dir = config.get('vcs_ssl_dir') |
|
181 | config_attrs = { | |
182 | if ssl_cert_dir: |
|
182 | 'vcs_ssl_dir': 'http.sslCAinfo={}', | |
183 | params.extend(['-c', f'http.sslCAinfo={ssl_cert_dir}']) |
|
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 | return params |
|
188 | return params | |
185 |
|
189 | |||
186 | @reraise_safe_exceptions |
|
190 | @reraise_safe_exceptions | |
@@ -757,7 +761,7 b' class GitRemote(RemoteBase):' | |||||
757 | return remote_refs |
|
761 | return remote_refs | |
758 |
|
762 | |||
759 | @reraise_safe_exceptions |
|
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 | self._factory.repo(wire) |
|
765 | self._factory.repo(wire) | |
762 | if refs and not isinstance(refs, (list, tuple)): |
|
766 | if refs and not isinstance(refs, (list, tuple)): | |
763 | refs = [refs] |
|
767 | refs = [refs] | |
@@ -807,6 +811,12 b' class GitRemote(RemoteBase):' | |||||
807 | fail_on_stderr=False, |
|
811 | fail_on_stderr=False, | |
808 | _copts=self._remote_conf(config), |
|
812 | _copts=self._remote_conf(config), | |
809 | extra_env={'GIT_TERMINAL_PROMPT': '0'}) |
|
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 | return remote_refs |
|
821 | return remote_refs | |
812 |
|
822 |
@@ -245,10 +245,10 b' class GitLFSHandler:' | |||||
245 |
|
245 | |||
246 | def create_git_lfs_wsgi_app(repo_path, repo_name, config): |
|
246 | def create_git_lfs_wsgi_app(repo_path, repo_name, config): | |
247 | git_path = settings.GIT_EXECUTABLE |
|
247 | git_path = settings.GIT_EXECUTABLE | |
248 |
update_server_info = config.pop( |
|
248 | update_server_info = config.pop('git_update_server_info') | |
249 |
git_lfs_enabled = config.pop( |
|
249 | git_lfs_enabled = config.pop('git_lfs_enabled') | |
250 |
git_lfs_store_path = config.pop( |
|
250 | git_lfs_store_path = config.pop('git_lfs_store_path') | |
251 |
git_lfs_http_scheme = config.pop( |
|
251 | git_lfs_http_scheme = config.pop('git_lfs_http_scheme', 'http') | |
252 | app = GitLFSHandler( |
|
252 | app = GitLFSHandler( | |
253 | repo_path, repo_name, git_path, update_server_info, config) |
|
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