Ejemplo n.º 1
0
opts = {}
repo_base = git.repo_base()
ui = StdioUI()

os.chdir(repo_base)
failing_files = set()
staged_mismatch = set()

for status, fname in git.status(filter="MA", cached=True):
    if args.verbose:
        print "Checking %s..." % fname
    if check_ignores(fname):
        continue
    if status == "M":
        regions = git.staged_regions(fname)
    else:
        regions = all_regions

    # Show they appropriate object and dump it to a file
    status = git.file_from_index(fname)
    f = TemporaryFile()
    f.write(status)

    verifiers = [ v(ui, opts, base=repo_base) for v in all_verifiers ]
    for v in verifiers:
        f.seek(0)
        # It is prefered that the first check is silent as it is in the
        # staged file. If the check fails, then we will do it non-silently
        # on the current file, reporting meaningful shortcomings
        if not v.skip(fname) and v.check(fname, regions, fobj=f, silent=True):
Ejemplo n.º 2
0
opts = {}
repo_base = git.repo_base()
ui = StdioUI()

os.chdir(repo_base)
failing_files = set()
staged_mismatch = set()

for status, fname in git.status(filter="MA", cached=True):
    if args.verbose:
        print("Checking {}...".format(fname))
    if check_ignores(fname):
        continue
    if status == "M":
        regions = git.staged_regions(fname)
    else:
        regions = all_regions

    # Show the appropriate object and dump it to a file
    try:
        status = git.file_from_index(fname)
    except UnicodeDecodeError:
        print("Decoding '" + fname
            + "' throws a UnicodeDecodeError.", file=sys.stderr)
        print("Please check '" + fname
            + "' exclusively uses utf-8 character encoding.", file=sys.stderr)
        sys.exit(1)

    f = TemporaryFile()
    f.write(status.encode('utf-8'))
Ejemplo n.º 3
0
git = GitRepo()

opts = {}
repo_base = git.repo_base()
context = 8
ui = StdioUI()

os.chdir(repo_base)
failing_files = set()

for status, fname in git.status(filter="MA", cached=True):
    if args.verbose:
        print "Checking %s..." % fname
    if status == "M":
        regions = git.staged_regions(fname, context=context)
    else:
        regions = all_regions

    verifiers = [ v(ui, opts, base=repo_base) for v in all_verifiers ]
    for v in verifiers:
        if v.check(fname, regions):
            failing_files.add(fname)

if failing_files:
    print >> sys.stderr
    print >> sys.stderr, "Style checker failed for the following files:"
    for f in failing_files:
        print >> sys.stderr, "\t%s" % f
    print >> sys.stderr
    print >> sys.stderr, \