def getinfo(package, local=False, dev_mode=False, head_only=False, db_connection=None, type="rpm"): project = package["name"] since = "-1" session = getSession(db_connection) commit = getLastProcessedCommit(session, project, type=type) if commit: # If we have switched source branches, we want to behave # as if no previous commits had been built, and only build # the last one if commit.commit_branch == getsourcebranch(package): # This will return all commits since the last handled commit # including the last handled commit, remove it later if needed. since = "--after=%d" % (commit.dt_commit) else: # The last processed commit belongs to a different branch. Just # in case, let's check if we built a previous commit from the # current branch commit = getLastBuiltCommit(session, project, getsourcebranch(package), type=type) if commit: logger.info("Last commit belongs to another branch, but" " we're ok with that") since = "--after=%d" % (commit.dt_commit) # In any case, we just want to build the last commit, if any head_only = True project_toprocess, skipped = pkginfo.getinfo(project=project, package=package, since=since, local=local, dev_mode=dev_mode, type=type) closeSession(session) # If since == -1, then we only want to trigger a build for the # most recent change if since == "-1" or head_only: del project_toprocess[:-1] return project_toprocess, package, skipped
def getinfo(package, local=False, dev_mode=False, head_only=False, db_connection=None, type="rpm"): project = package["name"] since = "-1" session = getSession(db_connection) commit = getLastProcessedCommit(session, project, type=type) if commit: # If we have switched source branches, we want to behave # as if no previous commits had been built, and only build # the last one if commit.commit_branch == getsourcebranch(package): # This will return all commits since the last handled commit # including the last handled commit, remove it later if needed. since = "--after=%d" % (commit.dt_commit) else: # The last processed commit belongs to a different branch. Just # in case, let's check if we built a previous commit from the # current branch commit = getLastBuiltCommit(session, project, getsourcebranch(package), type=type) if commit: logger.info("Last commit belongs to another branch, but" " we're ok with that") since = "--after=%d" % (commit.dt_commit) # In any case, we just want to build the last commit, if any head_only = True project_toprocess = pkginfo.getinfo(project=project, package=package, since=since, local=local, dev_mode=dev_mode, type=type) closeSession(session) # If since == -1, then we only want to trigger a build for the # most recent change if since == "-1" or head_only: del project_toprocess[:-1] return project_toprocess, package
def test_newproject(self): commit = \ db.getLastBuiltCommit(self.session, 'python-newproject', 'master') self.assertEqual(commit, None)
def test_withretry(self): # In our sample data the most recent of these has status == RETRY commit = \ db.getLastBuiltCommit(self.session, 'python-tripleoclient', 'master') self.assertEqual(commit.dt_build, 1444033941)
def test_noretry(self): commit = \ db.getLastBuiltCommit(self.session, 'python-pysaml2', 'master') self.assertEqual(commit.dt_build, 1444139517)