From d7bcfe4fc020529f9b6ed2a75dfb2f31acded080 Mon Sep 17 00:00:00 2001 From: Dirceu Pereira Tiegs Date: Wed, 14 Oct 2015 20:14:24 -0300 Subject: Fix issue #3055 (project search with unmatched parentheses) --- app/models/repository.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/repository.rb b/app/models/repository.rb index 8b51602bc23..04e1114608b 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -482,7 +482,7 @@ class Repository def search_files(query, ref) offset = 2 - args = %W(git grep -i -n --before-context #{offset} --after-context #{offset} #{query} #{ref || root_ref}) + args = %W(git grep -i -n --before-context #{offset} --after-context #{offset} -e #{query} #{ref || root_ref}) Gitlab::Popen.popen(args, path_to_repo).first.scrub.split(/^--$/) end -- cgit v1.2.1 From fe6ec80e75d35b8ead20e1cf8f797cc3ffee3f9b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 23 Oct 2015 17:01:10 +0200 Subject: Render CI status on merge requests index page Signed-off-by: Dmitriy Zaporozhets --- app/models/merge_request.rb | 10 ++++++++-- app/views/projects/merge_requests/_merge_request.html.haml | 4 ++++ app/views/projects/merge_requests/widget/_heading.html.haml | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 8d9ad44681d..85f37e49e62 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -159,11 +159,11 @@ class MergeRequest < ActiveRecord::Base def last_commit merge_request_diff ? merge_request_diff.last_commit : compare_commits.last - end + end def first_commit merge_request_diff ? merge_request_diff.first_commit : compare_commits.first - end + end def last_commit_short_sha last_commit.short_id @@ -470,4 +470,10 @@ class MergeRequest < ActiveRecord::Base unlock_mr if locked? end end + + def ci_commit + if last_commit + source_project.ci_commit(last_commit.id) + end + end end diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index 25e4e8ba80d..f9409be5cfa 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -1,3 +1,4 @@ +- ci_commit = merge_request.ci_commit %li{ class: mr_css_classes(merge_request) } .merge-request-title %span.merge-request-title-text @@ -6,6 +7,9 @@ - merge_request.labels.each do |label| = link_to_label(label, project: merge_request.project) .pull-right.light + - if ci_commit + = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}" do + = ci_status_icon(ci_commit) - if merge_request.merged? %span %i.fa.fa-check diff --git a/app/views/projects/merge_requests/widget/_heading.html.haml b/app/views/projects/merge_requests/widget/_heading.html.haml index 10efb811939..a3551516bfe 100644 --- a/app/views/projects/merge_requests/widget/_heading.html.haml +++ b/app/views/projects/merge_requests/widget/_heading.html.haml @@ -1,4 +1,4 @@ -- ci_commit = @merge_request.source_project.ci_commit(@merge_request.source_sha) +- ci_commit = @merge_request.ci_commit - if ci_commit - status = ci_commit.status .mr-widget-heading -- cgit v1.2.1 From 7b06c83cf72d24edab7adcc00f4000830539506e Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 23 Oct 2015 17:01:25 +0200 Subject: Add tests for MR index page Signed-off-by: Dmitriy Zaporozhets --- app/views/projects/merge_requests/_merge_request.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index f9409be5cfa..a285d5d660e 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -8,7 +8,8 @@ = link_to_label(label, project: merge_request.project) .pull-right.light - if ci_commit - = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}" do + = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", + title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do = ci_status_icon(ci_commit) - if merge_request.merged? %span -- cgit v1.2.1 From 696a7084010315078c38507cccabb236bb3d794a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 23 Oct 2015 17:32:52 +0200 Subject: Move rendering CI status to helper Signed-off-by: Dmitriy Zaporozhets --- app/helpers/ci_status_helper.rb | 7 +++++++ app/views/projects/commits/_commit.html.haml | 3 +-- app/views/projects/merge_requests/_merge_request.html.haml | 4 +--- app/views/shared/projects/_project.html.haml | 4 +--- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index dbd1e26fa79..ceafe5e8c91 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -42,4 +42,11 @@ module CiStatusHelper icon(icon_name) end + + def render_ci_status(ci_commit) + link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", + title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do + ci_status_icon(ci_commit) + end + end end diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index cddd5aa3a83..b7998dd12c1 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -18,8 +18,7 @@ .pull-right - if ci_commit - = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}" do - = ci_status_icon(ci_commit) + = render_ci_status(ci_commit)   = link_to commit.short_id, namespace_project_commit_path(project.namespace, project, commit), class: "commit_short_id" diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index a285d5d660e..300a3715292 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -8,9 +8,7 @@ = link_to_label(label, project: merge_request.project) .pull-right.light - if ci_commit - = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", - title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do - = ci_status_icon(ci_commit) + = render_ci_status(ci_commit) - if merge_request.merged? %span %i.fa.fa-check diff --git a/app/views/shared/projects/_project.html.haml b/app/views/shared/projects/_project.html.haml index aee839b44e7..c36995b94d7 100644 --- a/app/views/shared/projects/_project.html.haml +++ b/app/views/shared/projects/_project.html.haml @@ -21,9 +21,7 @@ .project-controls - if ci && !project.empty_repo? && project.commit - if ci_commit = project.ci_commit(project.commit.sha) - = link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", - title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do - = ci_status_icon(ci_commit) + = render_ci_status(ci_commit)   - if stars %span -- cgit v1.2.1 From 5615f2737cb034d3d8de70e1e50f1ba8ca78c34d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 23 Oct 2015 18:21:43 +0200 Subject: Fix rubocop issues Signed-off-by: Dmitriy Zaporozhets --- app/helpers/ci_status_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb index ceafe5e8c91..ed88df5dd86 100644 --- a/app/helpers/ci_status_helper.rb +++ b/app/helpers/ci_status_helper.rb @@ -44,8 +44,10 @@ module CiStatusHelper end def render_ci_status(ci_commit) - link_to ci_status_path(ci_commit), class: "c#{ci_status_color(ci_commit)}", - title: "Build status: #{ci_commit.status}", data: {toggle: 'tooltip', placement: 'left'} do + link_to ci_status_path(ci_commit), + class: "c#{ci_status_color(ci_commit)}", + title: "Build status: #{ci_commit.status}", + data: { toggle: 'tooltip', placement: 'left' } do ci_status_icon(ci_commit) end end -- cgit v1.2.1