diff --git a/Gemfile b/Gemfile index 71ac795772a581aa3efaa310d71237c3e2cc6ecf..c66d26162ce43061a288eb05fea15d95d8eb0243 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'omniauth-github' # Extracting information from a git repository # Since gollum requires grit we cannot use gitlab-grit gem name any more. Use grit instead -gem "grit", '~> 2.5.0', git: 'https://github.com/gitlabhq/grit.git', ref: '42297cdcee16284d2e4eff23d41377f52fc28b9d' +gem "grit", '~> 2.5.0', git: 'https://github.com/jacargentina/grit.git', :ref => "bd173692a99489c38a92bbe0a83b86c0b4850354" gem 'grit_ext', '~> 0.8.1' # Ruby/Rack Git Smart-HTTP Server Handler @@ -177,4 +177,4 @@ end group :production do gem "gitlab_meta", '5.0' -end +end \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index c8d75f9dc8912eb76156f9d4012e231eadcb46a8..3345197ba30e5c2d95a61bfc32fa6bdb0a2a1cf6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,16 +6,6 @@ GIT activerecord (>= 2.3.0) rake (>= 0.8.7) -GIT - remote: https://github.com/gitlabhq/grit.git - revision: 42297cdcee16284d2e4eff23d41377f52fc28b9d - ref: 42297cdcee16284d2e4eff23d41377f52fc28b9d - specs: - grit (2.5.0) - diff-lcs (~> 1.1) - mime-types (~> 1.15) - posix-spawn (~> 0.3.6) - GIT remote: https://github.com/gitlabhq/raphael-rails.git revision: cb2c92a040b9b941a5f1aa1ea866cc26e944fe58 @@ -23,14 +13,14 @@ GIT raphael-rails (2.1.0) GIT - remote: https://github.com/jonleighton/poltergeist.git - revision: 9645b52009e258921b860d3b7601d00008b22c45 - ref: 9645b52009e258921b860d3b7601d00008b22c45 + remote: https://github.com/jacargentina/grit.git + revision: bd173692a99489c38a92bbe0a83b86c0b4850354 + ref: bd173692a99489c38a92bbe0a83b86c0b4850354 specs: - poltergeist (1.1.0) - capybara (~> 2.0, >= 2.0.1) - faye-websocket (~> 0.4, >= 0.4.4) - http_parser.rb (~> 0.5.3) + grit (2.5.0) + diff-lcs (~> 1.1) + mime-types (~> 1.15) + posix-spawn (~> 0.3.6) GEM remote: https://rubygems.org/ @@ -520,6 +510,7 @@ DEPENDENCIES kaminari (~> 0.14.1) launchy letter_opener + minitest modernizr (= 2.6.2) mysql2 omniauth (~> 1.1.3) diff --git a/app/contexts/search_context.rb b/app/contexts/search_context.rb index de6542e82f407a74a5632e3571e610a50fa702d9..940aaad88920870c76676b6693a2caaef67dcd66 100644 --- a/app/contexts/search_context.rb +++ b/app/contexts/search_context.rb @@ -10,7 +10,11 @@ class SearchContext return result unless query.present? - result[:projects] = Project.where(id: project_ids).search(query).limit(10) + projects = Project.where(id: project_ids) + result[:projects] = projects.search(query).limit(10) + if projects.length == 1 + result[:files] = projects.first.files(query) + end result[:merge_requests] = MergeRequest.where(project_id: project_ids).search(query).limit(10) result[:issues] = Issue.where(project_id: project_ids).search(query).limit(10) result[:wiki_pages] = [] @@ -22,7 +26,8 @@ class SearchContext projects: [], merge_requests: [], issues: [], - wiki_pages: [] + wiki_pages: [], + files: [] } end end diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index bbd67df6c704f63e1102fe63a756890f68e9955c..238a2d67ebb1076978167aab3f057328f84de0f2 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -13,10 +13,11 @@ class SearchController < ApplicationController end result = SearchContext.new(project_ids, params).execute - + @projects = result[:projects] @merge_requests = result[:merge_requests] @issues = result[:issues] @wiki_pages = result[:wiki_pages] + @files = result[:files] end end diff --git a/app/models/project.rb b/app/models/project.rb index cad8f1666d35bb86e9f66c23c82992a85ee55a83..29b5abf0041897117bd552df2820ab0c6df04da0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -135,6 +135,7 @@ class Project < ActiveRecord::Base def access_options UsersProject.access_roles end + end def team @@ -400,4 +401,18 @@ class Project < ActiveRecord::Base def protected_branch? branch_name protected_branches_names.include?(branch_name) end + + def files query + greps = repository.repo.grep(query, default_branch) + greps.each do |g| + class << g + attr_accessor :project + attr_accessor :tree + end + g.tree = default_branch + g.project = self + end + greps + end + end diff --git a/app/views/search/_result.html.haml b/app/views/search/_result.html.haml index bfa46075baa3a2154328ba5ca355499ee4513a99..794ee814b6856bf899bfe0b80be8118a0909a458 100644 --- a/app/views/search/_result.html.haml +++ b/app/views/search/_result.html.haml @@ -32,6 +32,14 @@ %strong.term = truncate wiki_page.title, length: 50 %span.light (#{wiki_page.project.name_with_namespace}) + - @files.each do |file| + %li + file: + = link_to project_tree_path(file.project, (file.tree + "/" + file.filename), :anchor => "LC" + file.line.to_s) do + %strong.term + = file.filename + %span.light #{file.line} + %span #{file.text} :javascript $(function() { diff --git a/doc/install/installation.md b/doc/install/installation.md index 41202b09b74d277d11d310169910eaa084db05b3..3f86f24a5fb69994d4f92ddab698896432920b23 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -99,6 +99,11 @@ GitLab Shell is a ssh access and repository management software developed specia git clone https://github.com/gitlabhq/gitlab-shell.git cd gitlab-shell + + # switch to right version for v5.0 + git checkout v1.1.0 + git checkout -b v1.1.0 + cp config.yml.example config.yml # Edit config and replace gitlab_url @@ -196,7 +201,7 @@ Make sure to update username/password in config/database.yml. Download the init script (will be /etc/init.d/gitlab): - sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab + sudo curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-0-stable/init.d/gitlab sudo chmod +x /etc/init.d/gitlab Make GitLab start on boot: @@ -237,7 +242,7 @@ If you can't or don't want to use Nginx as your web server, have a look at the Download an example site config: - sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab + sudo curl --output /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-0-stable/nginx/gitlab sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab Make sure to edit the config file to match your setup: diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index c8d8d53183616ce15aa30c72d905d5616487b436..bc259e743287241baba4a512f643685c98dc0e2f 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -142,7 +142,7 @@ namespace :gitlab do return end - recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab 2>/dev/null` + recipe_content = `curl https://raw.github.com/gitlabhq/gitlab-recipes/5-0-stable/init.d/gitlab 2>/dev/null` script_content = File.read(script_path) if recipe_content == script_content