From ef968fd0c8a61d63283e9f7aba4a07809d87bc16 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 21 Mar 2013 22:22:21 +0200 Subject: [PATCH 01/16] fix commit-description css on commit.show --- app/assets/stylesheets/sections/commits.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/stylesheets/sections/commits.scss b/app/assets/stylesheets/sections/commits.scss index 0df39298c89..1e564188892 100644 --- a/app/assets/stylesheets/sections/commits.scss +++ b/app/assets/stylesheets/sections/commits.scss @@ -413,3 +413,9 @@ padding: 4px; background-color: #EEE; } + +.commit-description { + background: none; + border: none; + margin: 0; +} -- GitLab From 0e4b2395a9612d67255f5101452a2e79334c4352 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 22 Mar 2013 15:08:02 +0200 Subject: [PATCH 02/16] Fix lines and line numbers being squashed in File -> blame --- app/views/blame/show.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml index 36d81e6af38..62516266536 100644 --- a/app/views/blame/show.html.haml +++ b/app/views/blame/show.html.haml @@ -38,9 +38,11 @@ - current_line += 1 - else - lines.each do |line| - = current_line + :preserve + #{current_line} - current_line += 1 %td.lines %pre - lines.each do |line| - = line + :preserve + #{line} -- GitLab From 5c49cf6ca170aba7646f53d02130c79c0c4470a6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 22 Mar 2013 15:11:16 +0200 Subject: [PATCH 03/16] fix blame view head nav --- app/views/blame/_head.html.haml | 9 ++------- app/views/blame/show.html.haml | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/views/blame/_head.html.haml b/app/views/blame/_head.html.haml index ef9e6c9c532..3a883829562 100644 --- a/app/views/blame/_head.html.haml +++ b/app/views/blame/_head.html.haml @@ -1,7 +1,2 @@ -%ul.nav.nav-tabs - %li - = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} - = nav_link(controller: :refs) do - = link_to 'Source', project_tree_path(@project, @ref) - %li.pull-right - = render "shared/clone_panel" +%div.tree-ref-holder + = render 'shared/ref_switcher', destination: 'tree', path: params[:path] diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml index 62516266536..f85dde6dbbf 100644 --- a/app/views/blame/show.html.haml +++ b/app/views/blame/show.html.haml @@ -3,7 +3,7 @@ #tree-holder.tree-holder %ul.breadcrumb %li - %span.arrow + %i.icon-angle-right = link_to project_tree_path(@project, @ref) do = @project.name - @tree.breadcrumbs(6) do |link| -- GitLab From 0c7f426037db668fbd9ad11376b4db0007baafce Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 22 Mar 2013 18:52:25 +0200 Subject: [PATCH 04/16] fix xss issue in blame --- app/views/blame/show.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml index f85dde6dbbf..b2a45ef5303 100644 --- a/app/views/blame/show.html.haml +++ b/app/views/blame/show.html.haml @@ -38,11 +38,11 @@ - current_line += 1 - else - lines.each do |line| - :preserve - #{current_line} + = current_line + \ - current_line += 1 %td.lines %pre - lines.each do |line| - :preserve - #{line} + = line + \ -- GitLab From 017c19bbe4e9098e161b8cc0e866d644e7d3ae95 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Mon, 25 Mar 2013 12:00:57 +0100 Subject: [PATCH 05/16] Fixed type --- doc/install/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 69d3b186b32..a0ff9a26870 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -1,6 +1,6 @@ This installation guide was created for Debian/Ubuntu and tested on it. Please read [`doc/install/requirements.md`](./requirements.md) for hardware and platform requirements. -This installation guide is recommended to set up a production server. If you want a development environment please use the [Vargrant virtual machine](https://github.com/gitlabhq/gitlab-vagrant-vm) since it makes it much easier to set up all the dependencies for integration testing. +This installation guide is recommended to set up a production server. If you want a development environment please use the [Vagrant virtual machine](https://github.com/gitlabhq/gitlab-vagrant-vm) since it makes it much easier to set up all the dependencies for integration testing. **Important Note:** The following steps have been known to work. -- GitLab From 6a09b21df677e5115f46d3e52ffaf553f4276f85 Mon Sep 17 00:00:00 2001 From: Oluf Lorenzen Date: Thu, 28 Mar 2013 18:53:26 +0100 Subject: [PATCH 06/16] switch gitlab-shell to correct version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a gitlab:check does say that you need v1.1.0 of gitlab-shell... --- doc/install/installation.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/install/installation.md b/doc/install/installation.md index a0ff9a26870..853a6e78364 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -106,6 +106,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 -- GitLab From 34136d381fe733e7465700a043c7a3a27c8c0ec6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 30 Mar 2013 13:14:19 +0200 Subject: [PATCH 07/16] Use latest gitlab-grit fork to prevent gollum override gitlab-grit. Fixes issues related to gpg signed commits and other fixes from gitlab/grit fork --- Gemfile | 3 ++- Gemfile.lock | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 7f92cb75d30..494f331ef2a 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,8 @@ gem 'omniauth-twitter' gem 'omniauth-github' # Extracting information from a git repository -gem "gitlab-grit", '~> 1.0.0', require: 'grit' +# 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: 'c15e2758ec75f99230cd0fbcc9110bf932c0bf05' gem 'grit_ext', '~> 0.6.2' # Ruby/Rack Git Smart-HTTP Server Handler diff --git a/Gemfile.lock b/Gemfile.lock index 4de5c893ff8..7b779dbcad9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,6 +23,16 @@ GIT activerecord (>= 2.3.0) rake (>= 0.8.7) +GIT + remote: https://github.com/gitlabhq/grit.git + revision: c15e2758ec75f99230cd0fbcc9110bf932c0bf05 + ref: c15e2758ec75f99230cd0fbcc9110bf932c0bf05 + 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 @@ -166,10 +176,6 @@ GEM github-markup (0.7.5) gitlab-grack (1.0.0) rack (~> 1.4.1) - gitlab-grit (1.0.0) - diff-lcs (~> 1.1) - mime-types (~> 1.15) - posix-spawn (~> 0.3.6) gitlab-pygments.rb (0.3.2) posix-spawn (~> 0.3.6) yajl-ruby (~> 1.1.0) @@ -194,10 +200,6 @@ GEM grape-entity (0.2.0) activesupport multi_json (>= 1.3.2) - grit (2.5.0) - diff-lcs (~> 1.1) - mime-types (~> 1.15) - posix-spawn (~> 0.3.6) grit_ext (0.6.2) charlock_holmes (~> 0.6.9) growl (1.0.3) @@ -521,7 +523,6 @@ DEPENDENCIES github-linguist (~> 2.3.4) github-markup (~> 0.7.4) gitlab-grack (~> 1.0.0) - gitlab-grit (~> 1.0.0) gitlab-pygments.rb (~> 0.3.2) gitlab_meta (= 5.0) gitlab_omniauth-ldap (= 1.0.2) @@ -530,6 +531,7 @@ DEPENDENCIES gon grape (~> 0.3.1) grape-entity (~> 0.2.0) + grit (~> 2.5.0)! grit_ext (~> 0.6.2) growl guard-rspec -- GitLab From 8b761574bd629cf5a6ddb0e169fff019d55ad415 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 30 Mar 2013 16:37:41 +0200 Subject: [PATCH 08/16] fix gollum --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 494f331ef2a..e1e5bba238f 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: 'c15e2758ec75f99230cd0fbcc9110bf932c0bf05' +gem "grit", '~> 2.5.0', git: 'https://github.com/gitlabhq/grit.git', ref: 'c40a32432616a07fa7fc3c32c24ab73ad6a9718f' gem 'grit_ext', '~> 0.6.2' # Ruby/Rack Git Smart-HTTP Server Handler diff --git a/Gemfile.lock b/Gemfile.lock index 7b779dbcad9..9614a07c5fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,8 +25,8 @@ GIT GIT remote: https://github.com/gitlabhq/grit.git - revision: c15e2758ec75f99230cd0fbcc9110bf932c0bf05 - ref: c15e2758ec75f99230cd0fbcc9110bf932c0bf05 + revision: c40a32432616a07fa7fc3c32c24ab73ad6a9718f + ref: c40a32432616a07fa7fc3c32c24ab73ad6a9718f specs: grit (2.5.0) diff-lcs (~> 1.1) -- GitLab From 907a8f42a2224dc8ec796717213bf02388c1c364 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 4 Apr 2013 11:10:09 +0300 Subject: [PATCH 09/16] 5.0.1 --- CHANGELOG | 3 +++ VERSION | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 62792fcf5a6..dbe60f4650b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +v 5.0.1 + - Fixed issue with gitlab-grit being overrided by grit + v 5.0.0 - Replaced gitolite with gitlab-shell - Removed gitolite-related libraries diff --git a/VERSION b/VERSION index 0062ac97180..6b244dcd696 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.0 +5.0.1 -- GitLab From b6e71360b4929ad9ebd9aa0ce49d94c9bac7b577 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 6 Apr 2013 10:25:33 +0300 Subject: [PATCH 10/16] fix resicpes to point 5-0-stable branch --- doc/install/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index 853a6e78364..0ddd2cc5462 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -208,7 +208,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: @@ -249,7 +249,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: -- GitLab From 1daa75fd156cf93e6ec85cf660a845928b8be9f3 Mon Sep 17 00:00:00 2001 From: Dennis Boldt Date: Sat, 6 Apr 2013 12:47:57 +0200 Subject: [PATCH 11/16] Fixed check.rake due to #3530 --- lib/tasks/gitlab/check.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index 855227fb34f..b30079ff483 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 -- GitLab From 16633477c378d274142bf428cbd1dc9186a0549f Mon Sep 17 00:00:00 2001 From: Javier Castro Date: Fri, 12 Apr 2013 01:07:05 -0300 Subject: [PATCH 12/16] First approach to code search feature --- Gemfile | 6 ++++-- Gemfile.lock | 24 +++++++++++++----------- app/contexts/search_context.rb | 10 ++++++++-- app/controllers/search_controller.rb | 3 ++- app/models/project.rb | 15 +++++++++++++++ app/views/search/_result.html.haml | 8 ++++++++ 6 files changed, 50 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index e1e5bba238f..7f128c80756 100644 --- a/Gemfile +++ b/Gemfile @@ -23,8 +23,8 @@ 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: 'c40a32432616a07fa7fc3c32c24ab73ad6a9718f' -gem 'grit_ext', '~> 0.6.2' +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 gem 'gitlab-grack', '~> 1.0.0', require: 'grack' @@ -187,3 +187,5 @@ end group :production do gem "gitlab_meta", '5.0' end + +gem 'minitest' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 9614a07c5fa..0c16ca418d8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -24,21 +24,21 @@ GIT rake (>= 0.8.7) GIT - remote: https://github.com/gitlabhq/grit.git - revision: c40a32432616a07fa7fc3c32c24ab73ad6a9718f - ref: c40a32432616a07fa7fc3c32c24ab73ad6a9718f + remote: https://github.com/gitlabhq/raphael-rails.git + revision: cb2c92a040b9b941a5f1aa1ea866cc26e944fe58 + specs: + raphael-rails (2.1.0) + +GIT + remote: https://github.com/jacargentina/grit.git + revision: bd173692a99489c38a92bbe0a83b86c0b4850354 + ref: bd173692a99489c38a92bbe0a83b86c0b4850354 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 - specs: - raphael-rails (2.1.0) - GEM remote: https://rubygems.org/ specs: @@ -200,7 +200,7 @@ GEM grape-entity (0.2.0) activesupport multi_json (>= 1.3.2) - grit_ext (0.6.2) + grit_ext (0.8.1) charlock_holmes (~> 0.6.9) growl (1.0.3) guard (1.5.4) @@ -257,6 +257,7 @@ GEM treetop (~> 1.4.8) method_source (0.8.1) mime-types (1.21) + minitest (4.7.1) modernizr (2.6.2) sprockets (~> 2.0) multi_json (1.7.1) @@ -532,7 +533,7 @@ DEPENDENCIES grape (~> 0.3.1) grape-entity (~> 0.2.0) grit (~> 2.5.0)! - grit_ext (~> 0.6.2) + grit_ext (~> 0.8.1) growl guard-rspec guard-spinach @@ -544,6 +545,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 9becb8d674f..912b47f4ef4 100644 --- a/app/contexts/search_context.rb +++ b/app/contexts/search_context.rb @@ -10,10 +10,15 @@ 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] = Wiki.where(project_id: project_ids).search(query).limit(10) + result end @@ -22,7 +27,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 bbd67df6c70..238a2d67ebb 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 b13b2918652..06bb0d38578 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 @@ -399,4 +400,18 @@ class Project < ActiveRecord::Base def protected_branch? branch_name protected_branches.map(&:name).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 bfa46075baa..794ee814b68 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() { -- GitLab From 2bc1df0a9d2014c70219a6c2f99728b47b571939 Mon Sep 17 00:00:00 2001 From: Oluf Lorenzen Date: Thu, 28 Mar 2013 18:53:26 +0100 Subject: [PATCH 13/16] switch gitlab-shell to correct version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a gitlab:check does say that you need v1.1.0 of gitlab-shell... --- doc/install/installation.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/install/installation.md b/doc/install/installation.md index 41202b09b74..fb06fa09d20 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 -- GitLab From b3947328da8fd0abdf56ff707c45523f57cfe3b0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sat, 6 Apr 2013 10:25:33 +0300 Subject: [PATCH 14/16] fix resicpes to point 5-0-stable branch --- doc/install/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index fb06fa09d20..3f86f24a5fb 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -201,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: @@ -242,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: -- GitLab From bab3bfaabaca0cec2a43b1bd8facca448e45ad94 Mon Sep 17 00:00:00 2001 From: Dennis Boldt Date: Sat, 6 Apr 2013 12:47:57 +0200 Subject: [PATCH 15/16] Fixed check.rake due to #3530 --- lib/tasks/gitlab/check.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index c8d8d531836..bc259e74328 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 -- GitLab From 95a2f3bffe333acfcee7bcd9844c0ec71344fa8a Mon Sep 17 00:00:00 2001 From: Javier Castro Date: Fri, 12 Apr 2013 01:07:05 -0300 Subject: [PATCH 16/16] First approach to code search feature --- Gemfile | 4 +++- Gemfile.lock | 30 ++++++++++++---------------- app/contexts/search_context.rb | 9 +++++++-- app/controllers/search_controller.rb | 3 ++- app/models/project.rb | 15 ++++++++++++++ app/views/search/_result.html.haml | 8 ++++++++ 6 files changed, 48 insertions(+), 21 deletions(-) diff --git a/Gemfile b/Gemfile index 71ac795772a..ff140da48a6 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 @@ -178,3 +178,5 @@ end group :production do gem "gitlab_meta", '5.0' end + +gem 'minitest' diff --git a/Gemfile.lock b/Gemfile.lock index c8d75f9dc89..d2ccaf08f4a 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/ @@ -248,7 +238,12 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) method_source (0.8.1) +<<<<<<< HEAD mime-types (1.22) +======= + mime-types (1.21) + minitest (4.7.1) +>>>>>>> First approach to code search feature modernizr (2.6.2) sprockets (~> 2.0) multi_json (1.7.2) @@ -520,6 +515,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 de6542e82f4..940aaad8892 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 bbd67df6c70..238a2d67ebb 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 cad8f1666d3..29b5abf0041 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 bfa46075baa..794ee814b68 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() { -- GitLab