From c295f923f8a63d6117da1d8bea3ac445b3da0ca1 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Wed, 26 Oct 2011 19:14:03 +0200 Subject: [PATCH] store persistence correctly for changing branch names --- kernel_build.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/kernel_build.py b/kernel_build.py index 3877f9b..66b33a5 100644 --- a/kernel_build.py +++ b/kernel_build.py @@ -91,20 +91,27 @@ Base.metadata.create_all(engine) 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 -- 2.39.5