diff options
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 2fd504cb5b..503b43c5db 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -609,6 +609,8 @@ class LayerIndexLayerSource(LayerSource): | |||
609 | l.up_date = li['updated'] | 609 | l.up_date = li['updated'] |
610 | l.name = li['name'] | 610 | l.name = li['name'] |
611 | l.vcs_url = li['vcs_url'] | 611 | l.vcs_url = li['vcs_url'] |
612 | l.vcs_web_url = li['vcs_web_url'] | ||
613 | l.vcs_web_tree_base_url = li['vcs_web_tree_base_url'] | ||
612 | l.vcs_web_file_base_url = li['vcs_web_file_base_url'] | 614 | l.vcs_web_file_base_url = li['vcs_web_file_base_url'] |
613 | l.summary = li['summary'] | 615 | l.summary = li['summary'] |
614 | l.description = li['description'] | 616 | l.description = li['description'] |
@@ -738,6 +740,8 @@ class Layer(models.Model): | |||
738 | local_path = models.FilePathField(max_length=255, null = True, default = None) | 740 | local_path = models.FilePathField(max_length=255, null = True, default = None) |
739 | layer_index_url = models.URLField() | 741 | layer_index_url = models.URLField() |
740 | vcs_url = GitURLField(default = None, null = True) | 742 | vcs_url = GitURLField(default = None, null = True) |
743 | vcs_web_url = models.URLField(null = True, default = None) | ||
744 | vcs_web_tree_base_url = models.URLField(null = True, default = None) | ||
741 | vcs_web_file_base_url = models.URLField(null = True, default = None) | 745 | vcs_web_file_base_url = models.URLField(null = True, default = None) |
742 | 746 | ||
743 | summary = models.TextField(help_text='One-line description of the layer', null = True, default = None) | 747 | summary = models.TextField(help_text='One-line description of the layer', null = True, default = None) |
@@ -766,13 +770,54 @@ class Layer_Version(models.Model): | |||
766 | dirpath = models.CharField(max_length=255, null = True, default = None) # LayerBranch.vcs_subdir | 770 | dirpath = models.CharField(max_length=255, null = True, default = None) # LayerBranch.vcs_subdir |
767 | priority = models.IntegerField(default = 0) # if -1, this is a default layer | 771 | priority = models.IntegerField(default = 0) # if -1, this is a default layer |
768 | 772 | ||
769 | def get_vcs_link_url(self, file_path="/"): | 773 | # code lifted, with adaptations, from the layerindex-web application https://git.yoctoproject.org/cgit/cgit.cgi/layerindex-web/ |
774 | def _handle_url_path(self, base_url, path): | ||
775 | import re | ||
776 | if base_url: | ||
777 | if self.dirpath: | ||
778 | if path: | ||
779 | extra_path = self.dirpath + '/' + path | ||
780 | # Normalise out ../ in path for usage URL | ||
781 | extra_path = posixpath.normpath(extra_path) | ||
782 | # Minor workaround to handle case where subdirectory has been added between branches | ||
783 | # (should probably support usage URL per branch to handle this... sigh...) | ||
784 | if extra_path.startswith('../'): | ||
785 | extra_path = extra_path[3:] | ||
786 | else: | ||
787 | extra_path = self.dirpath | ||
788 | else: | ||
789 | extra_path = path | ||
790 | branchname = self.up_branch.name | ||
791 | url = base_url.replace('%branch%', branchname) | ||
792 | |||
793 | # If there's a % in the path (e.g. a wildcard bbappend) we need to encode it | ||
794 | if extra_path: | ||
795 | extra_path = extra_path.replace('%', '%25') | ||
796 | |||
797 | if '%path%' in base_url: | ||
798 | if extra_path: | ||
799 | url = re.sub(r'\[([^\]]*%path%[^\]]*)\]', '\\1', url) | ||
800 | else: | ||
801 | url = re.sub(r'\[([^\]]*%path%[^\]]*)\]', '', url) | ||
802 | return url.replace('%path%', extra_path) | ||
803 | else: | ||
804 | return url + extra_path | ||
805 | return None | ||
806 | |||
807 | def get_vcs_link_url(self): | ||
808 | if self.layer.vcs_web_url is None: | ||
809 | return None | ||
810 | return self.layer.vcs_web_url | ||
811 | |||
812 | def get_vcs_file_link_url(self, file_path=""): | ||
770 | if self.layer.vcs_web_file_base_url is None: | 813 | if self.layer.vcs_web_file_base_url is None: |
771 | return None | 814 | return None |
772 | return self.layer.vcs_web_file_base_url.replace('%path%', file_path).replace('%branch%', self.up_branch.name) | 815 | return self._handle_url_path(self.layer.vcs_web_file_base_url, file_path) |
773 | 816 | ||
774 | def get_vcs_link_url_dirpath(self): | 817 | def get_vcs_dirpath_link_url(self): |
775 | return self.get_vcs_link_url(self.dirpath) | 818 | if self.layer.vcs_web_tree_base_url is None: |
819 | return None | ||
820 | return self._handle_url_path(self.layer.vcs_web_tree_base_url, '') | ||
776 | 821 | ||
777 | 822 | ||
778 | def __unicode__(self): | 823 | def __unicode__(self): |