diff --git a/app/models/project.rb b/app/models/project.rb index a55f7a65b0b051d358ed34028cdca707d1adf7d3..b022bb4ebb2ac7907f80d34ef7d30c5677037ccd 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -201,6 +201,10 @@ class Project < ActiveRecord::Base [Gitlab.config.gitlab.url, path_with_namespace].join("/") end + def web_url_without_protocol + web_url.split("://")[1] + end + def build_commit_note(commit) notes.new(commit_id: commit.id, noteable_type: "Commit") end diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml index 0775abea3dda3dbeff677e902dc2b24e1df5e599..6d8139a0bbbc44b0ac4b8963adc9dc7b13046b44 100644 --- a/app/views/layouts/_head.html.haml +++ b/app/views/layouts/_head.html.haml @@ -20,3 +20,8 @@ = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}") - if current_controller?(:issues) = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") + + -# Go repository retrieval support. + - if controller_name == 'projects' && action_name == 'show' + %meta{name: "go-import", content: "#{@project.web_url_without_protocol} git #{@project.web_url}.git"} + diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 8aa4c7fed1a700d3006a882e1ebcfc0b59461fcb..373accfe4120f0a96a73a847024adb112549bf90 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -99,6 +99,11 @@ describe Project do project.web_url.should == "#{Gitlab.config.gitlab.url}/somewhere" end + it "returns the web URL without the protocol for this repo" do + project = Project.new(path: "somewhere") + project.web_url_without_protocol.should == "#{Gitlab.config.gitlab.host}/somewhere" + end + describe "last_activity methods" do let(:project) { create(:project) } let(:last_event) { double(created_at: Time.now) }