diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/commit_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/projects/repositories_controller.rb | 2 | ||||
-rw-r--r-- | app/models/commit.rb | 4 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 12 | ||||
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | app/models/wiki_page.rb | 4 | ||||
-rw-r--r-- | app/views/projects/wikis/history.html.haml | 6 | ||||
-rw-r--r-- | app/views/projects/wikis/pages.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/wikis/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/_file_hljs.html.haml | 13 |
10 files changed, 34 insertions, 23 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index c344297ba8a..34bd682bd90 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -19,13 +19,7 @@ class Projects::CommitController < Projects::ApplicationController [] end - begin - @diffs = @commit.diffs - rescue Grit::Git::GitTimeout - @diffs = [] - @diff_timeout = true - end - + @diffs = @commit.diffs @note = project.build_commit_note(commit) @notes_count = project.notes.for_commit_id(commit.id).count @notes = project.notes.for_commit_id(@commit.id).not_inline.fresh diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index f30eaadd928..c030320d037 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -5,7 +5,7 @@ class Projects::RepositoriesController < Projects::ApplicationController before_filter :require_non_empty_project def stats - @stats = Gitlab::Git::Stats.new(@repository.raw, @repository.root_ref) + @stats = Gitlab::Git::Stats.new(@repository.raw_repository, @repository.root_ref) @graph = @stats.graph end diff --git a/app/models/commit.rb b/app/models/commit.rb index ff5392957ce..c8b2e0475ff 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -108,4 +108,8 @@ class Commit super end + + def parents + @parents ||= Commit.decorate(super) + end end 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/repository.rb b/app/models/repository.rb index 9dd8603621f..a2bdfe87469 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -25,7 +25,7 @@ class Repository raw_repository.empty? end - def commit(id = nil) + def commit(id = 'HEAD') return nil unless raw_repository commit = Gitlab::Git::Commit.find(raw_repository, id) commit = Commit.new(commit) if commit @@ -137,7 +137,7 @@ class Repository def graph_log Rails.cache.fetch(cache_key(:graph_log)) do - stats = Gitlab::Git::GitStats.new(raw, root_ref, Gitlab.config.git.timeout) + stats = Gitlab::Git::GitStats.new(raw_repository, root_ref, Gitlab.config.git.timeout) stats.parsed_log end end 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) } |