Download:
child 183:c90fd4f23c9e
parent 181:379525df9cdb
182:139d26bef571
Anton Shestakov <av6@dwimlabs.net>, Mon, 25 Jul 2016 15:28:27 +0800
checker: limit using custom environment to scm tools

1 файлов изменено, 24 вставок(+), 15 удалений(-) [+]
checker.py file | annotate | diff | comparison | revisions
--- a/checker.py Mon Jul 25 14:03:08 2016 +0800
+++ b/checker.py Mon Jul 25 15:28:27 2016 +0800
@@ -48,6 +48,18 @@
return False
+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')):
try:
fd = open(os.path.join(path, '{}.yml'.format(name)))
@@ -89,27 +101,27 @@
def git_clone(url, dest):
- return run(['git', 'clone', url, dest])
+ return run_git(['clone', url, dest])
def hg_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])
def hg_update(commit):
- return run(['hg', 'update', commit])
+ return run_hg(['update', commit])
def git_status():
- return run(['git', 'status'])
+ return run_git(['status'])
def hg_summary():
- return run(['hg', 'sum'])
+ return run_hg(['summary'])
def git_show():
@@ -118,7 +130,7 @@
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)
def hg_log():
@@ -127,13 +139,13 @@
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']
+ cmd = ['ls-files']
cmd.extend(include)
- files = run(cmd, silent=True, get_output=True)
+ files = run_git(cmd, silent=True, get_output=True)
if files is not False:
files = files.splitlines()
for e in exclude:
@@ -142,12 +154,12 @@
def hg_files(include, exclude):
- cmd = ['hg', 'files']
+ cmd = ['files']
for pat in include:
cmd.extend(('-I', pat))
for pat in exclude:
cmd.extend(('-X', pat))
- files = run(cmd, silent=True, get_output=True, ignore_codes=(1,))
+ files = run_hg(cmd, silent=True, get_output=True, ignore_codes=(1,))
if files is not False:
files = files.splitlines()
return files
@@ -162,8 +174,6 @@
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):
@@ -263,7 +273,6 @@
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):