]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: toaster: reserve HEAD from imported layers
authorDavid Reyna <David.Reyna@windriver.com>
Thu, 14 Sep 2017 23:58:15 +0000 (16:58 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 17 Sep 2017 22:24:14 +0000 (23:24 +0100)
The HEAD reference in Toaster layers are reserved for the
"Local Yocto Project" layers, stored at the top directory.
Imported layers are not allowed to use this since they are
managed differently - for example the 'remotes' will collide.

Fix the add layer handler to not drop the data fields when it
is a git repo.

Explicitly inform the user when an internal Toaster error is
returned via AJAX, so that they know why clicking the layer add
button did not do anything.

[YOCTO #9924]

(Bitbake rev: 04bd9c9341e8390a7923fa0122cd4cb0befa569f)

Signed-off-by: David Reyna <David.Reyna@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/toaster/toastergui/api.py
bitbake/lib/toaster/toastergui/static/js/importlayer.js
bitbake/lib/toaster/toastergui/templates/importlayer.html

index cb8f0f3127a82791a5b2f3c1d105912d4410de2b..ab6ba69e0e14ee9a2b0dd46d34f9a78531753d28 100644 (file)
@@ -293,14 +293,14 @@ class XhrLayer(View):
                 layer_source=LayerSource.TYPE_IMPORTED)
 
             # Local layer
-            if 'local_source_dir' in layer_data:
+            if ('local_source_dir' in layer_data) and layer.local_source_dir:
                 layer.local_source_dir = layer_data['local_source_dir']
             # git layer
             elif 'vcs_url' in layer_data:
                 layer.vcs_url = layer_data['vcs_url']
                 layer_version.dirpath = layer_data['dir_path']
-                layer_version.commit = layer_data['get_ref']
-                layer_version.branch = layer_data['get_ref']
+                layer_version.commit = layer_data['git_ref']
+                layer_version.branch = layer_data['git_ref']
 
             layer.save()
             layer_version.save()
index b3f094e69b4fcf6d6e0ad645777ba0c7e6fccdec..59652b9a3649e75be9ecfde382a9923ae483045a 100644 (file)
@@ -176,6 +176,8 @@ function importLayerPageInit (ctx) {
           success: function (data) {
             if (data.error != "ok") {
               console.log(data.error);
+              /* let the user know why nothing happened */
+              alert(data.error)
             } else {
               createImportedNotification(data);
               window.location.replace(libtoaster.ctx.projectPageUrl);
@@ -244,9 +246,18 @@ function importLayerPageInit (ctx) {
         enable_import_btn(true);
       }
 
-      if ($("#git-repo-radio").prop("checked") &&
-          vcsURLInput.val().length > 0 && gitRefInput.val().length > 0) {
-        enable_import_btn(true);
+      if ($("#git-repo-radio").prop("checked")) {
+        if (gitRefInput.val().length > 0 &&
+            gitRefInput.val() == 'HEAD') {
+          $('#invalid-layer-revision-hint').show();
+          $('#layer-revision-ctrl').addClass('has-error');
+          enable_import_btn(false);
+        } else if (vcsURLInput.val().length > 0 &&
+                   gitRefInput.val().length > 0) {
+          $('#invalid-layer-revision-hint').hide();
+          $('#layer-revision-ctrl').removeClass('has-error');
+          enable_import_btn(true);
+        }
       }
     }
 
index afbeb94d423ec7ee8a43b7519ba335fe7431bf15..7e5253e963554eb506c0e5ccaaecf492ef617241 100644 (file)
         </label>
         <span style="display: block">
         <input type="text" class="form-control" id="layer-git-ref" autocomplete="off" data-minLength="1" data-autocomplete="off" data-provide="typeahead" required>
-        <span class="help-inline" style="display:none;" id="invalid-layer-revision-hint"></span>
         </span>
+        <span class="help-block has-error" style="display:none;" id="invalid-layer-revision-hint">The "HEAD" branch is reserved (only allowed for the "Local Yocto Project" layers)</span>
       </div>
     </fieldset>