#93: update URL to submodule

This commit is contained in:
Vokhmin Alexey V 2013-04-11 15:19:24 +04:00
parent 8fdcb33a83
commit 165532414d
2 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,23 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
module GitHelper 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 def render_path
# TODO: Looks ugly, rewrite with clear mind. # TODO: Looks ugly, rewrite with clear mind.
if @path.present? if @path.present?

View File

@ -26,7 +26,7 @@
- if node.is_a? Grit::Submodule - if node.is_a? Grit::Submodule
.pic= image_tag 'folder-submodule.png' .pic= image_tag 'folder-submodule.png'
.name .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.name, url, :class => 'files-see')
= '@' = '@'
= link_to(node.id[0..6], "#{url}/tree/#{node.id}", :class => 'files-see') = link_to(node.id[0..6], "#{url}/tree/#{node.id}", :class => 'files-see')