| Summary: | GitHub git protocol urls need to be scrubbed | ||
|---|---|---|---|
| Product: | [Yocto Project Subprojects] Layer Index | Reporter: | Tim Orling <tim.orling> |
| Component: | Layer Index Metadata | Assignee: | Tim Orling <tim.orling> |
| Status: | RESOLVED FIXED | QA Contact: | apoorv sangal <apoorvsangal> |
| Severity: | normal | ||
| Priority: | Medium+ | CC: | konrad.scherer, mhalstead, randy.macleod |
| Version: | unspecified | ||
| Target Milestone: | 4.1 M1 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | Don't know | |
|
Description
Tim Orling
2022-03-24 15:10:24 UTC
Is this something that Michael can do in the database? Yes from the Admin interface all the project url for each layers can be updated. Django does support custom commands and it should be possible to make a command that will iterate through the layers and update any github urls. The following should fix it:
UPDATE layerindex_layeritem
SET layerindex_layeritem.vcs_url = REPLACE(layerindex_layeritem.vcs_url,'git://github.com', 'https://github.com')
WHERE layerindex_layeritem.vcs_url LIKE "git://github.com%";
After discussing with Paul, we do not want to do SQL directly. I'll need to refactor for 'manage.py shell' which I might have permissions to do (after testing on local instance). Using manage.py shell:
from django.db.models import Value
from django.db.models.functions import Replace
from layerindex.models import LayerItem
layers = LayerItem.objects.all().filter(vcs_url__startswith='git://github.com')
layers.update(vcs_url=Replace('vcs_url', Value('git://github.com'), Value('https://github.com')))
To get to the shell: docker exec -it <layersapp> sh -c "/opt/layerindex/manage.py shell" Count before fix: 106 |