Show More
@@ -261,8 +261,8 b' auth_ret_code_detection = false' | |||
|
261 | 261 | ; codes don't break the transactions while 4XX codes do |
|
262 | 262 | lock_ret_code = 423 |
|
263 | 263 | |
|
264 | ; allows to change the repository location in settings page | |
|
265 | allow_repo_location_change = true | |
|
264 | ; Filesystem location were repositories should be stored | |
|
265 | repo_store.path = /var/opt/rhodecode_repo_store | |
|
266 | 266 | |
|
267 | 267 | ; allows to setup custom hooks in settings page |
|
268 | 268 | allow_custom_hooks_settings = true |
@@ -212,8 +212,8 b' auth_ret_code_detection = false' | |||
|
212 | 212 | ; codes don't break the transactions while 4XX codes do |
|
213 | 213 | lock_ret_code = 423 |
|
214 | 214 | |
|
215 | ; allows to change the repository location in settings page | |
|
216 | allow_repo_location_change = true | |
|
215 | ; Filesystem location were repositories should be stored | |
|
216 | repo_store.path = /var/opt/rhodecode_repo_store | |
|
217 | 217 | |
|
218 | 218 | ; allows to setup custom hooks in settings page |
|
219 | 219 | allow_custom_hooks_settings = true |
@@ -25,7 +25,7 b' from rhodecode.api import (' | |||
|
25 | 25 | |
|
26 | 26 | from rhodecode.api.utils import ( |
|
27 | 27 | Optional, OAttr, has_superadmin_permission, get_user_or_error) |
|
28 | from rhodecode.lib.utils import repo2db_mapper | |
|
28 | from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_repo_store_path | |
|
29 | 29 | from rhodecode.lib import system_info |
|
30 | 30 | from rhodecode.lib import user_sessions |
|
31 | 31 | from rhodecode.lib import exc_tracking |
@@ -33,7 +33,6 b' from rhodecode.lib.ext_json import json' | |||
|
33 | 33 | from rhodecode.lib.utils2 import safe_int |
|
34 | 34 | from rhodecode.model.db import UserIpMap |
|
35 | 35 | from rhodecode.model.scm import ScmModel |
|
36 | from rhodecode.model.settings import VcsSettingsModel | |
|
37 | 36 | from rhodecode.apps.file_store import utils |
|
38 | 37 | from rhodecode.apps.file_store.exceptions import FileNotAllowedException, \ |
|
39 | 38 | FileOverSizeException |
@@ -103,7 +102,7 b' def get_repo_store(request, apiuser):' | |||
|
103 | 102 | if not has_superadmin_permission(apiuser): |
|
104 | 103 | raise JSONRPCForbidden() |
|
105 | 104 | |
|
106 | path = VcsSettingsModel().get_repos_location() | |
|
105 | path = get_rhodecode_repo_store_path() | |
|
107 | 106 | return {"path": path} |
|
108 | 107 | |
|
109 | 108 |
@@ -38,7 +38,7 b' from rhodecode.lib.auth import (' | |||
|
38 | 38 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) |
|
39 | 39 | from rhodecode.lib.celerylib import tasks, run_task |
|
40 | 40 | from rhodecode.lib.str_utils import safe_str |
|
41 | from rhodecode.lib.utils import repo2db_mapper | |
|
41 | from rhodecode.lib.utils import repo2db_mapper, get_rhodecode_repo_store_path | |
|
42 | 42 | from rhodecode.lib.utils2 import str2bool, AttributeDict |
|
43 | 43 | from rhodecode.lib.index import searcher_from_config |
|
44 | 44 | |
@@ -167,9 +167,6 b' class AdminSettingsView(BaseAppView):' | |||
|
167 | 167 | return Response(html) |
|
168 | 168 | |
|
169 | 169 | try: |
|
170 | if c.visual.allow_repo_location_change: | |
|
171 | model.update_global_path_setting(form_result['paths_root_path']) | |
|
172 | ||
|
173 | 170 | model.update_global_ssl_setting(form_result['web_push_ssl']) |
|
174 | 171 | model.update_global_hook_settings(form_result) |
|
175 | 172 | |
@@ -217,7 +214,7 b' class AdminSettingsView(BaseAppView):' | |||
|
217 | 214 | def settings_mapping(self): |
|
218 | 215 | c = self.load_default_context() |
|
219 | 216 | c.active = 'mapping' |
|
220 |
c.storage_path = |
|
|
217 | c.storage_path = get_rhodecode_repo_store_path() | |
|
221 | 218 | data = render('rhodecode:templates/admin/settings/settings.mako', |
|
222 | 219 | self._get_template_context(c), self.request) |
|
223 | 220 | html = formencode.htmlfill.render( |
@@ -22,7 +22,7 b' import os' | |||
|
22 | 22 | from pyramid.renderers import render |
|
23 | 23 | |
|
24 | 24 | from rhodecode.events import trigger |
|
25 |
from rhodecode.lib.utils import get_rhodecode_realm, get_rhodecode_ |
|
|
25 | from rhodecode.lib.utils import get_rhodecode_realm, get_rhodecode_repo_store_path | |
|
26 | 26 | from rhodecode.lib.utils2 import str2bool |
|
27 | 27 | from rhodecode.model.db import RepoGroup |
|
28 | 28 | |
@@ -38,7 +38,7 b' def write_mod_dav_svn_config(settings):' | |||
|
38 | 38 | file_path = settings[config_keys.config_file_path] |
|
39 | 39 | config = _render_mod_dav_svn_config( |
|
40 | 40 | use_ssl=use_ssl, |
|
41 |
parent_path_root=get_rhodecode_ |
|
|
41 | parent_path_root=get_rhodecode_repo_store_path(), | |
|
42 | 42 | list_parent_path=settings[config_keys.list_parent_path], |
|
43 | 43 | location_root=settings[config_keys.location_root], |
|
44 | 44 | repo_groups=RepoGroup.get_all_repo_groups(), |
@@ -118,6 +118,8 b' def sanitize_settings_and_apply_defaults' | |||
|
118 | 118 | |
|
119 | 119 | settings_maker.make_setting('vcs.methods.cache', True, parser='bool') |
|
120 | 120 | |
|
121 | # repo_store path | |
|
122 | settings_maker.make_setting('repo_store.path', '/var/opt/rhodecode_repo_store') | |
|
121 | 123 | # Support legacy values of vcs.scm_app_implementation. Legacy |
|
122 | 124 | # configurations may use 'rhodecode.lib.middleware.utils.scm_app_http', or |
|
123 | 125 | # disabled since 4.13 'vcsserver.scm_app' which is now mapped to 'http'. |
@@ -80,7 +80,6 b' def load_pyramid_environment(global_conf' | |||
|
80 | 80 | rhodecode.PYRAMID_SETTINGS = settings_merged |
|
81 | 81 | rhodecode.CONFIG = settings_merged |
|
82 | 82 | rhodecode.CONFIG['default_user_id'] = utils.get_default_user_id() |
|
83 | rhodecode.CONFIG['default_base_path'] = utils.get_default_base_path() | |
|
84 | 83 | |
|
85 | 84 | if vcs_server_enabled: |
|
86 | 85 | connect_vcs(vcs_server_uri, utils.get_vcs_server_protocol(settings)) |
@@ -102,15 +102,3 b' def get_default_user_id():' | |||
|
102 | 102 | user_id = result.first()[0] |
|
103 | 103 | |
|
104 | 104 | return user_id |
|
105 | ||
|
106 | ||
|
107 | def get_default_base_path(): | |
|
108 | from sqlalchemy import text | |
|
109 | from rhodecode.model import meta | |
|
110 | ||
|
111 | engine = meta.get_engine() | |
|
112 | with meta.SA_Session(engine) as session: | |
|
113 | result = session.execute(text("SELECT ui_value from rhodecode_ui where ui_key = '/'")) | |
|
114 | base_path = result.first()[0] | |
|
115 | ||
|
116 | return base_path |
@@ -347,8 +347,6 b' def attach_context_attributes(context, r' | |||
|
347 | 347 | context.ssh_key_generator_enabled = str2bool( |
|
348 | 348 | config.get('ssh.enable_ui_key_generator', 'true')) |
|
349 | 349 | |
|
350 | context.visual.allow_repo_location_change = str2bool( | |
|
351 | config.get('allow_repo_location_change', True)) | |
|
352 | 350 | context.visual.allow_custom_hooks_settings = str2bool( |
|
353 | 351 | config.get('allow_custom_hooks_settings', True)) |
|
354 | 352 | context.debug_style = str2bool(config.get('debug_style', False)) |
@@ -156,17 +156,10 b' class SimpleVCS(object):' | |||
|
156 | 156 | |
|
157 | 157 | @property |
|
158 | 158 | def base_path(self): |
|
159 |
settings_path = self. |
|
|
160 | ||
|
161 | if not settings_path: | |
|
162 | settings_path = self.global_vcs_config.get(*VcsSettingsModel.PATH_SETTING) | |
|
159 | settings_path = self.config.get('repo_store.path') | |
|
163 | 160 | |
|
164 | 161 | if not settings_path: |
|
165 | # try, maybe we passed in explicitly as config option | |
|
166 | settings_path = self.config.get('base_path') | |
|
167 | ||
|
168 | if not settings_path: | |
|
169 | raise ValueError('FATAL: base_path is empty') | |
|
162 | raise ValueError('FATAL: repo_store.path is empty') | |
|
170 | 163 | return settings_path |
|
171 | 164 | |
|
172 | 165 | def set_repo_names(self, environ): |
@@ -331,8 +331,8 b' def cpu():' | |||
|
331 | 331 | @register_sysinfo |
|
332 | 332 | def storage(): |
|
333 | 333 | from rhodecode.lib.helpers import format_byte_size_binary |
|
334 |
from rhodecode. |
|
|
335 | path = VcsSettingsModel().get_repos_location() | |
|
334 | from rhodecode.lib.utils import get_rhodecode_repo_store_path | |
|
335 | path = get_rhodecode_repo_store_path() | |
|
336 | 336 | |
|
337 | 337 | value = dict(percent=0, used=0, total=0, path=path, text='') |
|
338 | 338 | state = STATE_OK_DEFAULT |
@@ -364,8 +364,8 b' def storage():' | |||
|
364 | 364 | |
|
365 | 365 | @register_sysinfo |
|
366 | 366 | def storage_inodes(): |
|
367 |
from rhodecode. |
|
|
368 | path = VcsSettingsModel().get_repos_location() | |
|
367 | from rhodecode.lib.utils import get_rhodecode_repo_store_path | |
|
368 | path = get_rhodecode_repo_store_path() | |
|
369 | 369 | |
|
370 | 370 | value = dict(percent=0.0, free=0, used=0, total=0, path=path, text='') |
|
371 | 371 | state = STATE_OK_DEFAULT |
@@ -442,11 +442,10 b' def storage_archives():' | |||
|
442 | 442 | @register_sysinfo |
|
443 | 443 | def storage_gist(): |
|
444 | 444 | from rhodecode.model.gist import GIST_STORE_LOC |
|
445 | from rhodecode.model.settings import VcsSettingsModel | |
|
446 | from rhodecode.lib.utils import safe_str | |
|
445 | from rhodecode.lib.utils import safe_str, get_rhodecode_repo_store_path | |
|
447 | 446 | from rhodecode.lib.helpers import format_byte_size_binary |
|
448 | 447 | path = safe_str(os.path.join( |
|
449 |
|
|
|
448 | get_rhodecode_repo_store_path(), GIST_STORE_LOC)) | |
|
450 | 449 | |
|
451 | 450 | # gist storage |
|
452 | 451 | value = dict(percent=0, used=0, total=0, items=0, path=path, text='') |
@@ -472,14 +472,14 b' def get_rhodecode_realm():' | |||
|
472 | 472 | return safe_str(realm.app_settings_value) |
|
473 | 473 | |
|
474 | 474 | |
|
475 |
def get_rhodecode_ |
|
|
475 | def get_rhodecode_repo_store_path(): | |
|
476 | 476 | """ |
|
477 | 477 | Returns the base path. The base path is the filesystem path which points |
|
478 | 478 | to the repository store. |
|
479 | 479 | """ |
|
480 | 480 | |
|
481 | 481 | import rhodecode |
|
482 |
return rhodecode.CONFIG[' |
|
|
482 | return rhodecode.CONFIG['repo_store.path'] | |
|
483 | 483 | |
|
484 | 484 | |
|
485 | 485 | def map_groups(path): |
@@ -21,6 +21,7 b' import logging' | |||
|
21 | 21 | |
|
22 | 22 | import rhodecode |
|
23 | 23 | from rhodecode.model import meta, db |
|
24 | from rhodecode.lib.utils import get_rhodecode_repo_store_path | |
|
24 | 25 | from rhodecode.lib.utils2 import obfuscate_url_pw, get_encryption_key |
|
25 | 26 | |
|
26 | 27 | log = logging.getLogger(__name__) |
@@ -138,3 +139,11 b' class BaseModel(object):' | |||
|
138 | 139 | Returns all instances of what is defined in `cls` class variable |
|
139 | 140 | """ |
|
140 | 141 | return cls.cls.getAll() |
|
142 | ||
|
143 | @property | |
|
144 | def repos_path(self): | |
|
145 | """ | |
|
146 | Gets the repositories root path from *ini file | |
|
147 | """ | |
|
148 | ||
|
149 | return get_rhodecode_repo_store_path() |
@@ -1942,8 +1942,8 b' class Repository(Base, BaseModel):' | |||
|
1942 | 1942 | |
|
1943 | 1943 | :param cls: |
|
1944 | 1944 | """ |
|
1945 |
from rhodecode.lib.utils import get_rhodecode_ |
|
|
1946 |
return get_rhodecode_ |
|
|
1945 | from rhodecode.lib.utils import get_rhodecode_repo_store_path | |
|
1946 | return get_rhodecode_repo_store_path() | |
|
1947 | 1947 | |
|
1948 | 1948 | @classmethod |
|
1949 | 1949 | def get_all_repos(cls, user_id=Optional(None), group_id=Optional(None), |
@@ -2009,16 +2009,13 b' class Repository(Base, BaseModel):' | |||
|
2009 | 2009 | def groups_and_repo(self): |
|
2010 | 2010 | return self.groups_with_parents, self |
|
2011 | 2011 | |
|
2012 |
@ |
|
|
2012 | @property | |
|
2013 | 2013 | def repo_path(self): |
|
2014 | 2014 | """ |
|
2015 | 2015 | Returns base full path for that repository means where it actually |
|
2016 | 2016 | exists on a filesystem |
|
2017 | 2017 | """ |
|
2018 | q = Session().query(RhodeCodeUi).filter( | |
|
2019 | RhodeCodeUi.ui_key == self.NAME_SEP) | |
|
2020 | q = q.options(FromCache("sql_cache_short", "repository_repo_path")) | |
|
2021 | return q.one().ui_value | |
|
2018 | return self.base_path() | |
|
2022 | 2019 | |
|
2023 | 2020 | @property |
|
2024 | 2021 | def repo_full_path(self): |
@@ -430,10 +430,6 b' def ApplicationUiSettingsForm(localizer)' | |||
|
430 | 430 | |
|
431 | 431 | class _ApplicationUiSettingsForm(_BaseVcsSettingsForm): |
|
432 | 432 | web_push_ssl = v.StringBoolean(if_missing=False) |
|
433 | paths_root_path = All( | |
|
434 | v.ValidPath(localizer), | |
|
435 | v.UnicodeString(strip=True, min=1, not_empty=True) | |
|
436 | ) | |
|
437 | 433 | largefiles_usercache = All( |
|
438 | 434 | v.ValidPath(localizer), |
|
439 | 435 | v.UnicodeString(strip=True, min=2, not_empty=True)) |
@@ -83,14 +83,6 b' class RepoModel(BaseModel):' | |||
|
83 | 83 | |
|
84 | 84 | return repo_to_perm |
|
85 | 85 | |
|
86 | @LazyProperty | |
|
87 | def repos_path(self): | |
|
88 | """ | |
|
89 | Gets the repositories root path from database | |
|
90 | """ | |
|
91 | settings_model = VcsSettingsModel(sa=self.sa) | |
|
92 | return settings_model.get_repos_location() | |
|
93 | ||
|
94 | 86 | def get(self, repo_id): |
|
95 | 87 | repo = self.sa.query(Repository) \ |
|
96 | 88 | .filter(Repository.repo_id == repo_id) |
@@ -62,15 +62,6 b' class RepoGroupModel(BaseModel):' | |||
|
62 | 62 | def get_repo_group(self, repo_group): |
|
63 | 63 | return self._get_repo_group(repo_group) |
|
64 | 64 | |
|
65 | @LazyProperty | |
|
66 | def repos_path(self): | |
|
67 | """ | |
|
68 | Gets the repositories root path from database | |
|
69 | """ | |
|
70 | ||
|
71 | settings_model = VcsSettingsModel(sa=self.sa) | |
|
72 | return settings_model.get_repos_location() | |
|
73 | ||
|
74 | 65 | def get_by_group_name(self, repo_group_name, cache=None): |
|
75 | 66 | repo = self.sa.query(RepoGroup) \ |
|
76 | 67 | .filter(RepoGroup.group_name == repo_group_name) |
@@ -189,15 +189,6 b' class ScmModel(BaseModel):' | |||
|
189 | 189 | Generic Scm Model |
|
190 | 190 | """ |
|
191 | 191 | |
|
192 | @LazyProperty | |
|
193 | def repos_path(self): | |
|
194 | """ | |
|
195 | Gets the repositories root path from database | |
|
196 | """ | |
|
197 | ||
|
198 | settings_model = VcsSettingsModel(sa=self.sa) | |
|
199 | return settings_model.get_repos_location() | |
|
200 | ||
|
201 | 192 | def repo_scan(self, repos_path=None): |
|
202 | 193 | """ |
|
203 | 194 | Listing of repositories in given path. This path should not be a |
@@ -717,10 +717,6 b' class VcsSettingsModel(object):' | |||
|
717 | 717 | self._create_or_update_ui( |
|
718 | 718 | self.global_settings, *self.SSL_SETTING, value=value) |
|
719 | 719 | |
|
720 | def update_global_path_setting(self, value): | |
|
721 | self._create_or_update_ui( | |
|
722 | self.global_settings, *self.PATH_SETTING, value=value) | |
|
723 | ||
|
724 | 720 | @assert_repo_settings |
|
725 | 721 | def delete_repo_svn_pattern(self, id_): |
|
726 | 722 | ui = self.repo_settings.UiDbModel.get(id_) |
@@ -795,9 +791,6 b' class VcsSettingsModel(object):' | |||
|
795 | 791 | else: |
|
796 | 792 | return self.get_repo_general_settings() |
|
797 | 793 | |
|
798 | def get_repos_location(self): | |
|
799 | return self.global_settings.get_ui_by_key('/').ui_value | |
|
800 | ||
|
801 | 794 | def _filter_ui_settings(self, settings): |
|
802 | 795 | filtered_settings = [ |
|
803 | 796 | s for s in settings if self._should_keep_setting(s)] |
@@ -116,8 +116,9 b' def scan_repositories_if_enabled(event):' | |||
|
116 | 116 | import_on_startup = settings['startup.import_repos'] |
|
117 | 117 | if vcs_server_enabled and import_on_startup: |
|
118 | 118 | from rhodecode.model.scm import ScmModel |
|
119 |
from rhodecode.lib.utils import repo2db_mapper |
|
|
120 | repositories = ScmModel().repo_scan(get_rhodecode_base_path()) | |
|
119 | from rhodecode.lib.utils import repo2db_mapper | |
|
120 | scm = ScmModel() | |
|
121 | repositories = scm.repo_scan(scm.repos_path) | |
|
121 | 122 | repo2db_mapper(repositories, remove_obsolete=False) |
|
122 | 123 | |
|
123 | 124 |
@@ -6,8 +6,7 b'' | |||
|
6 | 6 | suffix='', |
|
7 | 7 | svn_tag_patterns=c.svn_tag_patterns, |
|
8 | 8 | svn_branch_patterns=c.svn_branch_patterns, |
|
9 |
display_globals=True |
|
|
10 | allow_repo_location_change=c.visual.allow_repo_location_change | |
|
9 | display_globals=True | |
|
11 | 10 | )} |
|
12 | 11 | <div class="buttons"> |
|
13 | 12 | ${h.submit('save',_('Save settings'),class_="btn")} |
@@ -3,7 +3,7 b'' | |||
|
3 | 3 | ## <%namespace name="vcss" file="/base/vcssettings.mako"/> |
|
4 | 4 | ## ${vcss.vcs_settings_fields()} |
|
5 | 5 | |
|
6 |
<%def name="vcs_settings_fields(suffix='', svn_branch_patterns=None, svn_tag_patterns=None, repo_type=None, display_globals=False, |
|
|
6 | <%def name="vcs_settings_fields(suffix='', svn_branch_patterns=None, svn_tag_patterns=None, repo_type=None, display_globals=False, **kwargs)"> | |
|
7 | 7 | % if display_globals: |
|
8 | 8 | <div class="panel panel-default"> |
|
9 | 9 | <div class="panel-heading" id="general"> |
@@ -23,34 +23,6 b'' | |||
|
23 | 23 | </div> |
|
24 | 24 | % endif |
|
25 | 25 | |
|
26 | % if display_globals: | |
|
27 | <div class="panel panel-default"> | |
|
28 | <div class="panel-heading" id="vcs-storage-options"> | |
|
29 | <h3 class="panel-title">${_('Main Storage Location')}<a class="permalink" href="#vcs-storage-options"> ¶</a></h3> | |
|
30 | </div> | |
|
31 | <div class="panel-body"> | |
|
32 | <div class="field"> | |
|
33 | <div class="inputx locked_input"> | |
|
34 | %if allow_repo_location_change: | |
|
35 | ${h.text('paths_root_path',size=59,readonly="readonly", class_="disabled")} | |
|
36 | <span id="path_unlock" class="tooltip" | |
|
37 | title="${h.tooltip(_('Click to unlock. You must restart RhodeCode in order to make this setting take effect.'))}"> | |
|
38 | <div class="btn btn-default lock_input_button"><i id="path_unlock_icon" class="icon-lock"></i></div> | |
|
39 | </span> | |
|
40 | %else: | |
|
41 | ${_('Repository location change is disabled. You can enable this by changing the `allow_repo_location_change` inside .ini file.')} | |
|
42 | ## form still requires this but we cannot internally change it anyway | |
|
43 | ${h.hidden('paths_root_path',size=30,readonly="readonly", class_="disabled")} | |
|
44 | %endif | |
|
45 | </div> | |
|
46 | </div> | |
|
47 | <div class="label"> | |
|
48 | <span class="help-block">${_('Filesystem location where repositories should be stored. After changing this value a restart and rescan of the repository folder are required.')}</span> | |
|
49 | </div> | |
|
50 | </div> | |
|
51 | </div> | |
|
52 | % endif | |
|
53 | ||
|
54 | 26 | % if display_globals or repo_type in ['git', 'hg']: |
|
55 | 27 | <div class="panel panel-default"> |
|
56 | 28 | <div class="panel-heading" id="vcs-hooks-options"> |
@@ -27,6 +27,7 b' import urllib.parse' | |||
|
27 | 27 | |
|
28 | 28 | import pytest |
|
29 | 29 | |
|
30 | import rhodecode | |
|
30 | 31 | from rhodecode.model.db import User |
|
31 | 32 | from rhodecode.lib import auth |
|
32 | 33 | from rhodecode.lib import helpers as h |
@@ -54,7 +55,6 b' log = logging.getLogger(__name__)' | |||
|
54 | 55 | # SOME GLOBALS FOR TESTS |
|
55 | 56 | TEST_DIR = tempfile.gettempdir() |
|
56 | 57 | |
|
57 | TESTS_TMP_PATH = jn(TEST_DIR, 'rc_test_{}'.format(next(tempfile._RandomNameSequence()))) | |
|
58 | 58 | TEST_USER_ADMIN_LOGIN = 'test_admin' |
|
59 | 59 | TEST_USER_ADMIN_PASS = 'test12' |
|
60 | 60 | TEST_USER_ADMIN_EMAIL = 'test_admin@mail.com' |
@@ -81,6 +81,8 b" GIT_FORK = 'vcs_test_git_fork'" | |||
|
81 | 81 | SCM_TESTS = ['hg', 'git'] |
|
82 | 82 | uniq_suffix = str(int(time.mktime(datetime.datetime.now().timetuple()))) |
|
83 | 83 | |
|
84 | TESTS_TMP_PATH = tempfile.mkdtemp(prefix='rc_test_', dir=TEST_DIR) | |
|
85 | ||
|
84 | 86 | TEST_GIT_REPO = jn(TESTS_TMP_PATH, GIT_REPO) |
|
85 | 87 | TEST_GIT_REPO_CLONE = jn(TESTS_TMP_PATH, f'vcsgitclone{uniq_suffix}') |
|
86 | 88 | TEST_GIT_REPO_PULL = jn(TESTS_TMP_PATH, f'vcsgitpull{uniq_suffix}') |
@@ -111,7 +113,7 b' def get_new_dir(title):' | |||
|
111 | 113 | hex_str = sha1_safe(f'{os.getpid()} {time.time()}') |
|
112 | 114 | name_parts.append(hex_str) |
|
113 | 115 | name = '-'.join(name_parts) |
|
114 |
path = |
|
|
116 | path = jn(TEST_DIR, name) | |
|
115 | 117 | return get_normalized_path(path) |
|
116 | 118 | |
|
117 | 119 |
@@ -21,6 +21,7 b' import pytest' | |||
|
21 | 21 | |
|
22 | 22 | from rhodecode.lib.config_utils import get_app_config |
|
23 | 23 | from rhodecode.tests.fixture import TestINI |
|
24 | from rhodecode.tests import TESTS_TMP_PATH | |
|
24 | 25 | from rhodecode.tests.server_utils import RcVCSServer |
|
25 | 26 | |
|
26 | 27 | |
@@ -111,6 +112,7 b' def ini_config(request, tmpdir_factory, ' | |||
|
111 | 112 | 'vcs.svn.proxy.enabled': 'true', |
|
112 | 113 | 'vcs.hooks.protocol': 'http', |
|
113 | 114 | 'vcs.hooks.host': '*', |
|
115 | 'repo_store.path': TESTS_TMP_PATH, | |
|
114 | 116 | 'app.service_api.token': 'service_secret_token', |
|
115 | 117 | }}, |
|
116 | 118 |
@@ -23,16 +23,16 b' import pytest' | |||
|
23 | 23 | from unittest.mock import patch, Mock, MagicMock |
|
24 | 24 | |
|
25 | 25 | from rhodecode.lib.middleware.simplesvn import SimpleSvn, SimpleSvnApp |
|
26 |
from rhodecode.lib.utils import get_rhodecode_ |
|
|
26 | from rhodecode.lib.utils import get_rhodecode_repo_store_path | |
|
27 | 27 | from rhodecode.tests import SVN_REPO, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS |
|
28 | 28 | |
|
29 | 29 | |
|
30 | 30 | class TestSimpleSvn(object): |
|
31 | 31 | @pytest.fixture(autouse=True) |
|
32 | 32 | def simple_svn(self, baseapp, request_stub): |
|
33 |
base_path = get_rhodecode_ |
|
|
33 | base_path = get_rhodecode_repo_store_path() | |
|
34 | 34 | self.app = SimpleSvn( |
|
35 |
config={'auth_ret_code': '', ' |
|
|
35 | config={'auth_ret_code': '', 'repo_store.path': base_path}, | |
|
36 | 36 | registry=request_stub.registry) |
|
37 | 37 | |
|
38 | 38 | def test_get_config(self): |
@@ -126,7 +126,7 b' class TestSimpleSvnApp(object):' | |||
|
126 | 126 | def setup_method(self, method): |
|
127 | 127 | # note(marcink): this is hostname from docker compose used for testing... |
|
128 | 128 | self.host = 'http://svn:8090' |
|
129 |
base_path = get_rhodecode_ |
|
|
129 | base_path = get_rhodecode_repo_store_path() | |
|
130 | 130 | self.app = SimpleSvnApp( |
|
131 | 131 | config={'subversion_http_server_url': self.host, |
|
132 | 132 | 'base_path': base_path}) |
@@ -589,17 +589,6 b' class TestUpdateGlobalSslSetting(object)' | |||
|
589 | 589 | model.global_settings, 'web', 'push_ssl', value='False') |
|
590 | 590 | |
|
591 | 591 | |
|
592 | class TestUpdateGlobalPathSetting(object): | |
|
593 | def test_updates_global_path_settings(self): | |
|
594 | model = VcsSettingsModel() | |
|
595 | with mock.patch.object(model, '_create_or_update_ui') as create_mock: | |
|
596 | model.update_global_path_setting('False') | |
|
597 | Session().commit() | |
|
598 | ||
|
599 | create_mock.assert_called_once_with( | |
|
600 | model.global_settings, 'paths', '/', value='False') | |
|
601 | ||
|
602 | ||
|
603 | 592 | class TestCreateOrUpdateGlobalHgSettings(object): |
|
604 | 593 | FORM_DATA = { |
|
605 | 594 | 'extensions_largefiles': False, |
@@ -1004,21 +993,6 b' class TestGetSvnPatterns(object):' | |||
|
1004 | 993 | settings_mock.assert_called_once_with(*args) |
|
1005 | 994 | |
|
1006 | 995 | |
|
1007 | class TestGetReposLocation(object): | |
|
1008 | def test_returns_repos_location(self, repo_stub): | |
|
1009 | model = VcsSettingsModel() | |
|
1010 | ||
|
1011 | result_mock = mock.Mock() | |
|
1012 | result_mock.ui_value = '/tmp' | |
|
1013 | ||
|
1014 | with mock.patch.object(model, 'global_settings') as settings_mock: | |
|
1015 | settings_mock.get_ui_by_key.return_value = result_mock | |
|
1016 | result = model.get_repos_location() | |
|
1017 | ||
|
1018 | settings_mock.get_ui_by_key.assert_called_once_with('/') | |
|
1019 | assert result == '/tmp' | |
|
1020 | ||
|
1021 | ||
|
1022 | 996 | class TestCreateOrUpdateRepoSettings(object): |
|
1023 | 997 | FORM_DATA = { |
|
1024 | 998 | 'inherit_global_settings': False, |
@@ -121,20 +121,20 b' class TestRepoModel(object):' | |||
|
121 | 121 | def test_create_filesystem_repo_installs_hooks(self, tmpdir, backend): |
|
122 | 122 | repo = backend.create_repo() |
|
123 | 123 | repo_name = repo.repo_name |
|
124 | model = RepoModel() | |
|
125 | repo_location = tempfile.mkdtemp() | |
|
126 | model.repos_path = repo_location | |
|
127 |
repo = |
|
|
128 | repo_name, backend.alias, repo_group='', clone_uri=None) | |
|
124 | with mock.patch('rhodecode.model.repo.RepoModel.repos_path', | |
|
125 | new_callable=mock.PropertyMock) as mocked_models_property: | |
|
126 | mocked_models_property.return_value = tempfile.mkdtemp() | |
|
127 | repo = RepoModel()._create_filesystem_repo( | |
|
128 | repo_name, backend.alias, repo_group='', clone_uri=None) | |
|
129 | 129 | |
|
130 | hooks = { | |
|
131 | 'svn': ('pre-commit', 'post-commit'), | |
|
132 | 'git': ('pre-receive', 'post-receive'), | |
|
133 | } | |
|
134 | for hook in hooks[backend.alias]: | |
|
135 | with open(os.path.join(repo.path, 'hooks', hook)) as f: | |
|
136 | data = f.read() | |
|
137 | assert 'RC_HOOK_VER' in data | |
|
130 | hooks = { | |
|
131 | 'svn': ('pre-commit', 'post-commit'), | |
|
132 | 'git': ('pre-receive', 'post-receive'), | |
|
133 | } | |
|
134 | for hook in hooks[backend.alias]: | |
|
135 | with open(os.path.join(repo.path, 'hooks', hook)) as f: | |
|
136 | data = f.read() | |
|
137 | assert 'RC_HOOK_VER' in data | |
|
138 | 138 | |
|
139 | 139 | @pytest.mark.parametrize("use_global_config, repo_name_passed", [ |
|
140 | 140 | (True, False), |
@@ -206,9 +206,6 b' auth_ret_code_detection = false' | |||
|
206 | 206 | ; codes don't break the transactions while 4XX codes do |
|
207 | 207 | lock_ret_code = 423 |
|
208 | 208 | |
|
209 | ; allows to change the repository location in settings page | |
|
210 | allow_repo_location_change = true | |
|
211 | ||
|
212 | 209 | ; allows to setup custom hooks in settings page |
|
213 | 210 | allow_custom_hooks_settings = true |
|
214 | 211 |
General Comments 0
You need to be logged in to leave comments.
Login now