--- a/checker.py Mon Jul 25 14:03:08 2016 +0800
+++ b/checker.py Mon Jul 25 15:28:27 2016 +0800
+def run_git(args, **kwargs):
+ env = kwargs.pop('env', {})
+ env.update({'LC_ALL': 'en_US.UTF-8'})
+ return run(['git'] + args, env=env, **kwargs)
+def run_hg(args, **kwargs):
+ env = kwargs.pop('env', {})
+ env.update({'HGPLAIN': '1'})
+ return run(['hg'] + args, env=env, **kwargs)
def read_linter_config(name, path=rel('linters')):
fd = open(os.path.join(path, '{}.yml'.format(name)))
def git_clone(url, dest):
- return run(['git', 'clone', url, dest])
+ return run_git(['clone', url, dest])
- return run(['hg', 'clone', url, dest])
+ return run_hg(['clone', url, dest])
def git_checkout(commit):
- return run(['git', 'checkout', commit])
+ return run_git(['checkout', commit])
- return run(['hg', 'update', commit])
+ return run_hg(['update', commit])
- return run(['git', 'status'])
+ return run_git(['status'])
- return run(['hg', 'sum'])
+ return run_hg(['summary'])
r'# C&O commit date: %ai%n'
r'# C&O commit author: %aN%n'
r'# C&O commit message: %s%n')
- return run(['git', 'show', '-q', '--format=format:' + template], silent=True)
+ return run_git(['show', '-q', '--format=format:' + template], silent=True)
r'# C&O commit date: {date|isodatesec}\n'
r'# C&O commit author: {author|person}\n'
r'# C&O commit message: {desc|firstline}\n')
- return run(['hg', 'log', '-r', '.', '-T', template], silent=True)
+ return run_hg(['log', '-r', '.', '-T', template], silent=True)
def git_files(include, exclude):
- cmd = ['git', 'ls-files']
- files = run(cmd, silent=True, get_output=True)
+ files = run_git(cmd, silent=True, get_output=True)
files = files.splitlines()
def hg_files(include, exclude):
- files = run(cmd, silent=True, get_output=True, ignore_codes=(1,))
+ files = run_hg(cmd, silent=True, get_output=True, ignore_codes=(1,))
files = files.splitlines()
print('# C&O task: clone')
print('# C&O project URL: {}'.format(config['url']))
- if config['scm'] == 'hg':
- os.environ['HGPLAIN'] = '1'
if config['scm'] == 'git':
if not git_clone(config['url'], source):
def wrapper(config, args):
print('# C&O job started: {}'.format(timestamp()))
- os.environ.update({'LC_ALL': 'en_US.UTF-8'})
tmp = mkdtemp(prefix='candolint.')
if not execute(tmp, config, args):