Commit 5f9d90e2186c373d336794fa336496652a638366
Exists in
spb-stable
and in
3 other branches
Merge pull request #5958 from brunoga/go-repository-fetch
Added support for Go's repository retrieval.
Showing
3 changed files
with
14 additions
and
0 deletions
Show diff stats
app/models/project.rb
... | ... | @@ -205,6 +205,10 @@ class Project < ActiveRecord::Base |
205 | 205 | [Gitlab.config.gitlab.url, path_with_namespace].join("/") |
206 | 206 | end |
207 | 207 | |
208 | + def web_url_without_protocol | |
209 | + web_url.split("://")[1] | |
210 | + end | |
211 | + | |
208 | 212 | def build_commit_note(commit) |
209 | 213 | notes.new(commit_id: commit.id, noteable_type: "Commit") |
210 | 214 | end | ... | ... |
app/views/layouts/_head.html.haml
... | ... | @@ -22,3 +22,8 @@ |
22 | 22 | = 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}") |
23 | 23 | - if current_controller?(:issues) |
24 | 24 | = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues") |
25 | + | |
26 | + -# Go repository retrieval support. | |
27 | + - if controller_name == 'projects' && action_name == 'show' | |
28 | + %meta{name: "go-import", content: "#{@project.web_url_without_protocol} git #{@project.web_url}.git"} | |
29 | + | ... | ... |
spec/models/project_spec.rb
... | ... | @@ -99,6 +99,11 @@ describe Project do |
99 | 99 | project.web_url.should == "#{Gitlab.config.gitlab.url}/somewhere" |
100 | 100 | end |
101 | 101 | |
102 | + it "returns the web URL without the protocol for this repo" do | |
103 | + project = Project.new(path: "somewhere") | |
104 | + project.web_url_without_protocol.should == "#{Gitlab.config.gitlab.host}/somewhere" | |
105 | + end | |
106 | + | |
102 | 107 | describe "last_activity methods" do |
103 | 108 | let(:project) { create(:project) } |
104 | 109 | let(:last_event) { double(created_at: Time.now) } | ... | ... |