always look for the .gitreview file in root of repo

The build may not be happening in the root of the repository, so look
for that directory explicitly before trying to read the .gitreview
file.

Change-Id: I75e952c567d8387d3c620a2b005474ad2441f086
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-06-25 14:58:03 -04:00
parent ae47423826
commit 9a5c51991d
1 changed files with 11 additions and 2 deletions

View File

@ -124,9 +124,18 @@ def _get_series_name():
"Return string name of release series, or 'latest'"
global _series
if _series is None:
try:
git_root_dir = subprocess.check_output(
['git', 'rev-parse', '--show-toplevel'],
).decode('utf-8').strip()
except Exception:
logger.warning('Cannot find git top directory, assuming "."')
git_root_dir = '.'
parser = configparser.ConfigParser()
# TODO(stephenfin): Should this be relative to some directory?
parser.read('.gitreview')
in_file = os.path.join(git_root_dir, '.gitreview')
parsed = parser.read(in_file)
if not parsed:
logger.info('No {} found'.format(in_file))
try:
branch = parser.get('gerrit', 'defaultbranch')
except configparser.Error: