| |
@@ -152,3 +152,36 @@
|
| |
mock.call(['git', 'checkout', 'review/2344/1'], graceful=False),
|
| |
])
|
| |
self.assertEqual(result.exit_code, 0)
|
| |
+
|
| |
+ @mock.patch('pag.commands.review.run')
|
| |
+ @mock.patch('pag.commands.review.list_pull_requests', new=lambda _: LIST_RESPONSE['requests'])
|
| |
+ @mock.patch('pag.commands.review.in_git_repo', new=lambda: 'pagure')
|
| |
+ def test_cleanup_merged_branches(self, run):
|
| |
+ run.return_value = (0, 'review/1/1\nreview/1/2\n')
|
| |
+
|
| |
+ result = self.runner.invoke(review, ['--cleanup'])
|
| |
+
|
| |
+ self.assertEqual(result.exit_code, 0)
|
| |
+
|
| |
+ self.assertEqual(
|
| |
+ run.call_args_list,
|
| |
+ [
|
| |
+ mock.call(['git', 'branch', '--list', 'review/*'], echo=False),
|
| |
+ mock.call(['git', 'branch', '-D', 'review/1/1', 'review/1/2']),
|
| |
+ ])
|
| |
+
|
| |
+ @mock.patch('pag.commands.review.run')
|
| |
+ @mock.patch('pag.commands.review.list_pull_requests', new=lambda _: LIST_RESPONSE['requests'])
|
| |
+ @mock.patch('pag.commands.review.in_git_repo', new=lambda: 'pagure')
|
| |
+ def test_keep_branch_for_opened_pr(self, run):
|
| |
+ run.return_value = (0, 'review/2344/1\nreview/2344/2\n')
|
| |
+
|
| |
+ result = self.runner.invoke(review, ['--cleanup'])
|
| |
+
|
| |
+ self.assertEqual(result.exit_code, 0)
|
| |
+
|
| |
+ self.assertEqual(
|
| |
+ run.call_args_list,
|
| |
+ [
|
| |
+ mock.call(['git', 'branch', '--list', 'review/*'], echo=False),
|
| |
+ ])
|
| |
These can accumulate quite quickly, and having to delete them manually is a lot of work. Instead we can add
pag review --cleanup
command to delete all review branches that correspond to merged or closed pull requests.There's a warning printed because this command could potentially cause loss of data (user reviews pull request and starts their own work on the review branch).