How to use the gitman.common.newline function in gitman

To help you get started, we’ve selected a few gitman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jacebrowning / gitman / gitman / commands.py View on Github external
"""Display installed dependencies for a project.

    Optional arguments:

    - `root`: specifies the path to the root working tree
    - `depth`: number of levels of dependencies to traverse
    - `allow_dirty`: causes uncommitted changes to be ignored

    """
    log.info("Displaying dependencies...")
    count = None

    config = load_config(root)

    if config:
        common.newline()
        common.show(
            "Displaying current dependency versions...", color='message', log=False
        )
        common.newline()
        config.log(datetime.datetime.now().strftime("%F %T"))
        count = 0
        for identity in config.get_dependencies(depth=depth, allow_dirty=allow_dirty):
            count += 1
            config.log("{}: {} @ {}", *identity)
        config.log()

    return _display_result("display", "Displayed", count)
github jacebrowning / gitman / gitman / models / config.py View on Github external
def run_scripts(self, *names, depth=None, force=False):
        """Run scripts for the specified dependencies."""
        if depth == 0:
            log.info("Skipped directory: %s", self.location_path)
            return 0

        sources = self._get_sources()
        sources_filter = self._get_sources_filter(*names, sources=sources)

        shell.cd(self.location_path)
        common.newline()
        common.indent()

        count = 0
        for source in sources:
            if source.name in sources_filter:
                source.run_scripts(force=force)
                count += 1

                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
                    )
                    common.dedent()
github jacebrowning / gitman / gitman / commands.py View on Github external
"""Delete dependencies for a project.

    Optional arguments:

    - `root`: specifies the path to the root working tree
    - `force`: indicates uncommitted changes can be overwritten
    - `keep_location`: delete top level folder or keep the location

    """
    log.info("Deleting dependencies...")
    count = None

    config = load_config(root)

    if config:
        common.newline()
        common.show("Checking for uncommitted changes...", color='message', log=False)
        common.newline()
        count = len(list(config.get_dependencies(allow_dirty=force)))
        common.dedent(level=0)
        common.show("Deleting all dependencies...", color='message', log=False)
        common.newline()
        if keep_location:
            config.clean_dependencies()
        else:
            config.uninstall_dependencies()

    return _display_result("delete", "Deleted", count, allow_zero=True)
github jacebrowning / gitman / gitman / models / config.py View on Github external
def get_dependencies(self, depth=None, allow_dirty=True):
        """Yield the path, repository, and hash of each dependency."""
        if not os.path.exists(self.location_path):
            return

        shell.cd(self.location_path)
        common.newline()
        common.indent()

        for source in self.sources:

            if depth == 0:
                log.info("Skipped dependency: %s", source.name)
                continue

            yield source.identify(allow_dirty=allow_dirty)

            config = load_config(search=False)
            if config:
                common.indent()
                yield from config.get_dependencies(
                    depth=None if depth is None else max(0, depth - 1),
                    allow_dirty=allow_dirty,
github jacebrowning / gitman / gitman / models / source.py View on Github external
def run_scripts(self, force=False):
        log.info("Running install scripts...")

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

        # Check for scripts
        if not self.scripts:
            common.show("(no scripts to run)", color='shell_info')
            common.newline()
            return

        # Run all scripts
        for script in self.scripts:
            try:
                lines = shell.call(script, _shell=True)
            except exceptions.ShellError as exc:
                common.show(*exc.output, color='shell_error')
                cmd = exc.program
                if force:
                    log.debug("Ignored error from call to '%s'", cmd)
                else:
                    msg = "Command '{}' failed in {}".format(cmd, os.getcwd())
                    raise exceptions.ScriptFailure(msg)
            else:
                common.show(*lines, color='shell_output')
github jacebrowning / gitman / gitman / cli.py View on Github external
def _show_error(exception):
    common.dedent(0)
    common.newline()
    common.show(str(exception), color='error')
    common.newline()
github jacebrowning / gitman / gitman / commands.py View on Github external
- `fetch`: indicates the latest branches should always be fetched
    - `clean`: indicates untracked files should be deleted from dependencies
    - `skip_changes`: indicates dependencies with uncommitted changes
     should be skipped
    """
    log.info(
        "%sInstalling dependencies: %s",
        'force-' if force or force_interactive else '',
        ', '.join(names) if names else '',
    )
    count = None

    config = load_config(root)

    if config:
        common.newline()
        common.show("Installing dependencies...", color='message', log=False)
        common.newline()
        count = config.install_dependencies(
            *names,
            update=False,
            depth=depth,
            force=force,
            force_interactive=force_interactive,
            fetch=fetch,
            clean=clean,
            skip_changes=skip_changes,
        )

        if count:
            _run_scripts(*names, depth=depth, force=force, _config=config)