Remove global vars from check_valid_gerrit_projects.py

Replace global var with local variable usage.

Change-Id: I44640a274947f9be84232fb172f8247c15dbaee5
This commit is contained in:
Andreas Jaeger 2015-10-22 11:00:02 +02:00
parent 106f6b80e2
commit 10b18599e3

View File

@ -23,8 +23,6 @@ import sys
import tempfile import tempfile
import yaml import yaml
found_errors = 0
@contextlib.contextmanager @contextlib.contextmanager
def tempdir(): def tempdir():
@ -36,7 +34,7 @@ def tempdir():
def check_repo(repo_path): def check_repo(repo_path):
global found_errors found_errors = 0
print("Checking git repo '%s':" % repo_path) print("Checking git repo '%s':" % repo_path)
with tempdir() as repopath: with tempdir() as repopath:
@ -59,10 +57,11 @@ def check_repo(repo_path):
print(" Found no tags.") print(" Found no tags.")
# Just an empty line for nicer formatting # Just an empty line for nicer formatting
print("") print("")
return found_errors
def main(): def main():
global found_errors found_errors = 0
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', parser.add_argument('-v', '--verbose',
@ -124,7 +123,7 @@ def main():
# but not git@ # but not git@
upstream = p.get('upstream') upstream = p.get('upstream')
if upstream and 'track-upstream' not in p.get('options', []): if upstream and 'track-upstream' not in p.get('options', []):
check_repo(upstream) found_errors += check_repo(upstream)
if upstream: if upstream:
for prefix in VALID_SCHEMES: for prefix in VALID_SCHEMES:
if upstream.startswith(prefix): if upstream.startswith(prefix):