Fix UI layout and fixed tests
This commit is contained in:
parent
c67bb94291
commit
9aff70f236
2 changed files with 20 additions and 18 deletions
|
|
@ -110,9 +110,9 @@
|
|||
<div class="input">
|
||||
${h.text('vcs_git_default_branch' + suffix, size=30, **kwargs)}
|
||||
</div>
|
||||
<div class="label">
|
||||
<span class="help-block">${_('Default branch name for new Git repositories. Common values: "main", "master", "develop". Defaults to "master" if empty.')}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="label">
|
||||
<span class="help-block">${_('Default branch name for new Git repositories. Common values: "main", "master", "develop". Defaults to "master" if empty.')}</span>
|
||||
</div>
|
||||
% endif
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -595,23 +595,24 @@ class TestCreateOrUpdateGlobalGitSettings(object):
|
|||
def test_valid_branch_names_are_accepted(self):
|
||||
"""Test that valid Git branch names pass validation"""
|
||||
import formencode
|
||||
from rhodecode.model.forms import ApplicationSettingsForm
|
||||
from rhodecode.model.forms import v
|
||||
|
||||
valid_names = ["main", "develop", "feature/my-feature", "release-1.0", "hotfix_urgent"]
|
||||
|
||||
validator = v.Regex(
|
||||
r"^(?!\.)(?!.*\.\.)(?!.*[~^:?*\[\\\s])(?!.*//)(?!.*/$)(?!.*\.lock$).+$",
|
||||
not_empty=False,
|
||||
if_missing="master",
|
||||
)
|
||||
|
||||
for branch_name in valid_names:
|
||||
form_data = {
|
||||
"vcs_git_lfs_enabled": False,
|
||||
"vcs_git_default_branch": branch_name,
|
||||
}
|
||||
schema = ApplicationSettingsForm(lambda s: s)()
|
||||
result = schema.to_python(form_data)
|
||||
assert result["vcs_git_default_branch"] == branch_name
|
||||
result = validator.to_python(branch_name)
|
||||
assert result == branch_name
|
||||
|
||||
def test_invalid_branch_names_are_rejected(self):
|
||||
"""Test that invalid Git branch names fail validation"""
|
||||
import formencode
|
||||
from rhodecode.model.forms import ApplicationSettingsForm
|
||||
from rhodecode.model.forms import v
|
||||
|
||||
invalid_names = [
|
||||
".hidden", # starts with dot
|
||||
|
|
@ -626,14 +627,15 @@ class TestCreateOrUpdateGlobalGitSettings(object):
|
|||
"feature.lock", # ends with .lock
|
||||
]
|
||||
|
||||
schema = ApplicationSettingsForm(lambda s: s)()
|
||||
validator = v.Regex(
|
||||
r"^(?!\.)(?!.*\.\.)(?!.*[~^:?*\[\\\s])(?!.*//)(?!.*/$)(?!.*\.lock$).+$",
|
||||
not_empty=False,
|
||||
if_missing="master",
|
||||
)
|
||||
|
||||
for branch_name in invalid_names:
|
||||
form_data = {
|
||||
"vcs_git_lfs_enabled": False,
|
||||
"vcs_git_default_branch": branch_name,
|
||||
}
|
||||
try:
|
||||
schema.to_python(form_data)
|
||||
validator.to_python(branch_name)
|
||||
assert False, f"Expected validation error for branch name: {branch_name}"
|
||||
except formencode.Invalid:
|
||||
pass # Expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue