How to use the kibitzr.compat.sh function in kibitzr

To help you get started, we’ve selected a few kibitzr 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 kibitzr / kibitzr / kibitzr / storage.py View on Github external
def commit(self):
        """git commit and return whether there were changes"""
        self.git.add('-A', '.')
        try:
            self.git.commit('-m', self.commit_msg)
            return True
        except sh.ErrorReturnCode_1:
            return False
github kibitzr / kibitzr / kibitzr / bash.py View on Github external
def run_scipt(cls, name, stdin):
        from kibitzr.compat import sh
        logger.debug("Launching script %r", name)
        try:
            args = cls.ARGS + [name]
            return True, sh.Command(cls.EXECUTABLE)(*args, _in=stdin)
        except sh.ErrorReturnCode as exc:
            return False, exc
github kibitzr / kibitzr / kibitzr / storage.py View on Github external
def __init__(self, conf, storage_dir=None, style=None):
        self.storage_dir = storage_dir or self.STORAGE_DIR
        self.cwd = os.path.join(
            self.storage_dir,
            normalize_filename(conf['name']),
        )
        self.target = os.path.join(self.cwd, "content")
        self.git = sh.Command('git').bake(
            '--no-pager',
            _cwd=self.cwd,
        )
        self.ensure_repo_exists()
        if conf.get('url'):
            self.commit_msg = u"{name} at {url}".format(
                name=conf['name'],
                url=conf.get('url'),
            )
        else:
            self.commit_msg = conf['name']
        self.reporter = ChangesReporter(
            self.git,
            self.commit_msg,
            style,
        )
github kibitzr / kibitzr / kibitzr / bash.py View on Github external
def run_scipt(cls, name, stdin):
        from kibitzr.compat import sh
        logger.debug("Launching script %r", name)
        try:
            args = cls.ARGS + [name]
            return True, sh.Command(cls.EXECUTABLE)(*args, _in=stdin)
        except sh.ErrorReturnCode as exc:
            return False, exc
github kibitzr / kibitzr / kibitzr / storage.py View on Github external
def word(self):
        """Return last changes with word diff"""
        try:
            output = ensure_unicode(self.git.diff(
                '--no-color',
                '--word-diff=plain',
                'HEAD~1:content',
                'HEAD:content',
            ).stdout)
        except sh.ErrorReturnCode_128:
            result = ensure_unicode(self.git.show(
                "HEAD:content"
            ).stdout)
        else:
            ago = ensure_unicode(self.git.log(
                '-2',
                '--pretty=format:last change was %cr',
                'content'
            ).stdout).splitlines()
            lines = output.splitlines()
            result = u'\n'.join(
                itertools.chain(
                    itertools.islice(
                        itertools.dropwhile(
                            lambda x: not x.startswith('@@'),
                            lines[1:],