Files
@ 30b5b58cb2dc
Branch filter:
Location: kallithea/scripts/logformat.py - annotation
30b5b58cb2dc
1.7 KiB
text/x-python
git: introduce test_push_new_repo_git to reproduce a hook crash when pushing to empty repos
The crash will be fixed by a later changeset.
Reported on https://bitbucket.org/conservancy/kallithea/issues/323/git-hook-error-on-push-of-first-commit
remote: Traceback (most recent call last):
remote: File "hooks/post-receive", line 36, in <module>
remote: main()
remote: File "hooks/post-receive", line 32, in main
remote: sys.exit(kallithea.lib.hooks.handle_git_post_receive(repo_path, git_stdin_lines))
remote: File "kallithea/lib/hooks.py", line 453, in handle_git_post_receive
remote: git_revs += scm_repo.run_git_command(cmd)[0].splitlines()
remote: File "kallithea/lib/vcs/backends/git/repository.py", line 164, in run_git_command
remote: return self._run_git_command(cmd, **opts)
remote: File "kallithea/lib/vcs/backends/git/repository.py", line 151, in _run_git_command
remote: raise RepositoryError(tb_err)
remote: kallithea.lib.vcs.exceptions.RepositoryError: Couldn't run git command (['git', '-c', 'core.quotepath=false', 'log', 'b991c8d9ae7e66e165fc5eeb297c6843d21915e0', '--reverse', '--pretty=format:%H', '--not', '']).
remote: Original error was:Subprocess exited due to an error:
remote: fatal: ambiguous argument '': unknown revision or path not in the working tree.
remote:
To http://127.0.0.1:44433/new_git_DHAsQQ
* [new branch] master -> master
The crash will be fixed by a later changeset.
Reported on https://bitbucket.org/conservancy/kallithea/issues/323/git-hook-error-on-push-of-first-commit
remote: Traceback (most recent call last):
remote: File "hooks/post-receive", line 36, in <module>
remote: main()
remote: File "hooks/post-receive", line 32, in main
remote: sys.exit(kallithea.lib.hooks.handle_git_post_receive(repo_path, git_stdin_lines))
remote: File "kallithea/lib/hooks.py", line 453, in handle_git_post_receive
remote: git_revs += scm_repo.run_git_command(cmd)[0].splitlines()
remote: File "kallithea/lib/vcs/backends/git/repository.py", line 164, in run_git_command
remote: return self._run_git_command(cmd, **opts)
remote: File "kallithea/lib/vcs/backends/git/repository.py", line 151, in _run_git_command
remote: raise RepositoryError(tb_err)
remote: kallithea.lib.vcs.exceptions.RepositoryError: Couldn't run git command (['git', '-c', 'core.quotepath=false', 'log', 'b991c8d9ae7e66e165fc5eeb297c6843d21915e0', '--reverse', '--pretty=format:%H', '--not', '']).
remote: Original error was:Subprocess exited due to an error:
remote: fatal: ambiguous argument '': unknown revision or path not in the working tree.
remote:
To http://127.0.0.1:44433/new_git_DHAsQQ
* [new branch] master -> master
8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 8bc8366a6874 665dfa112f2c 8bc8366a6874 8bc8366a6874 665dfa112f2c | #!/usr/bin/env python2
import re
import sys
if len(sys.argv) < 2:
print 'Cleanup of superfluous % formatting of log statements.'
print 'Usage:'
print ''' hg revert `hg loc '*.py'|grep -v logformat.py` && scripts/logformat.py `hg loc '*.py'` && hg diff'''
raise SystemExit(1)
logre = r'''
(log\.(?:error|info|warning|debug)
[(][ \n]*
)
%s
(
[ \n]*[)]
)
'''
res = [
# handle % () - keeping spaces around the old %
(re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) \( ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) \) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# handle % without () - keeping spaces around the old %
(re.compile(logre % r'''("[^"]*"|'[^']*') ([\n ]*) % ([\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# remove extra space if it is on next line
(re.compile(logre % r'''("[^"]*"|'[^']*') , (\n [ ]) ([ ][\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# remove extra space if it is on same line
(re.compile(logre % r'''("[^"]*"|'[^']*') , [ ]+ () ( [\n ]+) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* ) ''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
# remove trailing , and space
(re.compile(logre % r'''("[^"]*"|'[^']*') , () ( [\n ]*) ( (?:[^()]|\n)* (?: \( (?:[^()]|\n)* \) (?:[^()]|\n)* )* [^(), \n] ) [ ,]*''', flags=re.MULTILINE|re.VERBOSE), r'\1\2,\3\4\5\6'),
]
for f in sys.argv[1:]:
s = open(f).read()
for r, t in res:
s = r.sub(t, s)
open(f, 'w').write(s)
|