From nobody Fri Apr 19 02:24:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531311902859979.7419101189812; Wed, 11 Jul 2018 05:25:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 110B73082A40; Wed, 11 Jul 2018 12:25:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFFDC60910; Wed, 11 Jul 2018 12:25:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E287E4BB78; Wed, 11 Jul 2018 12:25:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6BCOxeY000697 for ; Wed, 11 Jul 2018 08:24:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 74561111DD13; Wed, 11 Jul 2018 12:24:59 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-148.ams2.redhat.com [10.36.117.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC8DE111DD0B; Wed, 11 Jul 2018 12:24:56 +0000 (UTC) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 11 Jul 2018 14:24:55 +0200 Message-Id: <20180711122455.21112-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: patchew-devel@redhat.com Cc: Shubham Jain Subject: [Patchew-devel] [PATCH] fix git Results that are incorrect empty strings X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 11 Jul 2018 12:25:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Due to an error in the migration to populate Results for git, the data field was set to an empty string rather than an empty dictionary. Fix this with another migration on top. For simplicity I am using raw SQL here. Signed-off-by: Paolo Bonzini Reported-by: Shubham Jain --- api/migrations/0028_populate_git_results.py | 4 ++-- api/migrations/0032_fix_git_results.py | 20 ++++++++++++++++++++ mods/git.py | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 api/migrations/0032_fix_git_results.py diff --git a/api/migrations/0028_populate_git_results.py b/api/migrations/0= 028_populate_git_results.py index 482641a..bc17e08 100644 --- a/api/migrations/0028_populate_git_results.py +++ b/api/migrations/0028_populate_git_results.py @@ -34,6 +34,7 @@ def result_from_properties(apps, schema_editor): log_entry =3D LogEntry(data_xz=3Dlog_xz) log_entry.save() r.log_entry =3D log_entry + data =3D {} if get_property(MessageProperty, "git.apply-failed", message= =3Dm): r.status =3D api.models.Result.FAILURE else: @@ -41,7 +42,6 @@ def result_from_properties(apps, schema_editor): git_tag =3D get_property(MessageProperty, "git.tag", messa= ge=3Dm) git_url =3D get_property(MessageProperty, "git.url", messa= ge=3Dm) git_base =3D get_property(MessageProperty, "git.base", mes= sage=3Dm) - data =3D {} if git_repo and git_tag: data['repo'] =3D git_repo data['tag'] =3D 'refs/tags/' + git_tag @@ -49,8 +49,8 @@ def result_from_properties(apps, schema_editor): data['url'] =3D git_url if git_base: data['base'] =3D git_base - r.data =3D data r.status =3D api.models.Result.SUCCESS + r.data =3D data else: status =3D api.models.Result.PENDING r.last_update =3D datetime.datetime.utcnow() diff --git a/api/migrations/0032_fix_git_results.py b/api/migrations/0032_f= ix_git_results.py new file mode 100644 index 0000000..2438126 --- /dev/null +++ b/api/migrations/0032_fix_git_results.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.13 on 2018-07-11 12:17 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies =3D [ + ('api', '0031_auto_20180520_1654'), + ] + + operations =3D [ + # Due to an error in the migration to populate Results for git, th= e data + # field was set to an empty string rather than an empty dictionary= . This + # has been fixed now in the migration, but the fix is also include= d as a + # separate migration in case the buggy data is found in the databa= se. + migrations.RunSQL("update api_result set data =3D '{}' where name= =3D'git' and data =3D '\"\"'") + ] diff --git a/mods/git.py b/mods/git.py index a2b6d86..924547a 100644 --- a/mods/git.py +++ b/mods/git.py @@ -276,10 +276,10 @@ class ApplierReportView(APILoginRequiredView): r =3D Message.objects.series_heads().get(project=3Dp, message_id=3Dmessage_id).gi= t_result r.log =3D log + data =3D {} if failed: r.status =3D Result.FAILURE else: - data =3D {} data['repo'] =3D repo data['tag'] =3D 'refs/tags/' + tag if url: @@ -289,6 +289,6 @@ class ApplierReportView(APILoginRequiredView): data['url'] =3D url_template.replace("%t", tag) if base: data['base'] =3D base - r.data =3D data r.status =3D Result.SUCCESS + r.data =3D data r.save() --=20 2.17.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel