# HG changeset patch # User RhodeCode Admin # Date 2022-08-11 07:39:06 # Node ID 515e2e657fedfb757800eeaf70a3b35a3aca89fc # Parent d818a8febe3581c5bd224d490e2fd5433601b1bd vcs-settings: when setting landing ref from UI switch default GIT branch too. fixes #5663 diff --git a/rhodecode/model/repo.py b/rhodecode/model/repo.py --- a/rhodecode/model/repo.py +++ b/rhodecode/model/repo.py @@ -467,6 +467,9 @@ class RepoModel(BaseModel): RepoModel().grant_user_permission( repo=cur_repo, user=User.DEFAULT_USER, perm=EMPTY_PERM ) + if kwargs.get('repo_landing_rev'): + landing_rev_val = kwargs['repo_landing_rev'] + RepoModel().set_landing_rev(cur_repo, landing_rev_val) # handle extra fields for field in filter(lambda k: k.startswith(RepositoryField.PREFIX), kwargs): @@ -933,6 +936,12 @@ class RepoModel(BaseModel): if field: self.sa.delete(field) + def set_landing_rev(self, repo, landing_rev_name): + if landing_rev_name.startswith('branch:'): + landing_rev_name = landing_rev_name.split('branch:')[-1] + scm_instance = repo.scm_instance() + return scm_instance._remote.set_head_ref(landing_rev_name) + def _create_filesystem_repo(self, repo_name, repo_type, repo_group, clone_uri=None, repo_store_location=None, use_global_config=False, install_hooks=True):