diff options
6 files changed, 69 insertions, 29 deletions
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; } diff --git a/extensions/TryAutoLand/bin/TryAutoLand.updateStatus.pl b/extensions/TryAutoLand/bin/TryAutoLand.updateStatus.pl index faa6a3289..4a8f92089 100644 --- a/extensions/TryAutoLand/bin/TryAutoLand.updateStatus.pl +++ b/extensions/TryAutoLand/bin/TryAutoLand.updateStatus.pl @@ -47,10 +47,11 @@ print "Successfully logged in.\n"; ################################### my $attach_id = shift; +my $action = shift; my $status = shift; -$call = $rpc->call('TryAutoLand.updateStatus', - { attach_id => $attach_id, status => $status }); +$call = $rpc->call('TryAutoLand.update', + { attach_id => $attach_id, action => $action, status => $status }); my $result = ""; if ( $call->faultstring ) { diff --git a/extensions/TryAutoLand/bin/TryAutoLand.updateStatus_json.pl b/extensions/TryAutoLand/bin/TryAutoLand.updateStatus_json.pl index 28c57e3d7..f39b55229 100644 --- a/extensions/TryAutoLand/bin/TryAutoLand.updateStatus_json.pl +++ b/extensions/TryAutoLand/bin/TryAutoLand.updateStatus_json.pl @@ -17,8 +17,7 @@ my $rpc = new JSON::RPC::Client; $rpc->ua->ssl_opts(verify_hostname => 0); -my $uri = "https://bugzilla-stage-tip.mozilla.org/jsonrpc.cgi"; -#my $uri = "http://fedora/autoland/jsonrpc.cgi"; +my $uri = "http://fedora/726193/jsonrpc.cgi"; #$rpc->ua->cookie_jar($cookie_jar); @@ -43,10 +42,12 @@ my $uri = "https://bugzilla-stage-tip.mozilla.org/jsonrpc.cgi"; ################################### my $attach_id = shift; +my $action = shift; my $status = shift; -$result = $rpc->call($uri, { method => 'TryAutoLand.updateStatus', - params => { attach_id => $attach_id, +$result = $rpc->call($uri, { method => 'TryAutoLand.update', + params => { attach_id => $attach_id, + action => $action, status => $status, Bugzilla_login => $username, Bugzilla_password => $password } }); diff --git a/extensions/TryAutoLand/lib/WebService.pm b/extensions/TryAutoLand/lib/WebService.pm index 3ccb246d6..1088386dd 100644 --- a/extensions/TryAutoLand/lib/WebService.pm +++ b/extensions/TryAutoLand/lib/WebService.pm @@ -110,14 +110,17 @@ sub getBugs { ]; } -# TryAutoLand.updateStatus({ attach_id => $attach_id, status => $status }) +# TryAutoLand.update({ attach_id => $attach_id, action => $action, status => $status }) # Let's BMO know if a patch has landed or not and BMO will update the auto_land table accordingly -# $status will be a predetermined set of pending/complete codes -- when pending, the UI for submitting -# autoland will be locked and once complete status update occurs the UI can be unlocked and this entry -# can be removed from tracking by WebService API +# If $action eq 'status', $status will be a predetermined set of status values -- when waiting, +# the UI for submitting autoland will be locked and once complete status update occurs or the +# mapping is removed, the UI can be unlocked for the $attach_id # Allowed statuses: waiting, running, failed, or success +# +# If $action eq 'remove', the attach_id will be removed from the mapping table and the UI +# will be unlocked for the $attach_id. -sub updateStatus { +sub update { my ($self, $params) = @_; my $user = Bugzilla->user; my $dbh = Bugzilla->dbh; @@ -127,15 +130,25 @@ sub updateStatus { object => "autoland_attachments" }); } - foreach my $param ('attach_id', 'status') { + foreach my $param ('attach_id', 'action') { defined $params->{$param} - || ThrowUserError('param_required', + || ThrowCodeError('param_required', { param => $param }); } + my $action = delete $params->{'action'}; my $attach_id = delete $params->{'attach_id'}; my $status = delete $params->{'status'}; - + + if ($action eq 'status' && !$status) { + ThrowCodeError('param_required', { param => 'status' }); + } + + grep($_ eq $action, ('remove', 'status')) + || ThrowUserError('autoland_update_invalid_action', + { action => $action, + valid => ["remove", "status"] }); + my $attachment = Bugzilla::Attachment->new($attach_id); $attachment || ThrowUserError('autoland_invalid_attach_id', @@ -155,15 +168,22 @@ sub updateStatus { || ThrowUserError('autoland_invalid_attach_id', { attach_id => $attach_id }); - # Update the status - $attachment->autoland_update_status($status); + if ($action eq 'status') { + # Update the status + $attachment->autoland_update_status($status); + + return { + id => $self->type('int', $attachment->id), + who => $self->type('string', $attachment->autoland_who->login), + status => $self->type('string', $attachment->autoland_status), + status_when => $self->type('dateTime', $attachment->autoland_status_when), + }; + } + elsif ($action eq 'remove') { + $attachment->autoland_remove(); + } - return { - id => $self->type('int', $attachment->id), - who => $self->type('string', $attachment->autoland_who->login), - status => $self->type('string', $attachment->autoland_status), - status_when => $self->type('dateTime', $attachment->autoland_status_when), - }; + return {}; } 1; diff --git a/extensions/TryAutoLand/template/en/default/hook/bug/edit-after_custom_fields.html.tmpl b/extensions/TryAutoLand/template/en/default/hook/bug/edit-after_custom_fields.html.tmpl index f9bb8ef5e..ed6224afe 100644 --- a/extensions/TryAutoLand/template/en/default/hook/bug/edit-after_custom_fields.html.tmpl +++ b/extensions/TryAutoLand/template/en/default/hook/bug/edit-after_custom_fields.html.tmpl @@ -6,7 +6,7 @@ # defined by the Mozilla Public License, v. 2.0. #%] -[% IF user.in_group('hg-try') %] +[% IF user.in_group('autoland') %] [% autoland_attachments = [] %] [% autoland_waiting = 0 %] [% autoland_running = 0 %] diff --git a/extensions/TryAutoLand/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/TryAutoLand/template/en/default/hook/global/user-error-errors.html.tmpl index b2aac99fe..c12950dcf 100644 --- a/extensions/TryAutoLand/template/en/default/hook/global/user-error-errors.html.tmpl +++ b/extensions/TryAutoLand/template/en/default/hook/global/user-error-errors.html.tmpl @@ -9,7 +9,8 @@ [% IF error == "autoland_invalid_status" %] [% title = "AutoLand Invalid Status" %] The status '[% status FILTER html %]' is not a valid - status for the AutoLand extension. + status for the AutoLand extension. Valid statuses + are [% valid.join(', ') FILTER html %]. [% ELSIF error == "autoland_invalid_attach_id" %] [% title = "AutoLand Invalid Attachment ID" %] @@ -17,12 +18,16 @@ a valid id for the AutoLand extension. [% ELSIF error == "autoland_empty_try_syntax" %] - [% title = "Autoland Empty Try Syntax" %] + [% title = "AutoLand Empty Try Syntax" %] You cannot have a value for Branches and have an empty Try Syntax value. [% ELSIF error == "autoland_empty_branches" %] - [% title = "Autoland Empty Branches" %] + [% title = "AutoLand Empty Branches" %] You cannot check one or more patches for AutoLanding and have an empty Branches value. +[% ELSIF error == "autoland_update_invalid_action" %] + [% title = "AutoLand Update Invalid Action" %] + The action '[% action FILTER html %]' is not a valid action. + Valid actions are [% valid.join(', ') FILTER html %]. [% END %] |