Skip to content
Snippets Groups Projects
Commit 0fe2d7bb authored by Tobias Leibner's avatar Tobias Leibner
Browse files

[hooks] apply python formatter

parent 2e486a51
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""
Small delegating Python script to allow multiple hooks in a git repository.
......@@ -50,7 +49,6 @@ from subprocess import Popen, PIPE
from os import access, listdir, X_OK, environ
from os.path import isfile, isdir, abspath, normpath, dirname, join, basename
GIT_HOOKS = [
'applypatch-msg',
'commit-msg',
......@@ -71,10 +69,7 @@ def setup_logging():
from logging import basicConfig, DEBUG, ERROR
FORMAT = (
' %(log_color)s%(levelname)-8s%(reset)s | '
'%(log_color)s%(message)s%(reset)s'
)
FORMAT = (' %(log_color)s%(levelname)-8s%(reset)s | ' '%(log_color)s%(message)s%(reset)s')
logging_kwargs = {
'level': DEBUG if environ.get('GIT_HOOKS_DEBUG', False) else ERROR,
......@@ -117,9 +112,7 @@ def main():
# Gather scripts to call
files = [join(hooks_dir, f) for f in listdir(hooks_dir)]
hooks = sorted(
[h for h in files if isfile(h) and access(h, X_OK)]
)
hooks = sorted([h for h in files if isfile(h) and access(h, X_OK)])
if not hooks:
log.warning('No sub-hooks found for {}.'.format(hook_type))
exit(0)
......
......@@ -22,11 +22,10 @@ def _resolve(path):
broken = []
files = subprocess.check_output(['git', 'ls-files'],
universal_newlines=True)
files = subprocess.check_output(['git', 'ls-files'], universal_newlines=True)
root = os.getcwd()
for filename in files.splitlines():
path = Path(os.path.join(root,filename))
path = Path(os.path.join(root, filename))
if path.is_symlink():
target = _resolve(path)
# exists already checks if the pointed to file is there
......
......@@ -10,7 +10,6 @@ from configparser import ConfigParser
from functools import partial
import logging
get_output = partial(subprocess.check_output, universal_newlines=True)
root = Path(get_output(['git', 'rev-parse', '--show-toplevel']).strip())
supermod = Path(root, '..')
......@@ -61,9 +60,8 @@ def for_module(cf, mod, section=None):
cf = ConfigParser()
for_module(cf, supermod, 'supermodule')
os.chdir(supermod)
for s in [Path(s) for s in
get_output(['git', 'submodule', '--quiet', 'foreach', 'pwd'],
env=get_env(supermod)).split()]:
for s in [
Path(s) for s in get_output(['git', 'submodule', '--quiet', 'foreach', 'pwd'], env=get_env(supermod)).split()
]:
for_module(cf, s)
_save_config(supermod_name, root.parts[-1], cf)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment