From 999a70a7bcea5af5d2b08d9d1fe04d574a6e6029 Mon Sep 17 00:00:00 2001 From: NickAb Date: Sun, 27 Jul 2014 11:21:53 +0700 Subject: [PATCH] Fix issue #10 `git-sweep cleanup` will not prompt if there are no branches to clean. --- src/gitsweep/cli.py | 2 +- src/gitsweep/tests/test_cli.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gitsweep/cli.py b/src/gitsweep/cli.py index 6b995b5..e7bb993 100644 --- a/src/gitsweep/cli.py +++ b/src/gitsweep/cli.py @@ -136,7 +136,7 @@ def _sweep(self): for ref in ok_to_delete: sys.stdout.write(' {0}\n'.format(ref.remote_head)) - if not dry_run: + if not dry_run and ok_to_delete: deleter = Deleter(repo, remote_name=remote_name, master_branch=master_branch) diff --git a/src/gitsweep/tests/test_cli.py b/src/gitsweep/tests/test_cli.py index 9ddd6ce..2f916b3 100644 --- a/src/gitsweep/tests/test_cli.py +++ b/src/gitsweep/tests/test_cli.py @@ -252,3 +252,14 @@ def test_will_force_clean(self): Tell everyone to run `git fetch --prune` to sync with this remote. (you don't have to, yours is synced) ''', stdout) + + def test_cleanup_will_not_prompt_if_none_found(self): + """ + Will not prompt clean up if no branches found. + """ + (retcode, stdout, stderr) = self.gscommand('git-sweep cleanup') + + self.assertResults(''' + Fetching from the remote + No remote branches are available for cleaning up + ''', stdout) \ No newline at end of file