feat(git lfs path and path to hg large files in *.ini files): moved git lfs path and path of hg large files to *.ini files.

This commit is contained in:
Serhii Ilin 2024-09-25 10:59:01 +03:00
parent 0204973eb6
commit 5d1b03ab5b
9 changed files with 37 additions and 56 deletions

View file

@ -689,6 +689,12 @@ vcs.connection_timeout = 3600
; It uses cache_region `cache_repo`
vcs.methods.cache = true
; Filesystem location where Git lfs objects should be stored
vcs.git.lfs.storage_location = /var/opt/rhodecode_repo_store/.cache/git_lfs_store
; Filesystem location where Mercurial largefile objects should be stored
vcs.hg.largefiles.storage_location = /var/opt/rhodecode_repo_store/.cache/hg_largefiles_store
; ####################################################
; Subversion proxy support (mod_dav_svn)
; Maps RhodeCode repo groups into SVN paths for Apache

View file

@ -657,6 +657,12 @@ vcs.connection_timeout = 3600
; It uses cache_region `cache_repo`
vcs.methods.cache = true
; Filesystem location where Git lfs objects should be stored
vcs.git.lfs.storage_location = /var/opt/rhodecode_repo_store/.cache/git_lfs_store
; Filesystem location where Mercurial largefile objects should be stored
vcs.hg.largefiles.storage_location = /var/opt/rhodecode_repo_store/.cache/hg_largefiles_store
; ####################################################
; Subversion proxy support (mod_dav_svn)
; Maps RhodeCode repo groups into SVN paths for Apache

View file

@ -116,6 +116,9 @@ def sanitize_settings_and_apply_defaults(global_config, settings):
settings_maker.make_setting('vcs.start_server', 'false', parser='bool')
settings_maker.make_setting('vcs.backends', 'hg, git, svn', parser='list')
settings_maker.make_setting('vcs.connection_timeout', 3600, parser='int')
settings_maker.make_setting('vcs.git.lfs.storage_location', '/var/opt/rhodecode_repo_store/.cache/git_lfs_store')
settings_maker.make_setting('vcs.hg.largefiles.storage_location',
'/var/opt/rhodecode_repo_store/.cache/hg_largefiles_store')
settings_maker.make_setting('vcs.methods.cache', True, parser='bool')

View file

