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