Skip to content

Commit

Permalink
Add option to disable scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Apr 27, 2024
1 parent 262afef commit cb0f1bc
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 3.4.1 (beta)

- Fixed logic in filtering nested config.
- Added `--no-scripts` option to skip install/update scripts.

# 3.4 (2023-03-24)

Expand Down
15 changes: 15 additions & 0 deletions gitman/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ def main(args=None, function=None):
action="store_true",
dest="no_defaults",
)
sub.add_argument(
"-S",
"--no-scripts",
help="skip running scripts after installation",
action="store_true",
dest="no_scripts",
)

# Update parser
info = "update dependencies to the latest versions"
Expand All @@ -144,6 +151,13 @@ def main(args=None, function=None):
default=None,
help="disable recording of updated versions",
)
sub.add_argument(
"-S",
"--no-scripts",
help="skip running scripts after installation",
action="store_true",
dest="no_scripts",
)

# List parser
info = "display the current version of each dependency"
Expand Down Expand Up @@ -262,6 +276,7 @@ def _get_command(function, namespace):
force_interactive=namespace.force_interactive,
clean=namespace.clean,
skip_changes=namespace.skip_changes,
skip_scripts=namespace.no_scripts,
)
if namespace.command == "install":
kwargs.update(
Expand Down
8 changes: 6 additions & 2 deletions gitman/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def install(
clean=True,
skip_changes=False,
skip_default_group=False,
skip_scripts=False,
):
"""Install dependencies for a project.
Expand All @@ -80,6 +81,7 @@ def install(
should be skipped
- `skip_default_group`: indicates default_group should be skipped if
`*names` is empty
- `skip_scripts`: indicates scripts should be skipped
"""
log.info(
"%sInstalling dependencies: %s",
Expand Down Expand Up @@ -115,7 +117,7 @@ def install(
)
count += _count # type: ignore

if _count:
if _count and not skip_scripts:
label = "nested scripts" if index else "scripts"
common.show(f"Running {label}...", color="message", log=False)
common.newline()
Expand All @@ -136,6 +138,7 @@ def update(
lock=None, # pylint: disable=redefined-outer-name
skip_changes=False,
skip_default_group=False,
skip_scripts=False,
):
"""Update dependencies for a project.
Expand All @@ -155,6 +158,7 @@ def update(
should be skipped
- `skip_default_group`: indicates default_group should be skipped if
`*names` is empty
- `skip_scripts`: indicates scripts should be skipped
"""
log.info(
"%s dependencies%s: %s",
Expand Down Expand Up @@ -198,7 +202,7 @@ def update(
skip_changes=skip_changes or force_interactive,
)

if _count:
if _count and not skip_scripts:
label = "nested scripts" if index else "scripts"
common.show(f"Running {label}...", color="message", log=False)
common.newline()
Expand Down
7 changes: 7 additions & 0 deletions gitman/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ def main(args=None):
action="store_true",
dest="no_defaults",
)
parser.add_argument(
"-S",
"--no-scripts",
help="skip running scripts after installation",
action="store_true",
dest="no_scripts",
)

# Update option
group.add_argument(
Expand Down
15 changes: 15 additions & 0 deletions gitman/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_install(self, mock_install):
fetch=False,
clean=False,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
)

Expand All @@ -93,6 +94,7 @@ def test_install_root(self, mock_install):
fetch=False,
clean=False,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
)

Expand All @@ -109,6 +111,7 @@ def test_install_force(self, mock_install):
fetch=False,
clean=False,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
)

Expand All @@ -125,6 +128,7 @@ def test_install_fetch(self, mock_install):
fetch=True,
clean=False,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
)

Expand All @@ -141,6 +145,7 @@ def test_install_clean(self, mock_install):
fetch=False,
clean=True,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
)

Expand All @@ -159,6 +164,7 @@ def test_install_specific_sources(self, mock_install):
fetch=False,
clean=False,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
)

Expand All @@ -175,6 +181,7 @@ def test_install_with_depth(self, mock_update):
fetch=False,
clean=False,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
)

Expand Down Expand Up @@ -204,6 +211,7 @@ def test_update(self, mock_update):
recurse=False,
lock=None,
skip_changes=False,
skip_scripts=False,
)

@patch("gitman.commands.update")
Expand All @@ -220,6 +228,7 @@ def test_update_recursive(self, mock_update):
recurse=True,
lock=None,
skip_changes=False,
skip_scripts=False,
)

@patch("gitman.commands.update")
Expand All @@ -236,6 +245,7 @@ def test_update_no_lock(self, mock_update):
recurse=False,
lock=False,
skip_changes=False,
skip_scripts=False,
)

@patch("gitman.commands.update")
Expand All @@ -252,6 +262,7 @@ def test_update_skip_changes(self, mock_update):
recurse=False,
lock=None,
skip_changes=True,
skip_scripts=False,
)

@patch("gitman.commands.update")
Expand All @@ -268,6 +279,7 @@ def test_update_force(self, mock_update):
recurse=False,
lock=None,
skip_changes=False,
skip_scripts=False,
)

@patch("gitman.commands.update")
Expand All @@ -284,6 +296,7 @@ def test_update_force_interactive(self, mock_update):
recurse=False,
lock=None,
skip_changes=False,
skip_scripts=False,
)

@patch("gitman.commands.update")
Expand All @@ -302,6 +315,7 @@ def test_update_specific_sources(self, mock_install):
recurse=False,
lock=None,
skip_changes=False,
skip_scripts=False,
)

@patch("gitman.commands.update")
Expand All @@ -318,6 +332,7 @@ def test_update_with_depth(self, mock_update):
recurse=False,
lock=None,
skip_changes=False,
skip_scripts=False,
)


Expand Down
6 changes: 5 additions & 1 deletion gitman/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class TestMain:

"""Unit tests for the top-level arguments."""

@patch("gitman.cli.commands")
Expand All @@ -25,6 +24,7 @@ def test_install(self, mock_commands):
force=False,
force_interactive=False,
skip_changes=False,
skip_scripts=False,
skip_default_group=False,
),
call.install().__bool__(), # command status check
Expand All @@ -47,6 +47,7 @@ def test_update(self, mock_commands):
recurse=False,
lock=True,
skip_changes=False,
skip_scripts=False,
),
call.update().__bool__(), # command status check
] == mock_commands.mock_calls
Expand All @@ -68,6 +69,7 @@ def test_update_recursive(self, mock_commands):
recurse=True,
lock=True,
skip_changes=False,
skip_scripts=False,
),
call.update().__bool__(), # command status check
] == mock_commands.mock_calls
Expand All @@ -89,6 +91,7 @@ def test_update_no_lock(self, mock_commands):
recurse=False,
lock=False,
skip_changes=False,
skip_scripts=False,
),
call.update().__bool__(), # command status check
] == mock_commands.mock_calls
Expand All @@ -110,6 +113,7 @@ def test_update_skip_changes(self, mock_commands):
recurse=False,
lock=True,
skip_changes=True,
skip_scripts=False,
),
call.update().__bool__(), # command status check
] == mock_commands.mock_calls
Expand Down
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.4.1b1"
version = "3.4.1b2"
description = "A language-agnostic dependency manager using Git."

license = "MIT"
Expand Down

0 comments on commit cb0f1bc

Please sign in to comment.