summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/toastergui/typeaheads.py29
-rw-r--r--bitbake/lib/toaster/toastergui/urls.py5
2 files changed, 32 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/toastergui/typeaheads.py b/bitbake/lib/toaster/toastergui/typeaheads.py
index 2c6c1454a1..5316000209 100644
--- a/bitbake/lib/toaster/toastergui/typeaheads.py
+++ b/bitbake/lib/toaster/toastergui/typeaheads.py
@@ -16,9 +16,12 @@
16# with this program; if not, write to the Free Software Foundation, Inc., 16# with this program; if not, write to the Free Software Foundation, Inc.,
17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 18
19import subprocess
20
19from toastergui.widgets import ToasterTypeAhead 21from toastergui.widgets import ToasterTypeAhead
20from orm.models import Project 22from orm.models import Project
21from django.core.urlresolvers import reverse 23from django.core.urlresolvers import reverse
24from django.core.cache import cache
22 25
23class LayersTypeAhead(ToasterTypeAhead): 26class LayersTypeAhead(ToasterTypeAhead):
24 """ Typeahead for layers available and not added in the current project's 27 """ Typeahead for layers available and not added in the current project's
@@ -147,3 +150,29 @@ class ProjectsTypeAhead(ToasterTypeAhead):
147 results.append(needed_fields) 150 results.append(needed_fields)
148 151
149 return results 152 return results
153
154
155class GitRevisionTypeAhead(ToasterTypeAhead):
156 def apply_search(self, search_term, prj, request):
157 results = []
158 git_url = request.GET.get('git_url')
159 ls_remote = cache.get(git_url)
160
161 if ls_remote is None:
162 ls_remote = subprocess.check_output(['git', 'ls-remote', git_url],
163 universal_newlines=True)
164 ls_remote = ls_remote.splitlines()
165 # Avoid fetching the list of git refs on each new input
166 cache.set(git_url, ls_remote, 120)
167
168 for rev in ls_remote:
169 git_rev = str(rev).split("/")[-1:][0]
170 # "HEAD" has a special meaning in Toaster... YOCTO #9924
171 if "HEAD" in git_rev:
172 continue
173
174 if git_rev.startswith(search_term):
175 results.append({'name': git_rev,
176 'detail': '[ %s ]' % str(rev)})
177
178 return results
diff --git a/bitbake/lib/toaster/toastergui/urls.py b/bitbake/lib/toaster/toastergui/urls.py
index 29f0d96ba7..d92f190aed 100644
--- a/bitbake/lib/toaster/toastergui/urls.py
+++ b/bitbake/lib/toaster/toastergui/urls.py
@@ -182,8 +182,9 @@ urlpatterns = patterns('toastergui.views',
182 typeaheads.RecipesTypeAhead.as_view(), name='xhr_recipestypeahead'), 182 typeaheads.RecipesTypeAhead.as_view(), name='xhr_recipestypeahead'),
183 url(r'^xhr_typeahead/projects$', 183 url(r'^xhr_typeahead/projects$',
184 typeaheads.ProjectsTypeAhead.as_view(), name='xhr_projectstypeahead'), 184 typeaheads.ProjectsTypeAhead.as_view(), name='xhr_projectstypeahead'),
185 185 url(r'^xhr_typeahead/gitrev$',
186 186 typeaheads.GitRevisionTypeAhead.as_view(),
187 name='xhr_gitrevtypeahead'),
187 188
188 url(r'^xhr_testreleasechange/(?P<pid>\d+)$', 'xhr_testreleasechange', 189 url(r'^xhr_testreleasechange/(?P<pid>\d+)$', 'xhr_testreleasechange',
189 name='xhr_testreleasechange'), 190 name='xhr_testreleasechange'),