Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 4E113E008D2; Thu, 14 Sep 2017 16:28:42 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.1.11 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail.windriver.com (mail.windriver.com [147.11.1.11]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id C7003E0078E for ; Thu, 14 Sep 2017 16:28:41 -0700 (PDT) Received: from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com [147.11.189.41]) by mail.windriver.com (8.15.2/8.15.1) with ESMTPS id v8ENSeua027290 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL) for ; Thu, 14 Sep 2017 16:28:40 -0700 (PDT) Received: from ala-dreyna-lx3.corp.ad.wrs.com (147.11.157.78) by ALA-HCB.corp.ad.wrs.com (147.11.189.41) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 14 Sep 2017 16:28:40 -0700 From: David Reyna To: Date: Thu, 14 Sep 2017 16:20:29 -0700 Message-ID: <1505431229-5404-1-git-send-email-david.reyna@windriver.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [147.11.157.78] Subject: [PATCH] toaster: reserve HEAD from imported layers X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Sep 2017 23:28:42 -0000 Content-Type: text/plain From: David Reyna 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] Signed-off-by: David Reyna --- bitbake/lib/toaster/toastergui/api.py | 6 +++--- bitbake/lib/toaster/toastergui/static/js/importlayer.js | 17 ++++++++++++++--- .../lib/toaster/toastergui/templates/importlayer.html | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/bitbake/lib/toaster/toastergui/api.py b/bitbake/lib/toaster/toastergui/api.py index cb8f0f3..ab6ba69 100644 --- a/bitbake/lib/toaster/toastergui/api.py +++ b/bitbake/lib/toaster/toastergui/api.py @@ -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() diff --git a/bitbake/lib/toaster/toastergui/static/js/importlayer.js b/bitbake/lib/toaster/toastergui/static/js/importlayer.js index b3f094e..59652b9 100644 --- a/bitbake/lib/toaster/toastergui/static/js/importlayer.js +++ b/bitbake/lib/toaster/toastergui/static/js/importlayer.js @@ -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); + } } } diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html index afbeb94..7e5253e 100644 --- a/bitbake/lib/toaster/toastergui/templates/importlayer.html +++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html @@ -115,8 +115,8 @@ - + -- 1.9.1