mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-14 04:50:20 -06:00
replaced str concat with .write_line(); replaced \t with spaces; removed trailing space in logs
This commit is contained in:
@@ -37,22 +37,32 @@ def _log_and_exit(msg, exc, formatted):
|
||||
log_path = os.path.join(store.directory, 'pre-commit.log')
|
||||
output.write_line('Check the log at {}'.format(log_path))
|
||||
|
||||
meta_info_msg = '### version information\n```\n'
|
||||
meta_info_msg += 'pre-commit.version: {}\n'.format(C.VERSION)
|
||||
meta_info_msg += 'sys.version: \n{}\n'.format(
|
||||
'\n'.join(
|
||||
[
|
||||
'\t{}'.format(line)
|
||||
for line in sys.version.splitlines()
|
||||
],
|
||||
),
|
||||
)
|
||||
meta_info_msg += 'sys.executable: {}\n'.format(sys.executable)
|
||||
meta_info_msg += 'os.name: {}\n'.format(os.name)
|
||||
meta_info_msg += 'sys.platform: {}\n```\n'.format(sys.platform)
|
||||
meta_info_msg += '### error information\n```\n'
|
||||
with open(log_path, 'wb') as log:
|
||||
output.write(meta_info_msg, stream=log)
|
||||
output.write_line(
|
||||
'### version information\n```', stream=log,
|
||||
)
|
||||
output.write_line(
|
||||
'pre-commit.version: {}'.format(C.VERSION), stream=log,
|
||||
)
|
||||
output.write_line(
|
||||
'sys.version:\n{}'.format(
|
||||
'\n'.join(
|
||||
[
|
||||
' {}'.format(line)
|
||||
for line in sys.version.splitlines()
|
||||
],
|
||||
),
|
||||
),
|
||||
stream=log,
|
||||
)
|
||||
output.write_line(
|
||||
'sys.executable: {}'.format(sys.executable), stream=log,
|
||||
)
|
||||
output.write_line('os.name: {}'.format(os.name), stream=log)
|
||||
output.write_line(
|
||||
'sys.platform: {}\n```'.format(sys.platform), stream=log,
|
||||
)
|
||||
output.write_line('### error information\n```', stream=log)
|
||||
output.write(error_msg, stream=log)
|
||||
output.write_line(formatted, stream=log)
|
||||
output.write('\n```\n', stream=log)
|
||||
|
||||
@@ -115,7 +115,7 @@ def test_log_and_exit(cap_out, mock_store_dir):
|
||||
r'^### version information\n'
|
||||
r'```\n'
|
||||
r'pre-commit.version: \d+\.\d+\.\d+\n'
|
||||
r'sys.version: (.*\n)*'
|
||||
r'sys.version:\n( .*\n)*'
|
||||
r'sys.executable: .*\n'
|
||||
r'os.name: .*\n'
|
||||
r'sys.platform: .*\n'
|
||||
|
||||
Reference in New Issue
Block a user