diff --git a/api/migrations/0028_populate_git_results.py b/api/migrations/0028_populate_git_results.py index 482641a1..bc17e08c 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 = LogEntry(data_xz=log_xz) log_entry.save() r.log_entry = log_entry + data = {} if get_property(MessageProperty, "git.apply-failed", message=m): r.status = api.models.Result.FAILURE else: @@ -41,7 +42,6 @@ def result_from_properties(apps, schema_editor): git_tag = get_property(MessageProperty, "git.tag", message=m) git_url = get_property(MessageProperty, "git.url", message=m) git_base = get_property(MessageProperty, "git.base", message=m) - data = {} if git_repo and git_tag: data['repo'] = git_repo data['tag'] = 'refs/tags/' + git_tag @@ -49,8 +49,8 @@ def result_from_properties(apps, schema_editor): data['url'] = git_url if git_base: data['base'] = git_base - r.data = data r.status = api.models.Result.SUCCESS + r.data = data else: status = api.models.Result.PENDING r.last_update = datetime.datetime.utcnow() diff --git a/api/migrations/0032_fix_git_results.py b/api/migrations/0032_fix_git_results.py new file mode 100644 index 00000000..2438126a --- /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 = [ + ('api', '0031_auto_20180520_1654'), + ] + + operations = [ + # 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. This + # has been fixed now in the migration, but the fix is also included as a + # separate migration in case the buggy data is found in the database. + migrations.RunSQL("update api_result set data = '{}' where name='git' and data = '\"\"'") + ] diff --git a/mods/git.py b/mods/git.py index a2b6d86a..924547a6 100644 --- a/mods/git.py +++ b/mods/git.py @@ -276,10 +276,10 @@ def handle(self, request, project, message_id, tag, url, base, repo, r = Message.objects.series_heads().get(project=p, message_id=message_id).git_result r.log = log + data = {} if failed: r.status = Result.FAILURE else: - data = {} data['repo'] = repo data['tag'] = 'refs/tags/' + tag if url: @@ -289,6 +289,6 @@ def handle(self, request, project, message_id, tag, url, base, repo, data['url'] = url_template.replace("%t", tag) if base: data['base'] = base - r.data = data r.status = Result.SUCCESS + r.data = data r.save()