Account for bugfix branches in bifrost-cli

Fall back to the default branch unless an explicit one is provided.

Change-Id: I960fc1ab98f89feaf57d1b0aee7502ab0612a487
This commit is contained in:
Dmitry Tantsur 2020-07-09 13:12:48 +02:00
parent 12bbea5ea6
commit a47db1e302
2 changed files with 14 additions and 6 deletions

View File

@ -34,6 +34,7 @@ COMMON_PARAMS = [
]
BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
PLAYBOOKS = os.path.join(BASE, 'playbooks')
DEFAULT_BRANCH = 'master'
def get_env(extra=None):
@ -74,19 +75,26 @@ def env_setup(args):
def get_release(release):
if release:
if release != 'master' and not release.startswith('stable/'):
if release != DEFAULT_BRANCH and not release.startswith('stable/'):
release = 'stable/%s' % release
return release
else:
try:
gr = configparser.ConfigParser()
gr.read(os.path.join(BASE, '.gitreview'))
release = gr.get('gerrit', 'defaultbranch', fallback='master')
release = gr.get('gerrit', 'defaultbranch',
fallback=DEFAULT_BRANCH)
except (FileNotFoundError, configparser.Error):
log('Cannot read .gitreview, falling back to release',
DEFAULT_BRANCH)
return DEFAULT_BRANCH
else:
if release.startswith('bugfix/'):
log('Bugfix branch', release, 'cannot be used as a release, '
'falling back to', DEFAULT_BRANCH)
return DEFAULT_BRANCH
log('Using release', release, 'detected from the checkout')
return release
except (FileNotFoundError, configparser.Error):
log('Cannot read .gitreview, falling back to release "master"')
return 'master'
def cmd_testenv(args):

View File

@ -137,7 +137,7 @@ fi
if [ ${CLI_TEST} = "true" ]; then
# FIXME(dtantsur): bifrost-cli does not use opendev-provided repos.
../bifrost-cli --debug install --release ${ZUUL_BRANCH:-master} --testenv
../bifrost-cli --debug install --testenv
CLOUD_CONFIG+=" -e skip_install=true"
CLOUD_CONFIG+=" -e skip_package_install=true"
CLOUD_CONFIG+=" -e skip_bootstrap=true"