From 27e82186d52f56e627344ebfe0833c3c915a3652 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 10 2016 10:54:51 +0000 Subject: [PATCH 1/3] Fix deleting a branch with a '/' in its name --- diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index 96a1137..b8584c5 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -224,7 +224,7 @@ git push -u origin master {% endif %} {% for branch in branches if branch != head%} -
+
{% if branchname != branch %} @@ -240,14 +240,14 @@ git push -u origin master
{% if repo_admin and branch != head %} -
{{ form.csrf_token }} + onclick="$('#delete_branch_form-{{ branch | replace('/', '_') }}').submit();">
From f8ff28a164f88bd1127ea3b5199d73968aaf5c77 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 10 2016 14:35:15 +0000 Subject: [PATCH 2/3] Add unit-tests ensuring deleting a branch containing a '/' works --- diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 0064ef8..98acaa6 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2266,6 +2266,32 @@ index 0000000..fb7093d '', output.data) + # Add a branch with a '/' in its name that we can delete + path = os.path.join(tests.HERE, 'test.git') + tests.add_content_git_repo(path) + repo = pygit2.Repository(path) + repo.create_branch('feature/foo', repo.head.get_object()) + + # Check before deletion + output = self.app.post('/test', follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertIn( + '', + output.data) + self.assertIn( + '', + output.data) + + # Delete the branch + output = self.app.post('/test/feature/foo/delete', follow_redirects=True) + self.assertEqual(output.status_code, 200) + self.assertNotIn( + '', + output.data) + self.assertIn( + '', + output.data) + def test_view_docs(self): """ Test the view_docs endpoint. """ output = self.app.get('/docs/foo/') From 2623d50e25fdc771f5130e76c028d13ad0f119ee Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 10 2016 14:37:53 +0000 Subject: [PATCH 3/3] Check that the form to delete the branch has the proper id --- diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 98acaa6..4a518f5 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2252,6 +2252,7 @@ index 0000000..fb7093d self.assertIn( '', output.data) + self.assertIn('