mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
Move repo subdirectory to layerbranch
So it turns out that one or two layers have changed in structure between branches, so we need to be able to specify this on a per-branch basis. Good times... Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
parent
ee9176a8c5
commit
0a1215e59e
|
@ -46,12 +46,13 @@ LayerMaintainerFormSet = inlineformset_factory(LayerBranch, LayerMaintainer, for
|
|||
|
||||
class EditLayerForm(forms.ModelForm):
|
||||
# Additional form fields
|
||||
vcs_subdir = forms.CharField(label='Repository subdirectory', max_length=40, required=False, help_text='Subdirectory within the repository where the layer is located, if not in the root (usually only used if the repository contains more than one layer)')
|
||||
deps = forms.ModelMultipleChoiceField(label='Other layers this layer depends upon', queryset=LayerItem.objects.all(), required=False)
|
||||
captcha = CaptchaField(label='Verification', help_text='Please enter the letters displayed for verification purposes', error_messages={'invalid':'Incorrect entry, please try again'})
|
||||
|
||||
class Meta:
|
||||
model = LayerItem
|
||||
fields = ('name', 'layer_type', 'summary', 'description', 'vcs_url', 'vcs_subdir', 'vcs_web_url', 'vcs_web_tree_base_url', 'vcs_web_file_base_url', 'usage_url', 'mailing_list_url')
|
||||
fields = ('name', 'layer_type', 'summary', 'description', 'vcs_url', 'vcs_web_url', 'vcs_web_tree_base_url', 'vcs_web_file_base_url', 'usage_url', 'mailing_list_url')
|
||||
|
||||
def __init__(self, user, layerbranch, *args, **kwargs):
|
||||
super(self.__class__, self).__init__(*args, **kwargs)
|
||||
|
@ -63,6 +64,12 @@ class EditLayerForm(forms.ModelForm):
|
|||
self.fields['deps'].initial = [l.pk for l in LayerItem.objects.filter(name='openembedded-core')]
|
||||
if user.is_authenticated():
|
||||
del self.fields['captcha']
|
||||
# Ensure repo subdir appears after repo URL
|
||||
field_order = self.fields.keyOrder
|
||||
field_order.pop(field_order.index('vcs_subdir'))
|
||||
name_pos = field_order.index('vcs_url') + 1
|
||||
field_order.insert(name_pos, 'vcs_subdir')
|
||||
self.fields['vcs_subdir'].initial = layerbranch.vcs_subdir
|
||||
self.was_saved = False
|
||||
|
||||
def checked_deps(self):
|
||||
|
|
|
@ -41,7 +41,6 @@ class LayerItem(models.Model):
|
|||
layer_type = models.CharField(max_length=1, choices=LAYER_TYPE_CHOICES)
|
||||
summary = models.CharField(max_length=200, help_text='One-line description of the layer')
|
||||
description = models.TextField()
|
||||
vcs_subdir = models.CharField('Repository subdirectory', max_length=40, blank=True, help_text='Subdirectory within the repository where the layer is located, if not in the root (usually only used if the repository contains more than one layer)')
|
||||
vcs_url = models.CharField('Repository URL', max_length=200, help_text='Fetch/clone URL of the repository')
|
||||
vcs_web_url = models.URLField('Repository web interface URL', blank=True, help_text='URL of the web interface for browsing the repository, if any')
|
||||
vcs_web_tree_base_url = models.CharField('Repository web interface tree base URL', max_length=200, blank=True, help_text='Base URL for the web interface for browsing directories within the repository, if any')
|
||||
|
@ -91,6 +90,7 @@ class LayerItem(models.Model):
|
|||
class LayerBranch(models.Model):
|
||||
layer = models.ForeignKey(LayerItem)
|
||||
branch = models.ForeignKey(Branch)
|
||||
vcs_subdir = models.CharField('Repository subdirectory', max_length=40, blank=True, help_text='Subdirectory within the repository where the layer is located, if not in the root (usually only used if the repository contains more than one layer)')
|
||||
vcs_last_fetch = models.DateTimeField('Last successful fetch', blank=True, null=True)
|
||||
vcs_last_rev = models.CharField('Last revision fetched', max_length=80, blank=True)
|
||||
vcs_last_commit = models.DateTimeField('Last commit date', blank=True, null=True)
|
||||
|
@ -106,8 +106,8 @@ class LayerBranch(models.Model):
|
|||
|
||||
def _handle_url_path(self, base_url, path):
|
||||
if base_url:
|
||||
if self.layer.vcs_subdir:
|
||||
extra_path = self.layer.vcs_subdir + '/' + path
|
||||
if self.vcs_subdir:
|
||||
extra_path = self.vcs_subdir + '/' + path
|
||||
else:
|
||||
extra_path = path
|
||||
url = base_url.replace('%branch%', self.branch.name)
|
||||
|
|
|
@ -263,9 +263,14 @@ def main():
|
|||
if not core_layer:
|
||||
logger.error("Unable to find core layer %s in database; check CORE_LAYER_NAME setting" % settings.CORE_LAYER_NAME)
|
||||
sys.exit(1)
|
||||
core_layerbranch = core_layer.get_layerbranch(options.branch)
|
||||
if core_layerbranch:
|
||||
core_subdir = core_layerbranch.vcs_subdir
|
||||
else:
|
||||
core_subdir = 'meta'
|
||||
core_urldir = sanitise_path(core_layer.vcs_url)
|
||||
core_repodir = os.path.join(fetchdir, core_urldir)
|
||||
core_layerdir = os.path.join(core_repodir, core_layer.vcs_subdir)
|
||||
core_layerdir = os.path.join(core_repodir, core_subdir)
|
||||
out = runcmd("git checkout origin/%s" % options.branch, core_repodir)
|
||||
out = runcmd("git clean -f -x", core_repodir)
|
||||
# The directory above where this script exists should contain our conf/layer.conf,
|
||||
|
@ -319,22 +324,25 @@ def main():
|
|||
transaction.rollback()
|
||||
continue
|
||||
|
||||
if layer.vcs_subdir:
|
||||
# Find latest commit in subdirectory
|
||||
# A bit odd to do it this way but apparently there's no other way in the GitPython API
|
||||
for commit in repo.iter_commits('origin/%s' % options.branch, paths=layer.vcs_subdir):
|
||||
topcommit = commit
|
||||
break
|
||||
|
||||
layerbranch = layer.get_layerbranch(options.branch)
|
||||
if not layerbranch:
|
||||
# LayerBranch doesn't exist for this branch, create it
|
||||
layerbranch = LayerBranch()
|
||||
layerbranch.layer = layer
|
||||
layerbranch.branch = branch
|
||||
layerbranch_master = layer.get_layerbranch('master')
|
||||
if layerbranch_master:
|
||||
layerbranch.vcs_subdir = layerbranch_master.vcs_subdir
|
||||
layerbranch.save()
|
||||
|
||||
layerdir = os.path.join(repodir, layer.vcs_subdir)
|
||||
if layerbranch.vcs_subdir:
|
||||
# Find latest commit in subdirectory
|
||||
# A bit odd to do it this way but apparently there's no other way in the GitPython API
|
||||
for commit in repo.iter_commits('origin/%s' % options.branch, paths=layerbranch.vcs_subdir):
|
||||
topcommit = commit
|
||||
break
|
||||
|
||||
layerdir = os.path.join(repodir, layerbranch.vcs_subdir)
|
||||
layerdir_start = os.path.normpath(layerdir) + os.sep
|
||||
layerrecipes = Recipe.objects.filter(layerbranch=layerbranch)
|
||||
layermachines = Machine.objects.filter(layerbranch=layerbranch)
|
||||
|
@ -365,7 +373,12 @@ def main():
|
|||
for dep in layerbranch.dependencies_set.all():
|
||||
depurldir = sanitise_path(dep.dependency.vcs_url)
|
||||
deprepodir = os.path.join(fetchdir, depurldir)
|
||||
deplayerdir = os.path.join(deprepodir, dep.dependency.vcs_subdir)
|
||||
deplayerbranch = dep.dependency.get_layerbranch(options.branch)
|
||||
if not deplayerbranch:
|
||||
logger.error('Dependency %s of layer %s does not have branch record for branch %s' % (dep.dependency.name, layer.name, options.branch))
|
||||
transaction.rollback()
|
||||
continue
|
||||
deplayerdir = os.path.join(deprepodir, deplayerbranch.vcs_subdir)
|
||||
parse_layer_conf(deplayerdir, config_data_copy)
|
||||
config_data_copy.delVar('LAYERDIR')
|
||||
|
||||
|
@ -381,8 +394,8 @@ def main():
|
|||
if diff:
|
||||
# Apply git changes to existing recipe list
|
||||
|
||||
if layer.vcs_subdir:
|
||||
subdir_start = os.path.normpath(layer.vcs_subdir) + os.sep
|
||||
if layerbranch.vcs_subdir:
|
||||
subdir_start = os.path.normpath(layerbranch.vcs_subdir) + os.sep
|
||||
else:
|
||||
subdir_start = ""
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ def edit_layer_view(request, template_name, slug=None):
|
|||
with transaction.commit_on_success():
|
||||
form.save()
|
||||
layerbranch.layer = layeritem
|
||||
layerbranch.vcs_subdir = form.cleaned_data['vcs_subdir']
|
||||
layerbranch.save()
|
||||
maintainerformset.save()
|
||||
if slug:
|
||||
|
|
|
@ -95,9 +95,9 @@
|
|||
{% endif %}
|
||||
</p>
|
||||
|
||||
{% if layeritem.vcs_subdir %}
|
||||
{% if layerbranch.vcs_subdir %}
|
||||
<h4>Subdirectory</h4>
|
||||
<p><span data-toggle="tooltip" title="Select subdirectory"><i class="icon-circle-arrow-right selectallicon" for="vcs_subdir" id="vcs_subdir_select"></i></span><span id="vcs_subdir" class="copyable">{{ layeritem.vcs_subdir }}</span>
|
||||
<p><span data-toggle="tooltip" title="Select subdirectory"><i class="icon-circle-arrow-right selectallicon" for="vcs_subdir" id="vcs_subdir_select"></i></span><span id="vcs_subdir" class="copyable">{{ layerbranch.vcs_subdir }}</span>
|
||||
{% if layerbranch.tree_url %}
|
||||
<span class="label label-info">
|
||||
<a href="{{ layerbranch.tree_url }}">web subdirectory</a>
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Repository subdirectory</th>
|
||||
<td>{{ layeritem.vcs_subdir }}</td>
|
||||
<td>{{ layerbranch.vcs_subdir }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Repo web interface</th>
|
||||
|
|
Loading…
Reference in New Issue
Block a user