def get_last_kernel_revision_obj():
session = Session()
logger.debug('Getting kernel revision from persistence')
+ if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix'):
+ persistance_identifier = 'master'
+ elif GIT_BRANCH_NAME.startswith('release'):
+ persistance_identifier = 'release'
+ else
+ persistance_identifier = 'develop'
+
try:
answ = session.query(KernelVersion).filter(
- KernelVersion.branch_name == GIT_BRANCH_NAME).one()
+ KernelVersion.branch_name == persistance_identifier).one()
except NoResultFound:
- session.add(KernelVersion(GIT_BRANCH_NAME, 0))
+ session.add(KernelVersion(persistance_identifier, 0))
session.commit()
answ = session.query(KernelVersion).filter(
- KernelVersion.branch_name == GIT_BRANCH_NAME).one()
+ KernelVersion.branch_name == persistance_identifier).one()
finally:
session.close()
logger.info(
- 'Got this Kernel revision for branch %s: %s'
- %(GIT_BRANCH_NAME, answ)
+ 'Got this Kernel revision for branch %s and persistance_identifier %s: %s'
+ %(GIT_BRANCH_NAME, persistance_identifier, answ)
)
return answ