For layers which do not follow standard branch names (including the inclusive naming move away from "master" to "main") we have the actual_branch field set in a LayerBranch object. Previously this was only exposed via the admin interface.
Allow layer maintainers (including upon submitting a new layer) to set the 'Actual branch' in the web UI. Add a check to make sure the actual_branch is a valid branch name using 'git check-ref-format --branch <actual_branch>' since we are not using full refs. [YOCTO #8008] NOTE: Only existing LayerBranches will be editable. A new layer can be submitted with a different branch for "master", but only the "master" LayerBranch will be created. Further changes to the update.py script will be needed to make creation of new stable branches with an actual_branch possible. Signed-off-by: Tim Orling <tim.orl...@konsulko.com> --- layerindex/forms.py | 15 +++++++++++++++ layerindex/views.py | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/layerindex/forms.py b/layerindex/forms.py index 9615859..3b764f1 100644 --- a/layerindex/forms.py +++ b/layerindex/forms.py @@ -76,6 +76,7 @@ LayerMaintainerFormSet = inlineformset_factory(LayerBranch, LayerMaintainer, for class EditLayerForm(StyledModelForm): # 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)') + actual_branch = forms.CharField(label='Actual branch', max_length=80, required=False, help_text='Name of the actual branch in the repository matching the core branch (e.g. the development branch is "master" by default)') deps = forms.ModelMultipleChoiceField(label='Other layers this layer depends upon', queryset=LayerItem.objects.filter(comparison=False), required=False) captcha = CaptchaField(label='Verification', help_text='Please enter the letters displayed for verification purposes', error_messages={'invalid':'Incorrect entry, please try again'}) @@ -98,11 +99,16 @@ class EditLayerForm(StyledModelForm): field_order.pop(field_order.index('vcs_subdir')) name_pos = field_order.index('vcs_url') + 1 field_order.insert(name_pos, 'vcs_subdir') + # Ensure actual branch appears after repo subdir + field_order.pop(field_order.index('actual_branch')) + name_pos = name_pos + 1 + field_order.insert(name_pos, 'actual_branch') new_fields = OrderedDict() for field in field_order: new_fields[field] = self.fields[field] self.fields = new_fields self.fields['vcs_subdir'].initial = layerbranch.vcs_subdir + self.fields['actual_branch'].initial = layerbranch.actual_branch self.was_saved = False self.allow_base_type = allow_base_type @@ -178,6 +184,15 @@ class EditLayerForm(StyledModelForm): val(usage) return usage + def clean_actual_branch(self): + import subprocess + actual_branch = self.cleaned_data['actual_branch'].strip() + process = subprocess.Popen(["git", "check-ref-format", "--branch", actual_branch]) + exit_status = process.wait() + if exit_status != 0: + raise forms.ValidationError("Actual branch should be a valid git branch short name") + return actual_branch + class EditNoteForm(StyledModelForm): class Meta: diff --git a/layerindex/views.py b/layerindex/views.py index 2e87181..1a29dde 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -162,6 +162,11 @@ def edit_layer_view(request, template_name, branch='master', slug=None): layerbranch.vcs_subdir = new_subdir reset_last_rev = True layerbranch.save() + new_actual_branch = form.cleaned_data['actual_branch'] + if layerbranch.actual_branch != new_actual_branch: + layerbranch.actual_branch = new_actual_branch + reset_last_rev = True + layerbranch.save() maintainerformset.save() if slug: new_deps = form.cleaned_data['deps'] -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#62056): https://lists.yoctoproject.org/g/yocto/message/62056 Mute This Topic: https://lists.yoctoproject.org/mt/103428527/21656 Group Owner: yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-