From 64204296d23ca9983b7a39b11e0c3bed4b23f8a2 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Thu, 29 Mar 2012 15:58:58 -0400 Subject: Bug 740177 - Update the TryAutoLand WebService to allow removal of autoland patches r=glob --- extensions/TryAutoLand/Extension.pm | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'extensions/TryAutoLand/Extension.pm') diff --git a/extensions/TryAutoLand/Extension.pm b/extensions/TryAutoLand/Extension.pm index d3702af7f..40dbb70d9 100644 --- a/extensions/TryAutoLand/Extension.pm +++ b/extensions/TryAutoLand/Extension.pm @@ -29,6 +29,7 @@ BEGIN { *Bugzilla::Attachment::autoland_status = \&_autoland_attachment_status; *Bugzilla::Attachment::autoland_status_when = \&_autoland_attachment_status_when; *Bugzilla::Attachment::autoland_update_status = \&_autoland_attachment_update_status; + *Bugzilla::Attachment::autoland_remove = \&_autoland_attachment_remove; } sub db_schema_abstract_schema { @@ -179,7 +180,8 @@ sub _autoland_attachment_update_status { grep($_ eq $status, VALID_STATUSES) || ThrowUserError('autoland_invalid_status', - { status => $status }); + { status => $status, + valid => [ VALID_STATUSES ] }); if ($self->autoland_status ne $status) { my $timestamp = $dbh->selectrow_array("SELECT LOCALTIMESTAMP(0)"); @@ -193,6 +195,17 @@ sub _autoland_attachment_update_status { return 1; } +sub _autoland_attachment_remove { + my ($self) = @_; + my $dbh = Bugzilla->dbh; + return undef if !$self->autoland_checked; + $dbh->do("DELETE FROM autoland_attachments WHERE attach_id = ?", undef, $self->id); + delete $self->{'autoland_checked'}; + delete $self->{'autoland_who'}; + delete $self->{'autoland_status'}; + delete $self->{'autoland_status_when'}; +} + sub object_end_of_update { my ($self, $args) = @_; my $object = $args->{'object'}; @@ -201,7 +214,7 @@ sub object_end_of_update { my $cgi = Bugzilla->cgi; my $params = Bugzilla->input_params; - return if !$user->in_group('hg-try'); + return if !$user->in_group('autoland'); if ($object->isa('Bugzilla::Bug')) { # First make any needed changes to the branches and try_syntax fields @@ -291,7 +304,7 @@ sub template_before_process { my $vars = $args->{'vars'}; # in the header we just need to set the var to ensure the css gets included - if ($file eq 'bug/show-header.html.tmpl' && Bugzilla->user->in_group('hg-try') ) { + if ($file eq 'bug/show-header.html.tmpl' && Bugzilla->user->in_group('autoland') ) { $vars->{'autoland'} = 1; } -- cgit v1.2.3-24-g4f1b