Merge pull request #99 from abf/rosa-build:93-wrong-url-of-submodule

[refs #93]: wrong URL of submodule
This commit is contained in:
warpc 2013-04-11 15:36:48 +04:00
commit 73bb177764
2 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,23 @@
# -*- encoding : utf-8 -*-
module GitHelper
def submodule_url(node, treeish)
# node.url(treeish) looks like:
# - http://0.0.0.0:3000/abf/git@abf.rosalinux.ru:abf/rhel-scripts.git
# - git://github.com/avokhmin/mdv-scripts.git
url = node.url(treeish).gsub(/.git$/, '')
if url =~ /^git:/
url.gsub!(/^git/, 'http')
else
str = /git@.*:.*/.match(url)[0].gsub(/^git@/, '')
domen = str.gsub(/:.*/, '')
owner = str.gsub(/^#{domen}:/, '').gsub(/\/.*/, '')
project = str.gsub(/.*\//, '')
url = "http://#{domen}/#{owner}/#{project}"
end
url
end
def render_path
# TODO: Looks ugly, rewrite with clear mind.
if @path.present?

View File

@ -26,7 +26,7 @@
- if node.is_a? Grit::Submodule
.pic= image_tag 'folder-submodule.png'
.name
- url = node.url(@treeish).gsub(/^git/, 'http').gsub(/.git$/, '')
- url = submodule_url node, @treeish
= link_to(node.name, url, :class => 'files-see')
= '@'
= link_to(node.id[0..6], "#{url}/tree/#{node.id}", :class => 'files-see')