Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#38): Don't prompt when nothing to do #40

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion NEWS.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
News
====

0.1.1

*Release date: March 28, 2012*

* Fix issue #1 which makes the git-sweep help menus more useful
* Fix a minor grammar issue in the help
* Fix issue #2 which dropped extra options when telling you to use
cleanup
* Added a --force option to skip confirmation prompt

0.1.0
-----

*Release date: 0.1.0*
*Release date: n/a*

* Initial release
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
README = open(os.path.join(here, 'README.rst')).read()
NEWS = open(os.path.join(here, 'NEWS.txt')).read()

version = '0.1.0'
version = '0.1.1'

install_requires = [
'GitPython>=0.3.2RC1']
Expand All @@ -20,7 +20,17 @@
description="Clean up branches from your Git remotes",
long_description=README + '\n\n' + NEWS,
classifiers=[
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 4 - Beta',
'Environment :: Console',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: POSIX',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Version Control',
'Topic :: Text Processing'
],
keywords='git maintenance branches',
author='Arc90, Inc.',
Expand Down
33 changes: 17 additions & 16 deletions src/gitsweep/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,23 @@ def _sweep(self):
deleter = Deleter(repo, remote_name=remote_name,
master_branch=master_branch)

if not args.force:
sys.stdout.write('\nDelete these branches? (y/n) ')
answer = raw_input()
if args.force or answer.lower().startswith('y'):
sys.stdout.write('\n')
for ref in ok_to_delete:
sys.stdout.write(' deleting {0}'.format(ref.remote_head))
deleter.remove_remote_refs([ref])
sys.stdout.write(' (done)\n')

sys.stdout.write('\nAll done!\n')
sys.stdout.write('\nTell everyone to run `git fetch --prune` '
'to sync with this remote.\n')
sys.stdout.write('(you don\'t have to, yours is synced)\n')
else:
sys.stdout.write('\nOK, aborting.\n')
if ok_to_delete:
if not args.force:
sys.stdout.write('\nDelete these branches? (y/n) ')
answer = raw_input()
if args.force or answer.lower().startswith('y'):
sys.stdout.write('\n')
for ref in ok_to_delete:
sys.stdout.write(' deleting {0}'.format(ref.remote_head))
deleter.remove_remote_refs([ref])
sys.stdout.write(' (done)\n')

sys.stdout.write('\nAll done!\n')
sys.stdout.write('\nTell everyone to run `git fetch --prune` '
'to sync with this remote.\n')
sys.stdout.write('(you don\'t have to, yours is synced)\n')
else:
sys.stdout.write('\nOK, aborting.\n')
elif ok_to_delete:
# Replace the first argument with cleanup
sysv_copy = self.args[:]
Expand Down
16 changes: 14 additions & 2 deletions src/gitsweep/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_will_preview_none_found(self):

def test_will_cleanup(self):
"""
Will preview the proposed deletes.
Will cleanup the proposed deletes.
"""
for i in range(1, 6):
self.command('git checkout -b branch{0}'.format(i))
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_will_cleanup(self):

def test_will_abort_cleanup(self):
"""
Will preview the proposed deletes.
Will abort cleanup on user request
"""
for i in range(1, 6):
self.command('git checkout -b branch{0}'.format(i))
Expand Down Expand Up @@ -252,3 +252,15 @@ 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_no_branches_found(self):
"""
Will not prompt user if no branches are found that can be cleaned up
"""
(retcode, stdout, stderr) = self.gscommand('git-sweep cleanup --force')

self.assertResults('''
Fetching from the remote
No remote branches are available for cleaning up
''', stdout)