Skip to content

Commit

Permalink
Remove confusing '--lock' option on 'update' command
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jun 24, 2018
1 parent aaf505a commit 36c9352
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 72 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@

- Added `--keep-location` option on `uninstall` (@DavidWatkins).
- Added feature to enable sparse checkouts. See the docs for further information. (@xenji)
- **BREAKING**: Removed confusing `--lock` option on `update` command in favor of just using the `lock` command.
- **BREAKING**: Renamed `--no-lock` to `--skip-lock` on `update` command.
- **BREAKING**: Renamed `--no-dirty` to `--fail-if-dirty` on `list` command.

## 1.4 (2017/03/21)

Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/api.md
Expand Up @@ -45,7 +45,7 @@ with optional arguments:
- `force`: indicates uncommitted changes can be overwritten and
script errors can be ignored
- `clean`: indicates untracked files should be deleted from dependencies
- `lock`: indicates actual dependency versions should be recorded
- `lock`: indicates updated dependency versions should be recorded

## List

Expand Down
54 changes: 24 additions & 30 deletions docs/interfaces/cli.md
Expand Up @@ -15,83 +15,83 @@ $ gitman init
To clone/checkout the specified dependencies, run:

```sh
gitman install
$ gitman install
```

or filter the dependency list by directory name:

```sh
gitman install <name1> <name2> <etc.>
$ gitman install <name1> <name2> <etc.>
```

or limit the traversal of nested dependencies:

```sh
gitman install --depth=<count>
$ gitman install --depth=<count>
```

It will leave untracked files alone. To delete them, run:

```sh
gitman install --clean
$ gitman install --clean
```

It will only fetch from the repository if needed. To always fetch, run:

```sh
gitman install --fetch
$ gitman install --fetch
```

It will exit with an error if there are any uncommitted changes in dependencies or a post-install script fails. To overwrite all changes or ignore script failures, run:

```sh
gitman install --force
$ gitman install --force
```

## Update

If any of the dependencies track a branch (rather than a specific commit), the current upstream version of that branch can be checked out by running:

```sh
gitman update
$ gitman update
```

or filter the dependency list by directory name:

```sh
gitman update <name1> <name2> <etc.>
$ gitman update <name1> <name2> <etc.>
```

or limit the traversal of nested dependencies:

```sh
gitman update --depth=<count>
$ gitman update --depth=<count>
```

This will also record the exact versions of any previously locked dependencies. Disable this behavior by instead running:

```sh
gitman update --no-lock
$ gitman update --skip-lock
```

or to additionally get the latest versions of all nested dependencies, run:

```sh
gitman update --all
$ gitman update --all
```

## List

To display the currently checked out dependencies, run:

```sh
gitman list
$ gitman list
```

or exit with an error if there are any uncommitted changes:

```sh
gitman list --no-dirty
$ gitman list --fail-if-dirty
```

The `list` command will also record versions in the log file.
Expand All @@ -101,77 +101,71 @@ The `list` command will also record versions in the log file.
To manually record the exact version of each dependency, run:

```sh
gitman lock
$ gitman lock
```

or lock down specific dependencies:

```sh
gitman lock <name1> <name2> <etc.>
```

This can be combined with updating dependencies by running:

```sh
gitman update --lock
$ gitman lock <name1> <name2> <etc.>
```

To restore the exact versions previously checked out, run:

```sh
gitman install
$ gitman install
```

## Uninstall

To delete all dependencies, run:

```sh
gitman uninstall
$ gitman uninstall
```

If any dependencies contain uncommitted changes, instead run:

```sh
gitman uninstall --force
$ gitman uninstall --force
```

If you need to keep the top level folder and anything other than the dependencies:

```sh
gitman uninstall --keep-location
$ gitman uninstall --keep-location
```

## Show

To display the path to the dependency storage location:

```sh
gitman show
$ gitman show
```

To display the path to a dependency:

```sh
gitman show <name>
$ gitman show <name>
```

To display the path to the config file:

```sh
gitman show --config
$ gitman show --config
```

To display the path to the log file:

```sh
gitman show --log
$ gitman show --log
```

## Edit

To open the existing config file:

```sh
gitman edit
$ gitman edit
```
22 changes: 11 additions & 11 deletions docs/interfaces/plugin.md
Expand Up @@ -7,72 +7,72 @@
To clone/checkout the specified dependencies, run:

```sh
git deps
$ git deps
```

Delete all untracked files in dependencies by instead running:

```sh
git deps --clean
$ git deps --clean
```

Git will exit with an error if there are any uncommitted changes in dependencies or a post-install script fails. To overwrite all changes or ignore script failures, run:

```sh
git deps --force
$ git deps --force
```

## Update

If any of the dependencies track a branch (rather than a specific commit), the current upstream version of that branch can be checked out by running:

```sh
git deps --update
$ git deps --update
```

This will also record the exact versions that were checked out. Disable this behavior by instead running:

