Exemplo n.º 1
0
def _check_git_version():
    """Check the minimum GIT version
    """
    if not version.check('git', version.git_version()):
        print >> sys.stderr, ('GIT version %s or newer required.  '
                              'Found %s' % (version.get('git'),
                                            version.git_version()))
        sys.exit(1)
Exemplo n.º 2
0
def _common_diff_opts(config=config):
    # The '--patience' option did not appear until git 1.6.2
    # so don't allow it to be used on version previous to that
    patience = version.check('patience', version.git_version())
    submodule = version.check('diff-submodule', version.git_version())
    return {
        'patience': patience,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'with_raw_output': True,
        'with_stderr': True,
        'unified': config.get('gui.diffcontext', 3),
    }
Exemplo n.º 3
0
def _run_setup():
    """Runs distutils.setup()"""

    scripts = ['bin/git-cola']

    # git-difftool first moved out of git.git's contrib area in git 1.6.3
    if (os.environ.get('INSTALL_GIT_DIFFTOOL', '') or
            not version.check('difftool-builtin', version.git_version())):
        scripts.append('bin/difftool/git-difftool')
        scripts.append('bin/difftool/git-difftool--helper')

    if sys.platform == 'win32':
        scripts.append('win32/cola')
        scripts.append('win32/dirname')
        scripts.append('win32/py2exe-setup.py')
        scripts.append('win32/py2exe-setup.cmd')

    setup(name = 'git-cola',
          version = version.version(),
          description = 'A highly caffeinated git GUI',
          license = 'GPLv2',
          author = 'The git-cola community',
          author_email = '*****@*****.**',
          url = 'http://cola.tuxfamily.org/',
          long_description = 'A highly caffeinated git GUI',
          scripts = scripts,
          cmdclass = cmdclass,
          data_files = cola_data_files())
Exemplo n.º 4
0
def _check_git_version():
    """Check the minimum GIT version
    """
    git_version = version.git_version()
    if not version.check('git', git_version):
        print >> sys.stderr, ('GIT version %s or newer required.  '
                              'Found %s' % (version.get('git'), git_version))
        sys.exit(1)
Exemplo n.º 5
0
def _common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    return {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'with_raw_output': True,
        'with_stderr': True,
        'unified': config.get('gui.diffcontext', 3),
    }
Exemplo n.º 6
0
def _common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    return {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'with_raw_output': True,
        'with_stderr': True,
        'unified': config.get('gui.diffcontext', 3),
    }
Exemplo n.º 7
0
def _common_diff_opts(config=config):
    submodule = version.check("diff-submodule", version.git_version())
    return {
        "patience": True,
        "submodule": submodule,
        "no_color": True,
        "no_ext_diff": True,
        "with_raw_output": True,
        "with_stderr": True,
        "unified": config.get("gui.diffcontext", 3),
    }
Exemplo n.º 8
0
def common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    opts = {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'unified': config.get('gui.diffcontext', 3),
        '_raw': True,
    }
    opts.update(_diff_overrides)
    return opts
Exemplo n.º 9
0
def common_diff_opts(config=config):
    submodule = version.check("diff-submodule", version.git_version())
    opts = {
        "patience": True,
        "submodule": submodule,
        "no_color": True,
        "no_ext_diff": True,
        "unified": config.get("gui.diffcontext", 3),
        "_raw": True,
    }
    opts.update(_diff_overrides)
    return opts
Exemplo n.º 10
0
def common_diff_opts(config=config):
    submodule = version.check('diff-submodule', version.git_version())
    opts = {
        'patience': True,
        'submodule': submodule,
        'no_color': True,
        'no_ext_diff': True,
        'unified': config.get('gui.diffcontext', 3),
        '_raw': True,
    }
    opts.update(_diff_overrides)
    return opts
Exemplo n.º 11
0
def diff_helper(commit=None,
                branch=None,
                ref=None,
                endref=None,
                filename=None,
                cached=True,
                with_diff_header=False,
                suppress_header=True,
                reverse=False):
    "Invokes git diff on a filepath."
    if commit:
        ref, endref = commit+'^', commit
    argv = []
    if ref and endref:
        argv.append('%s..%s' % (ref, endref))
    elif ref:
        for r in ref.strip().split():
            argv.append(r)
    elif branch:
        argv.append(branch)

    if filename:
        argv.append('--')
        if type(filename) is list:
            argv.extend(filename)
        else:
            argv.append(filename)

    start = False
    del_tag = 'deleted file mode '

    headers = []
    deleted = cached and not os.path.exists(core.encode(filename))

    # The '--patience' option did not appear until git 1.6.2
    # so don't allow it to be used on version previous to that
    patience = version.check('patience', version.git_version())

    diffoutput = git.diff(R=reverse,
                          M=True,
                          no_color=True,
                          cached=cached,
                          unified=config.get('diff.context', 3),
                          with_raw_output=True,
                          with_stderr=True,
                          patience=patience,
                          *argv)

    # Handle 'git init'
    if diffoutput.startswith('fatal:'):
        if with_diff_header:
            return ('', '')
        else:
            return ''

    output = StringIO()

    diff = diffoutput.split('\n')
    for line in map(core.decode, diff):
        if not start and '@@' == line[:2] and '@@' in line[2:]:
            start = True
        if start or (deleted and del_tag in line):
            output.write(core.encode(line) + '\n')
        else:
            if with_diff_header:
                headers.append(core.encode(line))
            elif not suppress_header:
                output.write(core.encode(line) + '\n')

    result = core.decode(output.getvalue())
    output.close()

    if with_diff_header:
        return('\n'.join(headers), result)
    else:
        return result