summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/typeaheads.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/toastergui/typeaheads.py')
-rw-r--r--bitbake/lib/toaster/toastergui/typeaheads.py29
1 files changed, 29 insertions, 0 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