Mercurial > bitten > bitten-test
diff bitten/trac_ext/web_ui.py @ 184:fbf949f4c706
Allow invalidation of builds from the web interface. This results in the build being reset to ''PENDING'' status, and all build logs, slave information and reports deleted. Basically initiates a rebuild for a specific revision and target platform.
author | cmlenz |
---|---|
date | Wed, 31 Aug 2005 16:43:05 +0000 |
parents | cafe294fa835 |
children | da2a2e9a8f71 |
line wrap: on
line diff
--- a/bitten/trac_ext/web_ui.py +++ b/bitten/trac_ext/web_ui.py @@ -84,7 +84,7 @@ # IRequestHandler methods def match_request(self, req): - match = re.match(r'/build(?:/([\w.-]+))?$', req.path_info) + match = re.match(r'/build(?:/([\w.-]+))?/?$', req.path_info) if match: if match.group(1): req.args['config'] = match.group(1) @@ -417,6 +417,11 @@ build = Build.fetch(self.env, build_id, db=db) assert build, 'Build %s does not exist' % build_id + if req.method == 'POST': + if req.args.get('action') == 'invalidate': + self._do_invalidate(req, build, db) + req.redirect(self.env.href.build(build.config, build.id)) + add_link(req, 'up', self.env.href.build(build.config), 'Build Configuration') status2title = {Build.SUCCESS: 'Success', Build.FAILURE: 'Failure', @@ -441,6 +446,7 @@ 'reports': self._render_reports(req, build, step) }) req.hdf['build.steps'] = steps + req.hdf['build.can_delete'] = req.perm.has_permission('BUILD_DELETE') add_stylesheet(req, 'bitten/bitten.css') return 'bitten_build.cs', None @@ -477,6 +483,25 @@ # Internal methods + def _do_invalidate(self, req, build, db): + self.log.info('Invalidating build %d', build.id) + + for step in BuildStep.select(self.env, build=build.id, db=db): + step.delete(db=db) + + store = ReportStore(self.env) + store.delete_reports(build=build) + + build.slave = None + build.started = build.stopped = 0 + build.status = Build.PENDING + build.slave_info = {} + build.update() + + db.commit() + + req.redirect(self.env.href.build(build.config)) + def _render_log(self, req, build, step): items = [] for log in BuildLog.select(self.env, build=build.id, step=step.name):