Skip to content

Commit

Permalink
Default depth to 5
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
jacebrowning committed Mar 22, 2016
1 parent c466882 commit 114f160
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -5,6 +5,7 @@ Revision History
----------------

- Added `edit` command to launch the configuration file.
- Depth now defaults to 5 to prevent infinite recursion.

0.8.3 (2016/03/14)
------------------
Expand Down
2 changes: 1 addition & 1 deletion gitman/cli.py
Expand Up @@ -29,7 +29,7 @@ def main(args=None, function=None):
help="root directory of the project")
depth = argparse.ArgumentParser(add_help=False)
depth.add_argument('-d', '--depth', type=common.positive_int,
default=None, metavar="NUM",
default=5, metavar="NUM",
help="limit the number of dependency levels")
options = argparse.ArgumentParser(add_help=False)
options.add_argument('-f', '--force', action='store_true',
Expand Down
40 changes: 20 additions & 20 deletions gitman/test/test_cli.py
Expand Up @@ -57,15 +57,15 @@ def test_install(self, mock_install):
cli.main(['install'])

mock_install.assert_called_once_with(
root=None, depth=None, force=False, fetch=False, clean=False)
root=None, depth=5, force=False, fetch=False, clean=False)

@patch('gitman.commands.install')
def test_install_root(self, mock_install):
"""Verify the project's root can be specified."""
cli.main(['install', '--root', 'mock/path/to/root'])

mock_install.assert_called_once_with(
root='mock/path/to/root', depth=None,
root='mock/path/to/root', depth=5,
force=False, fetch=False, clean=False)

@patch('gitman.commands.install')
Expand All @@ -74,40 +74,40 @@ def test_install_force(self, mock_install):
cli.main(['install', '--force'])

mock_install.assert_called_once_with(
root=None, depth=None, force=True, fetch=False, clean=False)
root=None, depth=5, force=True, fetch=False, clean=False)

@patch('gitman.commands.install')
def test_install_fetch(self, mock_install):
"""Verify fetching can be enabled."""
cli.main(['install', '--fetch'])

mock_install.assert_called_once_with(
root=None, depth=None, force=False, fetch=True, clean=False)
root=None, depth=5, force=False, fetch=True, clean=False)

@patch('gitman.commands.install')
def test_install_clean(self, mock_install):
"""Verify dependency cleaning can be enabled."""
cli.main(['install', '--clean'])

mock_install.assert_called_once_with(
root=None, depth=None, force=False, fetch=False, clean=True)
root=None, depth=5, force=False, fetch=False, clean=True)

@patch('gitman.commands.install')
def test_install_specific_sources(self, mock_install):
"""Verify individual dependencies can be installed."""
cli.main(['install', 'foo', 'bar'])

mock_install.assert_called_once_with(
'foo', 'bar', root=None, depth=None,
'foo', 'bar', root=None, depth=5,
force=False, fetch=False, clean=False)

@patch('gitman.commands.install')
def test_install_with_depth(self, mock_update):
"""Verify the 'install' command can be limited by depth."""
cli.main(['install', '--depth', '5'])
cli.main(['install', '--depth', '10'])

mock_update.assert_called_once_with(
root=None, depth=5, force=False, fetch=False, clean=False)
root=None, depth=10, force=False, fetch=False, clean=False)

@patch('gitman.commands.install', Mock())
def test_install_with_depth_invalid(self):
Expand All @@ -128,7 +128,7 @@ def test_update(self, mock_update):
cli.main(['update'])

mock_update.assert_called_once_with(
root=None, depth=None,
root=None, depth=5,
force=False, clean=False, recurse=False, lock=None)

@patch('gitman.commands.update')
Expand All @@ -137,7 +137,7 @@ def test_update_recursive(self, mock_update):
cli.main(['update', '--all'])

mock_update.assert_called_once_with(
root=None, depth=None,
root=None, depth=5,
force=False, clean=False, recurse=True, lock=None)

@patch('gitman.commands.update')
Expand All @@ -146,7 +146,7 @@ def test_update_no_lock(self, mock_update):
cli.main(['update', '--no-lock'])

mock_update.assert_called_once_with(
root=None, depth=None,
root=None, depth=5,
force=False, clean=False, recurse=False, lock=False)

@patch('gitman.commands.update')
Expand All @@ -155,7 +155,7 @@ def test_update_lock(self, mock_update):
cli.main(['update', '--lock'])

mock_update.assert_called_once_with(
root=None, depth=None,
root=None, depth=5,
force=False, clean=False, recurse=False, lock=True)

def test_update_lock_conflict(self):
Expand All @@ -169,16 +169,16 @@ def test_update_specific_sources(self, mock_install):
cli.main(['update', 'foo', 'bar'])

mock_install.assert_called_once_with(
'foo', 'bar', root=None, depth=None,
'foo', 'bar', root=None, depth=5,
force=False, clean=False, recurse=False, lock=None)

@patch('gitman.commands.update')
def test_update_with_depth(self, mock_update):
"""Verify the 'update' command can be limited by depth."""
cli.main(['update', '--depth', '5'])
cli.main(['update', '--depth', '10'])

mock_update.assert_called_once_with(
root=None, depth=5,
root=None, depth=10,
force=False, clean=False, recurse=False, lock=None)


Expand All @@ -192,31 +192,31 @@ def test_list(self, mock_display):
cli.main(['list'])

mock_display.assert_called_once_with(
root=None, depth=None, allow_dirty=True)
root=None, depth=5, allow_dirty=True)

@patch('gitman.commands.display')
def test_list_root(self, mock_display):
"""Verify the project's root can be specified."""
cli.main(['list', '--root', 'mock/path/to/root'])

mock_display.assert_called_once_with(
root='mock/path/to/root', depth=None, allow_dirty=True)
root='mock/path/to/root', depth=5, allow_dirty=True)

@patch('gitman.commands.display')
def test_list_no_dirty(self, mock_display):
"""Verify the 'list' command can be set to fail when dirty."""
cli.main(['list', '--no-dirty'])

mock_display.assert_called_once_with(
root=None, depth=None, allow_dirty=False)
root=None, depth=5, allow_dirty=False)

@patch('gitman.commands.display')
def test_update_with_depth(self, mock_update):
"""Verify the 'list' command can be limited by depth."""
cli.main(['list', '--depth', '5'])
cli.main(['list', '--depth', '10'])

mock_update.assert_called_once_with(
root=None, depth=5, allow_dirty=True)
root=None, depth=10, allow_dirty=True)


def describe_lock():
Expand Down

0 comments on commit 114f160

Please sign in to comment.