@ -42,6 +42,7 @@ from webhelpers2.text import collapse, strip_tags, convert_accented_entities, co
from mako import exceptions
from rhodecode import ConfigGet
from rhodecode.lib.hash_utils import sha256_safe, md5, sha1
from rhodecode.lib.type_utils import AttributeDict
from rhodecode.lib.str_utils import safe_bytes, safe_str
@ -364,9 +365,9 @@ ui_sections = [
'ui', 'web', ]
def config_data_from_db(clear_session=True, repo=None):
def prepare_config_data(clear_session=True, repo=None):
"""
Read the configuration data from the database and return configuration
Read the configuration data from the database, *.ini files and return configuration
tuples.
"""
from rhodecode.model.settings import VcsSettingsModel
@ -380,6 +381,10 @@ def config_data_from_db(clear_session=True, repo=None):
ui_data = []
for setting in ui_settings:
# Todo: remove this section once transition to *.ini files will be completed
if setting.section in ('largefiles', 'vcs_git_lfs'):
if setting.key != 'enabled':
continue
if setting.active:
ui_data.append((setting.section, setting.key, setting.value))
config.append((
@ -390,6 +395,9 @@ def config_data_from_db(clear_session=True, repo=None):
# handles that
config.append((
safe_str(setting.section), safe_str(setting.key), False))
config_getter = ConfigGet()
config.append(('vcs_git_lfs', 'store_location', config_getter.get_str('vcs.git.lfs.storage_location')))
config.append(('largefiles', 'usercache', config_getter.get_str('vcs.hg.largefiles.storage_location')))
log.debug(
'settings ui from db@repo[%s]: %s',
repo,
@ -418,7 +426,7 @@ def make_db_config(clear_session=True, repo=None):
Create a :class:`Config` instance based on the values in the database.
"""
config = Config()
config_data = config_data_from_db(clear_session=clear_session, repo=repo)
config_data = prepare_config_data(clear_session=clear_session, repo=repo)
for section, option, value in config_data:
config.set(section, option, value)
return config

View file

@ -469,12 +469,6 @@ def ApplicationUiSettingsForm(localizer):
class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
web_push_ssl = v.StringBoolean(if_missing=False)
largefiles_usercache = All(
v.ValidPath(localizer),
v.UnicodeString(strip=True, min=2, not_empty=True))
vcs_git_lfs_store_location = All(
v.ValidPath(localizer),
v.UnicodeString(strip=True, min=2, not_empty=True))
extensions_hggit = v.StringBoolean(if_missing=False)
new_svn_branch = v.ValidSvnPattern(localizer, section='vcs_svn_branch')
new_svn_tag = v.ValidSvnPattern(localizer, section='vcs_svn_tag')

View file

@ -486,7 +486,6 @@ class VcsSettingsModel(object):
)
GLOBAL_HG_SETTINGS = (
('extensions', 'largefiles'),
('largefiles', 'usercache'),
('phases', 'publish'),
('extensions', 'evolve'),
('extensions', 'topic'),
@ -496,7 +495,6 @@ class VcsSettingsModel(object):
GLOBAL_GIT_SETTINGS = (
('vcs_git_lfs', 'enabled'),
('vcs_git_lfs', 'store_location')
)
SVN_BRANCH_SECTION = 'vcs_svn_branch'
@ -666,17 +664,15 @@ class VcsSettingsModel(object):
self.repo_settings, *phases, value=safe_str(data[phases_key]))
def create_or_update_global_hg_settings(self, data):
opts_len = 4
largefiles, largefiles_store, phases, evolve \
opts_len = 3
largefiles, phases, evolve \
= self.GLOBAL_HG_SETTINGS[:opts_len]
largefiles_key, largefiles_store_key, phases_key, evolve_key \
largefiles_key, phases_key, evolve_key \
= self._get_settings_keys(self.GLOBAL_HG_SETTINGS[:opts_len], data)
self._create_or_update_ui(
self.global_settings, *largefiles, value='',
active=data[largefiles_key])
self._create_or_update_ui(
self.global_settings, *largefiles_store, value=data[largefiles_store_key])
self._create_or_update_ui(
self.global_settings, *phases, value=safe_str(data[phases_key]))
self._create_or_update_ui(
@ -697,17 +693,12 @@ class VcsSettingsModel(object):
active=data[lfs_enabled_key])
def create_or_update_global_git_settings(self, data):
lfs_enabled, lfs_store_location \
= self.GLOBAL_GIT_SETTINGS
lfs_enabled_key, lfs_store_location_key \
= self._get_settings_keys(self.GLOBAL_GIT_SETTINGS, data)
lfs_enabled = self.GLOBAL_GIT_SETTINGS[0]
lfs_enabled_key = self._get_settings_keys(self.GLOBAL_GIT_SETTINGS, data)[0]
self._create_or_update_ui(
self.global_settings, *lfs_enabled, value=data[lfs_enabled_key],
active=data[lfs_enabled_key])
self._create_or_update_ui(
self.global_settings, *lfs_store_location,
value=data[lfs_store_location_key])
def create_or_update_global_svn_settings(self, data):
# branch/tags patterns

View file

@ -75,17 +75,6 @@
% endif
</div>
% if display_globals:
<div class="field">
<div class="input">
${h.text('largefiles_usercache' + suffix, size=59)}
</div>
</div>
<div class="label">
<span class="help-block">${_('Filesystem location where Mercurial largefile objects should be stored.')}</span>
</div>
% endif
<div class="checkbox">
${h.checkbox('phases_publish' + suffix, 'True', **kwargs)}
<label for="phases_publish${suffix}">${_('Set repositories as publishing') if display_globals else _('Set repository as publishing')}</label>
@ -127,17 +116,6 @@
<span class="help-block">${_('Enable lfs extensions for this repository.')}</span>
% endif
</div>
% if display_globals:
<div class="field">
<div class="input">
${h.text('vcs_git_lfs_store_location' + suffix, size=59)}
</div>
</div>
<div class="label">
<span class="help-block">${_('Filesystem location where Git lfs objects should be stored.')}</span>
</div>
% endif
</div>
</div>
% endif

View file

@ -371,7 +371,7 @@ class TestMakeDbConfig(object):
('section2', 'option2', 'value2'),
('section3', 'option3', 'value3'),
]
with mock.patch.object(utils, 'config_data_from_db') as config_mock:
with mock.patch.object(utils, 'prepare_config_data') as config_mock:
config_mock.return_value = test_data
kwargs = {'clear_session': False, 'repo': 'test_repo'}
result = utils.make_db_config(**kwargs)
@ -381,8 +381,8 @@ class TestMakeDbConfig(object):
assert value == expected_value
class TestConfigDataFromDb(object):
def test_config_data_from_db_returns_active_settings(self):
class TestPrepareConfigData(object):
def test_prepare_config_data_returns_active_settings(self):
test_data = [
UiSetting('section1', 'option1', 'value1', True),
UiSetting('section2', 'option2', 'value2', True),
@ -398,7 +398,7 @@ class TestConfigDataFromDb(object):
instance_mock = mock.Mock()
model_mock.return_value = instance_mock
instance_mock.get_ui_settings.return_value = test_data
result = utils.config_data_from_db(
result = utils.prepare_config_data(
clear_session=False, repo=repo_name)
self._assert_repo_name_passed(model_mock, repo_name)
@ -407,7 +407,8 @@ class TestConfigDataFromDb(object):
('section1', 'option1', 'value1'),
('section2', 'option2', 'value2'),
]
assert result == expected_result
# We have extra config items returned, so we're ignoring two last items
assert result[:2] == expected_result
def _assert_repo_name_passed(self, model_mock, repo_name):
assert model_mock.call_count == 1

View file

@ -592,7 +592,6 @@ class TestUpdateGlobalSslSetting(object):
class TestCreateOrUpdateGlobalHgSettings(object):
FORM_DATA = {
'extensions_largefiles': False,
'largefiles_usercache': '/example/largefiles-store',
'phases_publish': False,
'extensions_evolve': False
}
@ -605,7 +604,6 @@ class TestCreateOrUpdateGlobalHgSettings(object):
expected_calls = [
mock.call(model.global_settings, 'extensions', 'largefiles', active=False, value=''),
mock.call(model.global_settings, 'largefiles', 'usercache', value='/example/largefiles-store'),
mock.call(model.global_settings, 'phases', 'publish', value='False'),
mock.call(model.global_settings, 'extensions', 'evolve', active=False, value=''),
mock.call(model.global_settings, 'experimental', 'evolution', active=False, value=''),
@ -632,7 +630,6 @@ class TestCreateOrUpdateGlobalHgSettings(object):
class TestCreateOrUpdateGlobalGitSettings(object):
FORM_DATA = {
'vcs_git_lfs_enabled': False,
'vcs_git_lfs_store_location': '/example/lfs-store',
}
def test_creates_repo_hg_settings_when_data_is_correct(self):
@ -643,7 +640,6 @@ class TestCreateOrUpdateGlobalGitSettings(object):
expected_calls = [
mock.call(model.global_settings, 'vcs_git_lfs', 'enabled', active=False, value=False),
mock.call(model.global_settings, 'vcs_git_lfs', 'store_location', value='/example/lfs-store'),
]
assert expected_calls == create_mock.call_args_list
@ -1001,9 +997,7 @@ class TestCreateOrUpdateRepoSettings(object):
'hooks_outgoing_pull_logger': False,
'extensions_largefiles': False,
'extensions_evolve': False,
'largefiles_usercache': '/example/largefiles-store',
'vcs_git_lfs_enabled': False,
'vcs_git_lfs_store_location': '/',
'phases_publish': 'False',
'rhodecode_pr_merge_enabled': False,
'rhodecode_use_outdated_comments': False,