```sh
git deps --update --no-lock
$ git deps --update --skip-lock
```

Or, to additionally get the latest versions of all nested dependencies, run:

```sh
git deps --update --all
$ git deps --update --all
```

To restore the exact versions previously checked out, run:

```sh
git deps
$ git deps
```

## List

To display the currently checked out dependencies, run:

```sh
git deps --list
$ git deps --list
```

## Uninstall

To delete all dependencies, run:

```sh
git deps --uninstall
$ git deps --uninstall
```

If any dependencies contain uncommitted changes, instead run:

```sh
git deps --uninstall --force
$ git deps --uninstall --force
```

If you need to keep the top level folder and anything other than the dependencies:

```sh
git deps --uninstall --keep-location
$ git deps --uninstall --keep-location
```

2 changes: 1 addition & 1 deletion gitman/__init__.py
Expand Up @@ -3,7 +3,7 @@
import sys

__project__ = 'GitMan'
__version__ = '1.5b2'
__version__ = '1.5b3'

CLI = 'gitman'
PLUGIN = 'deps'
Expand Down
14 changes: 5 additions & 9 deletions gitman/cli.py
Expand Up @@ -65,20 +65,16 @@ def main(args=None, function=None): # pylint: disable=too-many-statements
sub.add_argument('name', nargs='*',
help="list of dependencies names to update")
sub.add_argument('-a', '--all', action='store_true', dest='recurse',
help="update all nested dependencies, recursively")
group = sub.add_mutually_exclusive_group()
group.add_argument('-l', '--lock',
action='store_true', dest='lock', default=None,
help="enable recording of versions for later reinstall")
group.add_argument('-L', '--no-lock',
action='store_false', dest='lock', default=None,
help="disable recording of versions for later reinstall")
help="also update all nested dependencies")
sub.add_argument('-L', '--skip-lock',
action='store_false', dest='lock', default=None,
help="disable recording of updated versions")

# List parser
info = "display the current version of each dependency"
sub = subs.add_parser('list', description=info.capitalize() + '.',
help=info, parents=[debug, project, depth], **shared)
sub.add_argument('-D', '--no-dirty', action='store_false',
sub.add_argument('-D', '--fail-if-dirty', action='store_false',
dest='allow_dirty',
help="fail if a source has uncommitted changes")

Expand Down
2 changes: 1 addition & 1 deletion gitman/commands.py
Expand Up @@ -102,7 +102,7 @@ def update(*names, root=None, depth=None,
- `force`: indicates uncommitted changes can be overwritten and
script errors can be ignored
- `clean`: indicates untracked files should be deleted from dependencies
- `lock`: indicates actual dependency versions should be recorded
- `lock`: indicates updated dependency versions should be recorded
"""
log.info("%s dependencies%s: %s",
Expand Down
4 changes: 2 additions & 2 deletions gitman/plugin.py
Expand Up @@ -40,9 +40,9 @@ def main(args=None):
)
parser.add_argument('-a', '--all', action='store_true', dest='recurse',
help="include nested dependencies when updating")
parser.add_argument('-L', '--no-lock',
parser.add_argument('-L', '--skip-lock',
action='store_false', dest='lock', default=True,
help="skip recording of versions for later reinstall")
help="disable recording of updated versions")

# Display option
group.add_argument(
Expand Down
18 changes: 2 additions & 16 deletions gitman/tests/test_cli.py
Expand Up @@ -155,26 +155,12 @@ def test_update_recursive(self, mock_update):
@patch('gitman.commands.update')
def test_update_no_lock(self, mock_update):
"""Verify the 'update' command can disable locking."""
cli.main(['update', '--no-lock'])
cli.main(['update', '--skip-lock'])

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

@patch('gitman.commands.update')
def test_update_lock(self, mock_update):
"""Verify the 'update' command can enable locking."""
cli.main(['update', '--lock'])

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

def test_update_lock_conflict(self):
"""Verify the 'update' command cannot specify both locking options."""
with pytest.raises(SystemExit):
cli.main(['update', '--lock', '--no-lock'])

@patch('gitman.commands.update')
def test_update_specific_sources(self, mock_install):
"""Verify individual dependencies can be installed."""
Expand Down Expand Up @@ -216,7 +202,7 @@ def test_list_root(self, mock_display):
@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'])
cli.main(['list', '--fail-if-dirty'])

mock_display.assert_called_once_with(
root=None, depth=5, allow_dirty=False)
Expand Down
2 changes: 1 addition & 1 deletion gitman/tests/test_plugin.py
Expand Up @@ -53,7 +53,7 @@ def test_update_no_lock(self, mock_commands):
"""Verify 'update' can be called without locking."""
mock_commands.update.__name__ = 'mock'

plugin.main(['--update', '--no-lock'])
plugin.main(['--update', '--skip-lock'])

assert [
call.update(root=None, depth=None,
Expand Down

0 comments on commit 36c9352

Please sign in to comment.