← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/launchpad:allow-delete-gitrepo-while-creating into launchpad:master

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:allow-delete-gitrepo-while-creating into launchpad:master.

Commit message:
Allowing users to delete git repositories while they are creating

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1920208 in Launchpad itself: "Git repositories can easily get stuck creating for too long"
  https://bugs.launchpad.net/launchpad/+bug/1920208

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/400490

We don't have any strong constraint on allowing users to delete on Launchpad a repository that is being created on Turnip side. If that happens, the repository confirmation on Turnip will fail, and the forked repository should be deleted from filesystem correctly.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:allow-delete-gitrepo-while-creating into launchpad:master.
diff --git a/lib/lp/code/browser/gitrepository.py b/lib/lp/code/browser/gitrepository.py
index 76606cd..c41cafe 100644
--- a/lib/lp/code/browser/gitrepository.py
+++ b/lib/lp/code/browser/gitrepository.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2020 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2021 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Git repository views."""
@@ -1376,8 +1376,6 @@ class GitRepositoryDeletionView(LaunchpadFormView):
 
         Uses display_deletion_requirements as its source data.
         """
-        if self.context.status == GitRepositoryStatus.CREATING:
-            return False
         return len([item for item, action, reason, allowed in
             self.display_deletion_requirements if not allowed]) == 0
 
@@ -1420,8 +1418,6 @@ class GitRepositoryDeletionView(LaunchpadFormView):
 
     @property
     def warning_message(self):
-        if self.context.status == GitRepositoryStatus.CREATING:
-            return "This repository is being created and cannot be deleted."
         return None
 
 
diff --git a/lib/lp/code/browser/tests/test_gitrepository.py b/lib/lp/code/browser/tests/test_gitrepository.py
index 5a17f6e..8dadb9d 100644
--- a/lib/lp/code/browser/tests/test_gitrepository.py
+++ b/lib/lp/code/browser/tests/test_gitrepository.py
@@ -1,4 +1,4 @@
-# Copyright 2015-2020 Canonical Ltd.  This software is licensed under the
+# Copyright 2015-2021 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for GitRepositoryView."""
@@ -2016,30 +2016,11 @@ class TestGitRepositoryDeletionView(BrowserTestCase):
         delete_link = browser.getLink("Delete repository")
         self.assertEqual(delete_url, delete_link.url)
 
-    def test_creating_warning_message_is_present(self):
-        # If the repository is not being created, we should show the
-        # warning message, and suppress the "delete" button.
-        repository = removeSecurityProxy(self.factory.makeGitRepository())
-        repository.status = GitRepositoryStatus.CREATING
-        browser = self.getViewBrowser(
-            repository, "+delete", rootsite="code", user=repository.owner)
-
-        # Warning message is present.
-        tag = find_tags_by_class(browser.contents, "warning message", True)
-        self.assertIsNotNone(tag)
-        self.assertIn(
-            "This repository is being created and cannot be deleted.",
-            ' '.join(tag.contents))
-        # Delete button is not present
-        tag = find_tag_by_id(
-            browser.contents, "field.actions.delete_repository")
-        self.assertIsNone(tag)
-
-    def test_creating_warning_message_is_not_shown(self):
-        # If the repository is not being created, we should not show the
+    def test_can_delete_creating_repository(self):
+        # Even if the repository is being created, we should not show the
         # warning message, and the "delete" button should be present.
         repository = removeSecurityProxy(self.factory.makeGitRepository())
-        repository.status = GitRepositoryStatus.AVAILABLE
+        repository.status = GitRepositoryStatus.CREATING
         browser = self.getViewBrowser(
             repository, "+delete", rootsite="code", user=repository.owner)
 

Follow ups