mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-06 21:54:47 +02:00

The Recipe Reporting System needs to be able to provide links to commits in the web interface for the repository, but we can only do this if we have a custom template URL just like we do for file/tree links, since it's different for different git web interfaces. Add support in all the various places for such a URL and make use of it in the RRS. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations, models
|
|
|
|
|
|
def set_commit_url(apps, schema_editor):
|
|
import re
|
|
LayerItem = apps.get_model('layerindex', 'LayerItem')
|
|
for layer in LayerItem.objects.all():
|
|
if layer.vcs_web_url:
|
|
if 'git.yoctoproject.org' in layer.vcs_web_url or 'git.openembedded.org' in layer.vcs_web_url or 'cgit.' in layer.vcs_web_url:
|
|
layer.vcs_web_commit_url = layer.vcs_web_url + '/commit/?id=%hash%'
|
|
elif 'github.com/' in layer.vcs_web_url:
|
|
layer.vcs_web_commit_url = layer.vcs_web_url + '/commit/%hash%'
|
|
elif 'bitbucket.org/' in layer.vcs_web_url:
|
|
layer.vcs_web_commit_url = layer.vcs_web_url + '/commits/%hash%'
|
|
elif 'gitlab.' in layer.vcs_web_url:
|
|
layer.vcs_web_commit_url = layer.vcs_web_url + '/commit/%hash%'
|
|
elif 'a=tree;' in layer.vcs_web_tree_base_url:
|
|
layer.vcs_web_commit_url = re.sub(r'\.git.*', '.git;a=commit;h=%hash%', layer.vcs_web_url)
|
|
layer.save()
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('layerindex', '0011_source'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='layeritem',
|
|
name='vcs_web_commit_url',
|
|
field=models.CharField(verbose_name='Repository web interface commit URL', max_length=255, blank=True, help_text='Base URL for the web interface for viewing a single commit within the repository, if any'),
|
|
),
|
|
migrations.RunPython(set_commit_url, reverse_code=migrations.RunPython.noop),
|
|
]
|