summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-25 13:56:23 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-25 13:56:23 +0300
commit4b65b0e0f5804492e90c3ee8037739c47bcc354b (patch)
tree700b172cc1402fd7aeab11eb13f7e6e69ed0276d
parentb13c1469a317a36a72e87fa92972e440fc8438e5 (diff)
downloadgitlab-ce-use-more-rugged.tar.gz
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--Gemfile4
-rw-r--r--Gemfile.lock8
-rw-r--r--app/models/project_wiki.rb12
-rw-r--r--app/models/wiki_page.rb4
-rw-r--r--app/views/projects/wikis/history.html.haml6
-rw-r--r--app/views/projects/wikis/pages.html.haml2
-rw-r--r--app/views/projects/wikis/show.html.haml2
-rw-r--r--app/views/shared/_file_hljs.html.haml13
-rw-r--r--lib/gitlab/project_search_results.rb12
9 files changed, 40 insertions, 23 deletions
diff --git a/Gemfile b/Gemfile
index c1d13aa51a9..f4907f4cda2 100644
--- a/Gemfile
+++ b/Gemfile
@@ -31,8 +31,8 @@ gem 'omniauth-shibboleth'
# Extracting information from a git repository
# Provide access to Gitlab::Git library
-# gem "gitlab_git", '~> 6.0', path: '../../gitlab_git'
-gem "gitlab_git", '~> 6.0', git: 'https://gitlab.com/gitlab-org/gitlab_git.git', ref: '97c160e0cbc54d9b5803030e5cc49157440bbe2a'
+# gem "gitlab_git", path: '../../gitlab_git'
+gem "gitlab_git", git: 'https://gitlab.com/gitlab-org/gitlab_git.git', ref: '187ff05aef6fc5390a2d666f35f84de0db9777b7'
# Ruby/Rack Git Smart-HTTP Server Handler
gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
diff --git a/Gemfile.lock b/Gemfile.lock
index 1e5228acaa3..22e97798d87 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,9 +1,9 @@
GIT
remote: https://gitlab.com/gitlab-org/gitlab_git.git
- revision: 97c160e0cbc54d9b5803030e5cc49157440bbe2a
- ref: 97c160e0cbc54d9b5803030e5cc49157440bbe2a
+ revision: 187ff05aef6fc5390a2d666f35f84de0db9777b7
+ ref: 187ff05aef6fc5390a2d666f35f84de0db9777b7
specs:
- gitlab_git (6.3.0)
+ gitlab_git (7.0.0.pre)
activesupport (~> 4.0)
charlock_holmes (~> 0.6)
gitlab-linguist (~> 3.0)
@@ -624,7 +624,7 @@ DEPENDENCIES
gitlab-grack (~> 2.0.0.pre)
gitlab-linguist (~> 3.0.0)
gitlab_emoji (~> 0.0.1.1)
- gitlab_git (~> 6.0)!
+ gitlab_git!
gitlab_meta (= 7.0)
gitlab_omniauth-ldap (= 1.1.0)
gollum-lib (~> 3.0.0)
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index a82a300a672..770a26ed894 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -107,6 +107,18 @@ class ProjectWiki
[title.gsub(/\.[^.]*$/, ""), title_array.join("/")]
end
+ def search_files(query)
+ repository.search_files(query, default_branch)
+ end
+
+ def repository
+ Repository.new(path_with_namespace, default_branch)
+ end
+
+ def default_branch
+ wiki.class.default_ref
+ end
+
private
def create_repo!
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index b8a0a9eb58b..b9ab6702c53 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -87,14 +87,14 @@ class WikiPage
def version
return nil unless persisted?
- @version ||= Commit.new(Gitlab::Git::Commit.new(@page.version))
+ @version ||= @page.version
end
# Returns an array of Gitlab Commit instances.
def versions
return [] unless persisted?
- @page.versions.map { |v| Commit.new(Gitlab::Git::Commit.new(v)) }
+ @page.versions
end
def commit
diff --git a/app/views/projects/wikis/history.html.haml b/app/views/projects/wikis/history.html.haml
index 7bc566cf7f5..d3a66c48c9b 100644
--- a/app/views/projects/wikis/history.html.haml
+++ b/app/views/projects/wikis/history.html.haml
@@ -17,11 +17,11 @@
%tr
%td
= link_to project_wiki_path(@project, @page, version_id: commit.id) do
- = commit.short_id
+ = commit.id[0..10]
%td
- = commit_author_link(commit, avatar: true, size: 24)
+ = commit.author.name
%td
- = commit.title
+ = commit.message
%td
#{time_ago_with_tooltip(version.date)}
%td
diff --git a/app/views/projects/wikis/pages.html.haml b/app/views/projects/wikis/pages.html.haml
index 74317faf9d6..264b48ec36c 100644
--- a/app/views/projects/wikis/pages.html.haml
+++ b/app/views/projects/wikis/pages.html.haml
@@ -8,5 +8,5 @@
= link_to wiki_page.title, project_wiki_path(@project, wiki_page)
%small (#{wiki_page.format})
.pull-right
- %small Last edited #{time_ago_with_tooltip(wiki_page.commit.created_at)}
+ %small Last edited #{time_ago_with_tooltip(wiki_page.commit.authored_date)}
= paginate @wiki_pages, theme: 'gitlab'
diff --git a/app/views/projects/wikis/show.html.haml b/app/views/projects/wikis/show.html.haml
index cb923e4ca32..ede4fef9e24 100644
--- a/app/views/projects/wikis/show.html.haml
+++ b/app/views/projects/wikis/show.html.haml
@@ -17,4 +17,4 @@
%hr
.wiki-last-edit-by
- Last edited by #{commit_author_link(@page.commit, avatar: true, size: 16)} #{time_ago_with_tooltip(@page.commit.created_at)}
+ Last edited by #{@page.commit.author.name} #{time_ago_with_tooltip(@page.commit.authored_date)}
diff --git a/app/views/shared/_file_hljs.html.haml b/app/views/shared/_file_hljs.html.haml
index 7dd97c2b25c..cbc01bd60e0 100644
--- a/app/views/shared/_file_hljs.html.haml
+++ b/app/views/shared/_file_hljs.html.haml
@@ -1,11 +1,12 @@
%div.highlighted-data{class: user_color_scheme_class}
.line-numbers
- - blob.data.lines.to_a.size.times do |index|
- - offset = defined?(first_line_number) ? first_line_number : 1
- - i = index + offset
- = link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do
- %i.icon-link
- = i
+ - if blob.data.present?
+ - blob.data.lines.to_a.size.times do |index|
+ - offset = defined?(first_line_number) ? first_line_number : 1
+ - i = index + offset
+ = link_to "#L#{i}", id: "L#{i}", rel: "#L#{i}" do
+ %i.icon-link
+ = i
.highlight
%pre
%code{ class: highlightjs_class(blob.name) }
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb
index 9dc8b34d9c7..e5a04c3d9cf 100644
--- a/lib/gitlab/project_search_results.rb
+++ b/lib/gitlab/project_search_results.rb
@@ -4,7 +4,11 @@ module Gitlab
def initialize(project_id, query, repository_ref = nil)
@project = Project.find(project_id)
- @repository_ref = repository_ref
+ @repository_ref = if repository_ref.present?
+ repository_ref
+ else
+ nil
+ end
@query = Shellwords.shellescape(query) if query.present?
end
@@ -50,10 +54,10 @@ module Gitlab
def wiki_blobs
if project.wiki_enabled?
- wiki_repo = Repository.new(ProjectWiki.new(project).path_with_namespace)
+ project_wiki = ProjectWiki.new(project)
- if wiki_repo.exists?
- wiki_repo.search_files(query)
+ unless project_wiki.empty?
+ project_wiki.search_files(query)
else
[]
end