Commit 4d482b3b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'version-file' into 'master'

Version file

Fixes #1345
parents 10a33f0f af7e7798
...@@ -128,6 +128,7 @@ class Repository ...@@ -128,6 +128,7 @@ class Repository
Rails.cache.delete(cache_key(:commit_count)) Rails.cache.delete(cache_key(:commit_count))
Rails.cache.delete(cache_key(:graph_log)) Rails.cache.delete(cache_key(:graph_log))
Rails.cache.delete(cache_key(:readme)) Rails.cache.delete(cache_key(:readme))
Rails.cache.delete(cache_key(:version))
Rails.cache.delete(cache_key(:contribution_guide)) Rails.cache.delete(cache_key(:contribution_guide))
end end
...@@ -156,12 +157,24 @@ class Repository ...@@ -156,12 +157,24 @@ class Repository
Gitlab::Git::Blob.find(self, sha, path) Gitlab::Git::Blob.find(self, sha, path)
end end
def blob_by_oid(oid)
Gitlab::Git::Blob.raw(self, oid)
end
def readme def readme
Rails.cache.fetch(cache_key(:readme)) do Rails.cache.fetch(cache_key(:readme)) do
tree(:head).readme tree(:head).readme
end end
end end
def version
Rails.cache.fetch(cache_key(:version)) do
tree(:head).blobs.find do |file|
file.name.downcase == 'version'
end
end
end
def contribution_guide def contribution_guide
Rails.cache.fetch(cache_key(:contribution_guide)) do Rails.cache.fetch(cache_key(:contribution_guide)) do
tree(:head).contribution_guide tree(:head).contribution_guide
......
...@@ -44,6 +44,12 @@ ...@@ -44,6 +44,12 @@
= link_to project_blob_path(@project, tree_join(@repository.root_ref, readme.name)), class: 'btn btn-block' do = link_to project_blob_path(@project, tree_join(@repository.root_ref, readme.name)), class: 'btn btn-block' do
= readme.name = readme.name
- if @repository.version
- version = @repository.version
= link_to project_blob_path(@project, tree_join(@repository.root_ref, version.name)), class: 'btn btn-block' do
Version:
= @repository.blob_by_oid(version.id).data
.prepend-top-10 .prepend-top-10
%p %p
%span.light Created on %span.light Created on
......
...@@ -24,3 +24,8 @@ Feature: Project Feature ...@@ -24,3 +24,8 @@ Feature: Project Feature
When I visit edit project "Shop" page When I visit edit project "Shop" page
And change project path settings And change project path settings
Then I should see project with new path settings Then I should see project with new path settings
Scenario: I should see project readme and version
When I visit project "Shop" page
Then I should see project "Shop" README link
And I should see project "Shop" version
...@@ -24,4 +24,16 @@ class ProjectFeature < Spinach::FeatureSteps ...@@ -24,4 +24,16 @@ class ProjectFeature < Spinach::FeatureSteps
step 'I should see project with new path settings' do step 'I should see project with new path settings' do
project.path.should == "new-path" project.path.should == "new-path"
end end
step 'I should see project "Shop" README link' do
within '.project-side' do
page.should have_content "README.md"
end
end
step 'I should see project "Shop" version' do
within '.project-side' do
page.should have_content "Version: 2.2.0"
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment