Loading gitlab_cp/sync.py +57 −56 Original line number Diff line number Diff line Loading @@ -379,9 +379,7 @@ class Synchronizer: dest_project: Optional[Project] = None # 1: sync project dest_visibility = self.adjust_visibility( src_project.attributes.get("visibility", GlVisibility.public) ) dest_visibility = self.adjust_visibility(src_project.attributes.get("visibility", GlVisibility.public)) try: dest_project = self.dest_client.projects.get(dest_project_path) changed_attr = [] Loading Loading @@ -465,20 +463,25 @@ class Synchronizer: dest_avatar_url = dest_project.avatar_url dest_web_url = dest_project.web_url if ( src_avatar_url and dest_avatar_url and src_avatar_url != f"{src_web_url}/-/avatar" # and not self.look_same_resources(src_avatar_url, dest_avatar_url) and (dest_avatar_url == f"{dest_web_url}/-/avatar" or self.force_update_avatar) (src_avatar_url is None or src_avatar_url == f"{src_web_url}/-/avatar") or (dest_avatar_url is not None and dest_avatar_url != f"{dest_web_url}/-/avatar" and not self.force_update_avatar) ): if self.dry_run: # image up-to-date print( f" - avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif self.dry_run: print( f" - avatar image: {AnsiColors.HYELLOW}update needed{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif src_project.attributes.get("visibility", GlVisibility.public) != GlVisibility.public: # no way to download the avatar image of a non-public project print( f"- avatar image: {AnsiColors.HGRAY}update needed{AnsiColors.HRED} skipped due to src project not public ({src_avatar_url} / {dest_avatar_url})" ) else: try: avatar_path = self.work_dir / basename(src_avatar_url) # /!\ can only work if src project is public (no authentication required) urlretrieve(src_avatar_url, avatar_path) dest_project.avatar = open(avatar_path, "rb") dest_project.save() Loading @@ -492,10 +495,6 @@ class Synchronizer: ) self.handle_warn(ge) # don't rethrow - continue anyway else: print( f" - avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) # 2: sync Git repository self.sync_git_repo(src_project, dest_project) Loading @@ -514,9 +513,7 @@ class Synchronizer: # echo "$src_group" > "group-$src_group_id.json" dest_group = None is_root_group = src_group.full_path == self.src_sync_path dest_visibility = self.adjust_visibility( src_group.attributes.get("visibility", GlVisibility.public) ) dest_visibility = self.adjust_visibility(src_group.visibility) # 1: sync group properties try: Loading Loading @@ -629,13 +626,21 @@ class Synchronizer: src_avatar_url = src_group.avatar_url dest_avatar_url = dest_group.avatar_url if ( src_avatar_url and (dest_avatar_url is None or self.force_update_avatar) # and not self.look_same_resources(src_avatar_url, dest_avatar_url) src_avatar_url is None or (dest_avatar_url is not None and not self.force_update_avatar) ): if self.dry_run: # image up-to-date print( f"- avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif self.dry_run: print( f"- avatar image: {AnsiColors.HYELLOW}update needed{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif src_group.visibility != GlVisibility.public: # no way to download the avatar image of a non-public group print( f"- avatar image: {AnsiColors.HRED}update needed{AnsiColors.RESET} skipped due to src group not public ({src_avatar_url} / {dest_avatar_url})" ) else: try: avatar_path = self.work_dir / basename(src_avatar_url) Loading @@ -652,10 +657,6 @@ class Synchronizer: ) # don't rethrow - continue anyway self.handle_warn(ge) else: print( f"- avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) # 2: sync sub-projects subprojects = src_group.projects.list(all=True) Loading Loading
gitlab_cp/sync.py +57 −56 Original line number Diff line number Diff line Loading @@ -379,9 +379,7 @@ class Synchronizer: dest_project: Optional[Project] = None # 1: sync project dest_visibility = self.adjust_visibility( src_project.attributes.get("visibility", GlVisibility.public) ) dest_visibility = self.adjust_visibility(src_project.attributes.get("visibility", GlVisibility.public)) try: dest_project = self.dest_client.projects.get(dest_project_path) changed_attr = [] Loading Loading @@ -465,20 +463,25 @@ class Synchronizer: dest_avatar_url = dest_project.avatar_url dest_web_url = dest_project.web_url if ( src_avatar_url and dest_avatar_url and src_avatar_url != f"{src_web_url}/-/avatar" # and not self.look_same_resources(src_avatar_url, dest_avatar_url) and (dest_avatar_url == f"{dest_web_url}/-/avatar" or self.force_update_avatar) (src_avatar_url is None or src_avatar_url == f"{src_web_url}/-/avatar") or (dest_avatar_url is not None and dest_avatar_url != f"{dest_web_url}/-/avatar" and not self.force_update_avatar) ): if self.dry_run: # image up-to-date print( f" - avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif self.dry_run: print( f" - avatar image: {AnsiColors.HYELLOW}update needed{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif src_project.attributes.get("visibility", GlVisibility.public) != GlVisibility.public: # no way to download the avatar image of a non-public project print( f"- avatar image: {AnsiColors.HGRAY}update needed{AnsiColors.HRED} skipped due to src project not public ({src_avatar_url} / {dest_avatar_url})" ) else: try: avatar_path = self.work_dir / basename(src_avatar_url) # /!\ can only work if src project is public (no authentication required) urlretrieve(src_avatar_url, avatar_path) dest_project.avatar = open(avatar_path, "rb") dest_project.save() Loading @@ -492,10 +495,6 @@ class Synchronizer: ) self.handle_warn(ge) # don't rethrow - continue anyway else: print( f" - avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) # 2: sync Git repository self.sync_git_repo(src_project, dest_project) Loading @@ -514,9 +513,7 @@ class Synchronizer: # echo "$src_group" > "group-$src_group_id.json" dest_group = None is_root_group = src_group.full_path == self.src_sync_path dest_visibility = self.adjust_visibility( src_group.attributes.get("visibility", GlVisibility.public) ) dest_visibility = self.adjust_visibility(src_group.visibility) # 1: sync group properties try: Loading Loading @@ -629,13 +626,21 @@ class Synchronizer: src_avatar_url = src_group.avatar_url dest_avatar_url = dest_group.avatar_url if ( src_avatar_url and (dest_avatar_url is None or self.force_update_avatar) # and not self.look_same_resources(src_avatar_url, dest_avatar_url) src_avatar_url is None or (dest_avatar_url is not None and not self.force_update_avatar) ): if self.dry_run: # image up-to-date print( f"- avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif self.dry_run: print( f"- avatar image: {AnsiColors.HYELLOW}update needed{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) elif src_group.visibility != GlVisibility.public: # no way to download the avatar image of a non-public group print( f"- avatar image: {AnsiColors.HRED}update needed{AnsiColors.RESET} skipped due to src group not public ({src_avatar_url} / {dest_avatar_url})" ) else: try: avatar_path = self.work_dir / basename(src_avatar_url) Loading @@ -652,10 +657,6 @@ class Synchronizer: ) # don't rethrow - continue anyway self.handle_warn(ge) else: print( f"- avatar image: {AnsiColors.HGRAY}up-to-date{AnsiColors.RESET} ({src_avatar_url} / {dest_avatar_url})" ) # 2: sync sub-projects subprojects = src_group.projects.list(all=True) Loading