From fe60b05fa4e33c07d136f2a51a85094a485dd06a Mon Sep 17 00:00:00 2001 From: jefer94 Date: Mon, 16 Dec 2024 20:56:47 -0500 Subject: [PATCH] avoid issues related to repos endswith .git --- .../commands/schedule_repository_deletions.py | 11 +++++++++++ .../commands/send_deletion_order_notifications.py | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/breathecode/assignments/management/commands/schedule_repository_deletions.py b/breathecode/assignments/management/commands/schedule_repository_deletions.py index 46cc829d6..c7d31ebf0 100644 --- a/breathecode/assignments/management/commands/schedule_repository_deletions.py +++ b/breathecode/assignments/management/commands/schedule_repository_deletions.py @@ -185,6 +185,10 @@ def delete_github_repositories(self): for deletion_order in qs: ids.append(deletion_order.id) + if deletion_order.repository_name.endswith(".git"): + deletion_order.repository_name = deletion_order.repository_name[:-4] + deletion_order.save() + try: if self.github_client.repo_exists( owner=deletion_order.repository_user, repo=deletion_order.repository_name @@ -289,6 +293,9 @@ def schedule_github_deletion(self, provider: str, user: str, repo_name: str): ).exists(): return + if repo_name.endswith(".git"): + repo_name = repo_name[:-4] + status = RepositoryDeletionOrder.Status.PENDING if ( Task.objects.filter(github_url__icontains=f"github.com/{user}/{repo_name}") @@ -356,6 +363,10 @@ def transfer_ownership(self): for deletion_order in qs: ids.append(deletion_order.id) + if deletion_order.repository_name.endswith(".git"): + deletion_order.repository_name = deletion_order.repository_name[:-4] + deletion_order.save() + try: if self.github_client.repo_exists( owner=deletion_order.repository_user, repo=deletion_order.repository_name diff --git a/breathecode/assignments/management/commands/send_deletion_order_notifications.py b/breathecode/assignments/management/commands/send_deletion_order_notifications.py index 02a4dc4cb..5fc4adba3 100644 --- a/breathecode/assignments/management/commands/send_deletion_order_notifications.py +++ b/breathecode/assignments/management/commands/send_deletion_order_notifications.py @@ -37,6 +37,10 @@ def github(self): if deletion_order.repository_user not in allowed_users: continue + if deletion_order.repository_name.endswith(".git"): + deletion_order.repository_name = deletion_order.repository_name[:-4] + deletion_order.save() + new_owner = self.get_username(deletion_order.repository_user, deletion_order.repository_name) if new_owner is None: continue