Fix checking only a specific namespace
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
1320c7f424
commit
8a180b87c0
1 changed files with 31 additions and 24 deletions
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This script goes through all the git repos in dist-git and adjust their
|
This script goes through all the git repos in dist-git and adjust their
|
||||||
git post-receive hook so they are always as desired.
|
git hook so they are always as expected.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -58,6 +57,32 @@ def is_valid_hook(hook, target_link):
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
def process_namespace(namespace):
|
||||||
|
""" Process all the git repo in a specified namespace. """
|
||||||
|
target_link = _target_link
|
||||||
|
if namespace == 'forks':
|
||||||
|
target_link = _target_link_forks
|
||||||
|
|
||||||
|
print('Processing: %s' % namespace)
|
||||||
|
path = os.path.join(_base_path, namespace)
|
||||||
|
if not os.path.isdir(path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
|
# Don't go down the .git repos
|
||||||
|
if dirpath.endswith('.git'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for repo in dirnames:
|
||||||
|
repo_path = os.path.join(dirpath, repo)
|
||||||
|
if not repo_path.endswith('.git'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
hook = os.path.join(repo_path, 'hooks', 'post-receive')
|
||||||
|
if not is_valid_hook(hook, target_link) and not args.check:
|
||||||
|
fix_link(hook, target_link)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
""" This is the main method of the program.
|
""" This is the main method of the program.
|
||||||
It parses the command line arguments. If a specific repo was specified
|
It parses the command line arguments. If a specific repo was specified
|
||||||
|
@ -85,32 +110,14 @@ def main():
|
||||||
if not is_valid_hook(hook, target_link) and not args.check:
|
if not is_valid_hook(hook, target_link) and not args.check:
|
||||||
fix_link(hook, target_link)
|
fix_link(hook, target_link)
|
||||||
|
|
||||||
|
elif args.namespace:
|
||||||
|
process_namespace(args.namespace)
|
||||||
else:
|
else:
|
||||||
# Check all repos
|
# Check all repos
|
||||||
for namespace in namespaces:
|
for namespace in namespaces:
|
||||||
target_link = _target_link
|
process_namespace(namespace)
|
||||||
if namespace == 'forks':
|
|
||||||
target_link = _target_link_forks
|
|
||||||
|
|
||||||
print('Processing: %s' % namespace)
|
|
||||||
path = os.path.join(_base_path, namespace)
|
|
||||||
if not os.path.isdir(path):
|
|
||||||
continue
|
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk(path):
|
|
||||||
# Don't go down the .git repos
|
|
||||||
if dirpath.endswith('.git'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
for repo in dirnames:
|
|
||||||
repo_path = os.path.join(dirpath, repo)
|
|
||||||
if not repo_path.endswith('.git'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
hook = os.path.join(repo_path, 'hooks', 'post-receive')
|
|
||||||
if not is_valid_hook(hook, target_link) and not args.check:
|
|
||||||
fix_link(hook, target_link)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue