How to use the gitman.common.show 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 / cli.py View on Github external
log.debug("Command canceled")
    except exceptions.UncommittedChanges as exception:
        _show_error(exception)
        exit_message = (
            "Run again with --force/--force-interactive to discard changes "
            "or '--skip-changes' to skip this dependency"
        )
    except exceptions.ScriptFailure as exception:
        _show_error(exception)
        exit_message = "Run again with '--force' to ignore script errors"
    except exceptions.InvalidConfig as exception:
        _show_error(exception)
        exit_message = "Adapt config and run again"
    finally:
        if exit_message:
            common.show(exit_message, color='message')
            common.newline()

    if success:
        log.debug("Command succeeded")
    else:
        log.debug("Command failed")
        sys.exit(1)
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
common.show("Updating dependencies...", color='message', log=False)
        common.newline()
        count = config.install_dependencies(
            *names,
            update=True,
            depth=depth,
            recurse=recurse,
            force=force,
            force_interactive=force_interactive,
            fetch=True,
            clean=clean,
            skip_changes=skip_changes,
        )

        if count and lock is not False:
            common.show("Recording installed versions...", color='message', log=False)
            common.newline()
            config.lock_dependencies(
                *names,
                obey_existing=lock is None,
                skip_changes=skip_changes or force_interactive,
            )

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

    return _display_result("update", "Updated", count)
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:
github jacebrowning / gitman / gitman / models / source.py View on Github external
if os.path.isdir(self.name):

            shell.cd(self.name)
            if not git.valid():
                raise self._invalid_repository

            path = os.getcwd()
            url = git.get_url(self.type)
            if git.changes(
                self.type,
                display_status=not allow_dirty and not skip_changes,
                _show=not skip_changes,
            ):

                if allow_dirty:
                    common.show(self.DIRTY, color='git_dirty', log=False)
                    common.newline()
                    return path, url, self.DIRTY

                if skip_changes:
                    msg = ("Skipped lock due to uncommitted changes " "in {}").format(
                        os.getcwd()
                    )
                    common.show(msg, color='git_changes')
                    common.newline()
                    return path, url, self.DIRTY

                msg = "Uncommitted changes in {}".format(os.getcwd())
                raise exceptions.UncommittedChanges(msg)

            rev = git.get_hash(self.type, _show=True)
            common.show(rev, color='git_rev', log=False)
github jacebrowning / gitman / gitman / commands.py View on Github external
source = Source(
            type='git',
            name="sample_dependency",
            repo="https://github.com/githubtraining/hellogitworld",
        )
        config.sources.append(source)
        source = source.lock(rev="ebbbf773431ba07510251bb03f9525c7bab2b13a")
        config.sources_locked.append(source)
        config.datafile.save()

        msg = "Created sample config file: {}".format(config.path)
        common.show(msg, color='success')
        success = True

    msg = "To edit this config file, run: gitman edit"
    common.show(msg, color='message')

    return success
github jacebrowning / gitman / gitman / shell.py View on Github external
def show(name, *args, stdout=True):
    program = ' '.join([name, *args])
    if stdout:
        common.show(CMD_PREFIX + program, color='shell')
    else:
        log.debug(CMD_PREFIX + program)
    return program