changeset 8971:ff22ffbac5a3 stable

repo group: clarify comments
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 21 Dec 2022 23:15:38 +0100
parents 11cae16e5a5d
children 4b5ab0426388
files kallithea/model/db.py kallithea/model/repo_group.py
diffstat 2 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/model/db.py	Tue Dec 13 16:46:09 2022 +0100
+++ b/kallithea/model/db.py	Wed Dec 21 23:15:38 2022 +0100
@@ -913,7 +913,7 @@
     STATE_ERROR = 'repo_state_error'
 
     repo_id = Column(Integer(), primary_key=True)
-    repo_name = Column(Unicode(255), nullable=False, unique=True)
+    repo_name = Column(Unicode(255), nullable=False, unique=True)  # full path, must be updated (based on get_new_name) when name or path changes
     repo_state = Column(String(255), nullable=False)
 
     clone_uri = Column(String(255), nullable=True) # FIXME: not nullable?
@@ -1337,7 +1337,7 @@
     SEP = ' &raquo; '
 
     group_id = Column(Integer(), primary_key=True)
-    group_name = Column(Unicode(255), nullable=False, unique=True) # full path
+    group_name = Column(Unicode(255), nullable=False, unique=True)  # full path, must be updated (based on get_new_name) when name or path changes
     parent_group_id = Column('group_parent_id', Integer(), ForeignKey('groups.group_id'), nullable=True)
     group_description = Column(Unicode(10000), nullable=False)
     owner_id = Column('user_id', Integer(), ForeignKey('users.user_id'), nullable=False)
--- a/kallithea/model/repo_group.py	Tue Dec 13 16:46:09 2022 +0100
+++ b/kallithea/model/repo_group.py	Wed Dec 21 23:15:38 2022 +0100
@@ -278,9 +278,8 @@
     def update(self, repo_group, repo_group_args):
         try:
             repo_group = db.RepoGroup.guess_instance(repo_group)
-            old_path = repo_group.full_path
+            old_path = repo_group.full_path  # aka .group_name
 
-            # change properties
             if 'owner' in repo_group_args:
                 repo_group.owner = db.User.get_by_username(repo_group_args['owner'])
             if 'group_description' in repo_group_args:
@@ -297,26 +296,23 @@
             new_path = repo_group.full_path
             meta.Session().add(repo_group)
 
-            # iterate over all members of this groups and do fixes
-            # if obj is a repoGroup also fix the name of the group according
-            # to the parent
-            # if obj is a Repo fix it's name
-            # this can be potentially heavy operation
+            # Iterate over all members of this repo group and update the full
+            # path (repo_name and group_name) based on the (already updated)
+            # full path of the parent.
+            # This can potentially be a heavy operation.
             for obj in repo_group.recursive_groups_and_repos():
-                # set the value from it's parent
                 if isinstance(obj, db.RepoGroup):
                     new_name = obj.get_new_name(obj.name)
                     log.debug('Fixing group %s to new name %s'
                                 % (obj.group_name, new_name))
                     obj.group_name = new_name
                 elif isinstance(obj, db.Repository):
-                    # we need to get all repositories from this new group and
-                    # rename them accordingly to new group path
                     new_name = obj.get_new_name(obj.just_name)
                     log.debug('Fixing repo %s to new name %s'
                                 % (obj.repo_name, new_name))
                     obj.repo_name = new_name
 
+            # Rename in file system
             self._rename_group(old_path, new_path)
 
             return repo_group