Skip to content

Commit

Permalink
Merge pull request #251 from mrpossoms/depth-first-scripts
Browse files Browse the repository at this point in the history
Depth first script execution
  • Loading branch information
jacebrowning committed Feb 25, 2021
2 parents 99904bd + c263491 commit b9a5ecf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 10 additions & 5 deletions gitman/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datafiles import datafile, field

from .. import common, exceptions, shell
from ..decorators import preserve_cwd
from .group import Group
from .source import Source

Expand Down Expand Up @@ -140,6 +141,7 @@ def install_dependencies(

return count

@preserve_cwd
def run_scripts(self, *names, depth=None, force=False, show_shell_stdout=False):
"""Run scripts for the specified dependencies."""
if depth == 0:
Expand All @@ -158,17 +160,20 @@ def run_scripts(self, *names, depth=None, force=False, show_shell_stdout=False):
count = 0
for source in sources:
if source.name in sources_filter:
source.run_scripts(force=force, show_shell_stdout=show_shell_stdout)
count += 1
shell.cd(source.name)

config = load_config(search=False)
if config:
common.indent()
count += config.run_scripts(
depth=None if depth is None else max(0, depth - 1), force=force
)
remaining_depth = None if depth is None else max(0, depth - 1)
if remaining_depth:
common.newline()
count += config.run_scripts(depth=remaining_depth, force=force)
common.dedent()

source.run_scripts(force=force, show_shell_stdout=show_shell_stdout)
count += 1

shell.cd(self.location_path, _show=False)

common.dedent()
Expand Down
1 change: 0 additions & 1 deletion gitman/models/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def run_scripts(self, force=False, show_shell_stdout=False):
log.info("Running install scripts...")

# Enter the working tree
shell.cd(self.name)
if not git.valid():
raise self._invalid_repository

Expand Down

0 comments on commit b9a5ecf

Please sign in to comment.