enable logging in validate command

Turn on logging output, to the console, and add some log statements in
gitutils.

Change-Id: I63c80c9b2d6674d64dbc8b341a36ad51248aa19c
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann
2017-11-15 17:37:30 -05:00
parent a926bf8954
commit 77e0060f62
2 changed files with 16 additions and 0 deletions

View File

@@ -21,11 +21,13 @@ from __future__ import print_function
import argparse
import atexit
import glob
import logging
import os
import os.path
import pkgutil
import re
import shutil
import sys
import tempfile
import jsonschema
@@ -945,6 +947,14 @@ def main():
)
args = parser.parse_args()
# Set up logging, including making some loggers quiet.
logging.basicConfig(
format='%(levelname)s:%(name)s: %(message)s',
stream=sys.stdout,
level=logging.DEBUG,
)
logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING)
filenames = args.input or gitutils.find_modified_deliverable_files()
if not filenames:
print('no modified deliverable files and no arguments, '

View File

@@ -106,6 +106,7 @@ def clone_repo(workdir, repo, ref=None, branch=None):
if branch:
cmd.extend(['--branch', branch])
cmd.append(repo)
LOG.info(' '.join(cmd))
subprocess.check_call(cmd)
@@ -190,7 +191,10 @@ def check_branch_sha(workdir, repo, series, sha):
)
# If the patch is on the named branch, everything is fine.
if remote_match in containing_branches:
LOG.debug('found %s branch', remote_match)
return True
LOG.debug('did not find %s in branches containing %s: %s',
remote_match, sha, containing_branches)
# If the expected branch does not exist yet, this may be a
# late release attempt to create that branch or just a project
# that hasn't branched, yet, and is releasing from master for
@@ -203,10 +207,12 @@ def check_branch_sha(workdir, repo, series, sha):
).decode('utf-8')
)
if (remote_match not in all_branches) and ('master' in containing_branches):
LOG.debug('did not find %s but SHA is on master', remote_match)
return True
# At this point we know the release is not from the required
# branch and it is not from master, which means it is the
# wrong branch and should not be allowed.
LOG.debug('did not find SHA on %s or master', remote_match)
return False
except subprocess.CalledProcessError as e:
LOG.error('failed checking SHA on branch: %s [%s]' % (e, e.output.strip()))