Skip to content

Commit

Permalink
Merge pull request #276 from jacebrowning/display-results
Browse files Browse the repository at this point in the history
Display the number of dependencies after each command
  • Loading branch information
jacebrowning committed Mar 13, 2022
2 parents 6413994 + 5156f88 commit 702870c
Show file tree
Hide file tree
Showing 8 changed files with 409 additions and 394 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added support for locking dependencies to specific versions.
- Updated dependency locator to include all nested projects.
- Added a summary message to display the dependency count.

# 3.1 (2022-02-23)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

GitMan is a language-agnostic dependency manager using Git. It aims to serve as a submodules replacement and provides advanced options for managing versions of nested Git repositories.

[![Demo](https://raw.githubusercontent.com/jacebrowning/gitman/main/docs/demo.gif)](https://asciinema.org/a/y3VenEKfLreczVpaLPbnU6AEQ)
[![Demo](https://raw.githubusercontent.com/jacebrowning/gitman/main/docs/demo.gif)](https://asciinema.org/a/3DLos4HIU84P0AfFlZMYcgPus)

[![Unix Build Status](https://img.shields.io/travis/com/jacebrowning/gitman/main.svg?label=unix)](https://travis-ci.com/jacebrowning/gitman)
[![Windows Build Status](https://img.shields.io/appveyor/ci/jacebrowning/gitman/main.svg?label=window)](https://ci.appveyor.com/project/jacebrowning/gitman)
Expand Down
767 changes: 387 additions & 380 deletions docs/demo.cast

Large diffs are not rendered by default.

Binary file modified docs/demo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 16 additions & 10 deletions gitman/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ def install(
configs = [config] if config else []
configs.extend(find_nested_configs(root, depth, []))
if configs:
count = 0
common.newline()

for config in configs:
common.show("Installing dependencies...", color="message", log=False)
common.newline()
count = config.install_dependencies(

_count = config.install_dependencies(
*names,
update=False,
depth=depth,
Expand All @@ -106,8 +108,9 @@ def install(
skip_changes=skip_changes,
skip_default_group=skip_default_group,
)
count += _count # type: ignore

if count:
if _count:
_run_scripts(
*names, depth=depth, force=force, _config=config, show_shell_stdout=True
)
Expand Down Expand Up @@ -159,12 +162,13 @@ def update(
configs = [config] if config else []
configs.extend(find_nested_configs(root, depth, []))
if configs:
count = 0
common.newline()

for config in configs:
common.show("Updating dependencies...", color="message", log=False)
common.newline()
count = config.install_dependencies(
_count = config.install_dependencies(
*names,
update=True,
depth=depth,
Expand All @@ -176,8 +180,9 @@ def update(
skip_changes=skip_changes,
skip_default_group=skip_default_group,
)
count += _count # type: ignore

if count and lock is not False:
if _count and lock is not False:
common.show("Recording installed versions...", color="message", log=False)
common.newline()
config.lock_dependencies(
Expand All @@ -186,7 +191,7 @@ def update(
skip_changes=skip_changes or force_interactive,
)

if count:
if _count:
_run_scripts(
*names, depth=depth, force=force, _config=config, show_shell_stdout=True
)
Expand Down Expand Up @@ -281,12 +286,13 @@ def lock(*names, root=None):
configs = [config] if config else []
configs.extend(find_nested_configs(root, None, []))
if configs:
count = 0
common.newline()

for config in configs:
common.show("Locking dependencies...", color="message", log=False)
common.newline()
count = config.lock_dependencies(*names, obey_existing=False)
count += config.lock_dependencies(*names, obey_existing=False) # type: ignore
common.dedent(level=0)

return _display_result("lock", "Locked", count)
Expand Down Expand Up @@ -361,7 +367,7 @@ def edit(*, root=None):
return system.launch(config.path)


def _display_result(present, past, count, allow_zero=False):
def _display_result(modify, modified, count, allow_zero=False):
"""Convert a command's dependency count to a return status.
>>> _display_result("sample", "Sampled", 1)
Expand All @@ -378,11 +384,11 @@ def _display_result(present, past, count, allow_zero=False):
"""
if count is None:
log.warning("No dependencies to %s", present)
common.show(f"No dependencies to {modify}", color="error")
elif count == 1:
log.info("%s 1 dependency", past)
common.show(f"{modified} 1 dependency", color="message")
else:
log.info("%s %s dependencies", past, count)
common.show(f"{modified} {count} dependencies", color="message")

if count:
return True
Expand Down
4 changes: 2 additions & 2 deletions gitman/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import log
from datafiles import datafile, field

from .. import common, exceptions, shell
from .. import common, exceptions, settings, shell
from ..decorators import preserve_cwd
from .group import Group
from .source import Identity, Source
Expand Down Expand Up @@ -422,7 +422,7 @@ def find_nested_configs(
root = os.path.abspath(root) if root else _resolve_current_directory()
configs: List[Config] = []

if depth is not None and depth <= 1:
if (depth is not None and depth <= 1) or settings.CI:
return configs

log.debug(f"Searching for nested project in: {root}")
Expand Down
1 change: 1 addition & 0 deletions gitman/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
LOGGING_DATEFMT = "%Y-%m-%d %H:%M"

# Display settings
CI = bool(os.getenv("CI", ""))
RECORDING_DELAY = int(os.getenv("RECORDING_DELAY", "0"))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]

name = "gitman"
version = "3.2a5"
version = "3.2a6"
description = "A language-agnostic dependency manager using Git."

license = "MIT"
Expand Down

0 comments on commit 702870c

Please sign in to comment.