repos: cleannup and fix landing-ref code.

with latest git update this exposed a bug when we allowed to set references like tip for git repos
now the defaults are loaded from a single place controlled by default branch for git.

Repos without master are now working just fine with new git and new logic.
This commit is contained in:
RhodeCode Admin 2023-01-18 22:10:40 +01:00
parent ca160683bf
commit d300144665
6 changed files with 36 additions and 20 deletions

View file

@ -22,6 +22,7 @@ import mock
import pytest
from rhodecode.model.repo import RepoModel
from rhodecode.model.scm import ScmModel
from rhodecode.tests import TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN
from rhodecode.api.tests.utils import (
build_data, api_call, assert_error, assert_ok, crash, jsonify)
@ -65,8 +66,8 @@ class TestApiUpdateRepo(object):
({'push_uri': 'http://example.com/repo_push'},
{'push_uri': 'http://example.com/repo_push'}),
({'landing_rev': 'rev:tip'},
{'landing_rev': ['rev', 'tip']}),
({'landing_rev': None}, # auto-updated based on type of repo
{'landing_rev': [None, None]}),
({'enable_statistics': True},
SAME_AS_UPDATES),
@ -97,6 +98,12 @@ class TestApiUpdateRepo(object):
if updates.get('_group'):
fixture.create_repo_group(updates['_group'])
if 'landing_rev' in updates:
default_landing_ref, _lbl = ScmModel.backend_landing_ref(backend.alias)
_type, _name = default_landing_ref.split(':')
updates['landing_rev'] = default_landing_ref
expected['landing_rev'] = [_type, _name]
expected_api_data = repo.get_api_data(include_secrets=True)
if expected is SAME_AS_UPDATES:
expected_api_data.update(updates)