summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-11 19:43:56 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-05-11 19:43:56 +0000
commite1a8089cc2a54126596abae50f2987e2421b1dc3 (patch)
tree15bc0e5a26f3c9ef746bbc969544fd7c04006bc0
parent95a470cf5087abcd497ef3b260f443ae3ffebeef (diff)
parentaa4d19904418cf57369ab9c80d05730c03636baf (diff)
downloadgitlab-ce-e1a8089cc2a54126596abae50f2987e2421b1dc3.tar.gz
Merge branch 'create-merge-request' into 'master'
Add Create Merge Request buttons to commits page and push event. Commits page: ![Screen_Shot_2015-05-09_at_22.27.09](https://gitlab.com/gitlab-org/gitlab-ce/uploads/f77c2e47f768b2fc132de6e3a2a0323e/Screen_Shot_2015-05-09_at_22.27.09.png) Branches page: ![Screen_Shot_2015-05-09_at_22.55.24](https://gitlab.com/gitlab-org/gitlab-ce/uploads/b0a6374f5c5d830ef19de9694e603c8f/Screen_Shot_2015-05-09_at_22.55.24.png) Push event: (Only for new branches, and only shown to the pushing user) ![Screen_Shot_2015-05-09_at_22.27.21](https://gitlab.com/gitlab-org/gitlab-ce/uploads/989c9cb66ee03d09b96809452749d2b8/Screen_Shot_2015-05-09_at_22.27.21.png) Push event with multiple commits and a Compare link: ![Screen_Shot_2015-05-09_at_22.28.01](https://gitlab.com/gitlab-org/gitlab-ce/uploads/a70c718e559f69177f9341c0af92707c/Screen_Shot_2015-05-09_at_22.28.01.png) See merge request !632
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/projects/compare_controller.rb3
-rw-r--r--app/helpers/compare_helper.rb25
-rw-r--r--app/views/events/event/_push.html.haml14
-rw-r--r--app/views/projects/branches/_branch.html.haml11
-rw-r--r--app/views/projects/commits/_head.html.haml2
-rw-r--r--app/views/projects/commits/show.html.haml16
-rw-r--r--app/views/projects/compare/_form.html.haml7
-rw-r--r--features/steps/project/commits/commits.rb2
9 files changed, 52 insertions, 29 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 57567728b49..5c4634fb151 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -50,6 +50,7 @@ v 7.11.0 (unreleased)
- Add footnotes support to Markdown (Guillaume Delbergue)
- Add current_sign_in_at to UserFull REST api.
- Make Sidekiq MemoryKiller shutdown signal configurable
+ - Add "Create Merge Request" buttons to commits and branches pages and push event.
v 7.10.2
- Fix CI links on MR page
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index 7c20b81c0b1..c5f085c236f 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -6,11 +6,12 @@ class Projects::CompareController < Projects::ApplicationController
before_action :authorize_download_code!
def index
+ @ref = Addressable::URI.unescape(params[:to])
end
def show
base_ref = Addressable::URI.unescape(params[:from])
- head_ref = Addressable::URI.unescape(params[:to])
+ @ref = head_ref = Addressable::URI.unescape(params[:to])
compare_result = CompareService.new.execute(
current_user,
diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb
index 01847c6b807..f1dc906cab4 100644
--- a/app/helpers/compare_helper.rb
+++ b/app/helpers/compare_helper.rb
@@ -1,21 +1,20 @@
module CompareHelper
- def compare_to_mr_button?
- @project.merge_requests_enabled &&
- params[:from].present? &&
- params[:to].present? &&
- @repository.branch_names.include?(params[:from]) &&
- @repository.branch_names.include?(params[:to]) &&
- params[:from] != params[:to] &&
- !@refs_are_same
+ def create_mr_button?(from = params[:from], to = params[:to], project = @project)
+ from.present? &&
+ to.present? &&
+ from != to &&
+ project.merge_requests_enabled &&
+ project.repository.branch_names.include?(from) &&
+ project.repository.branch_names.include?(to)
end
- def compare_mr_path
+ def create_mr_path(from = params[:from], to = params[:to], project = @project)
new_namespace_project_merge_request_path(
- @project.namespace,
- @project,
+ project.namespace,
+ project,
merge_request: {
- source_branch: params[:to],
- target_branch: params[:from]
+ source_branch: to,
+ target_branch: from
}
)
end
diff --git a/app/views/events/event/_push.html.haml b/app/views/events/event/_push.html.haml
index 60d7978b13f..1da702be384 100644
--- a/app/views/events/event/_push.html.haml
+++ b/app/views/events/event/_push.html.haml
@@ -17,15 +17,27 @@
- few_commits.each do |commit|
= render "events/commit", commit: commit, project: project
+ - create_mr = current_user == event.author && event.new_ref? && create_mr_button?(event.project.default_branch, event.ref_name, event.project)
- if event.commits_count > 1
%li.commits-stat
- if event.commits_count > 2
%span ... and #{event.commits_count - 2} more commits.
+
- if event.md_ref?
- from = event.commit_from
- from_label = truncate_sha(from)
- else
- from = event.project.default_branch
- from_label = from
+
= link_to namespace_project_compare_path(event.project.namespace, event.project, from: from, to: event.commit_to) do
- %strong Compare &rarr; #{from_label}...#{truncate_sha(event.commit_to)}
+ Compare #{from_label}...#{truncate_sha(event.commit_to)}
+
+ - if create_mr
+ or
+ = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do
+ create a merge request
+ - elsif create_mr
+ %li.commits-stat
+ = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do
+ Create Merge Request
diff --git a/app/views/projects/branches/_branch.html.haml b/app/views/projects/branches/_branch.html.haml
index 4e7415be4aa..43412624da6 100644
--- a/app/views/projects/branches/_branch.html.haml
+++ b/app/views/projects/branches/_branch.html.haml
@@ -10,16 +10,19 @@
%i.fa.fa-lock
protected
.pull-right
- - if can?(current_user, :download_code, @project)
- = render 'projects/repositories/download_archive', ref: branch.name, btn_class: 'btn-grouped btn-group-xs'
+ - if create_mr_button?(@repository.root_ref, branch.name)
+ = link_to create_mr_path(@repository.root_ref, branch.name), class: 'btn btn-grouped btn-xs' do
+ = icon('plus')
+ Merge Request
+
- if branch.name != @repository.root_ref
= link_to namespace_project_compare_index_path(@project.namespace, @project, from: @repository.root_ref, to: branch.name), class: 'btn btn-grouped btn-xs', method: :post, title: "Compare" do
- %i.fa.fa-files-o
+ = icon("exchange")
Compare
- if can_remove_branch?(@project, branch.name)
= link_to namespace_project_branch_path(@project.namespace, @project, branch.name), class: 'btn btn-grouped btn-xs btn-remove remove-row', method: :delete, data: { confirm: 'Removed branch cannot be restored. Are you sure?'}, remote: true do
- %i.fa.fa-trash-o
+ = icon("trash-o")
- if commit
%ul.list-unstyled
diff --git a/app/views/projects/commits/_head.html.haml b/app/views/projects/commits/_head.html.haml
index a714f5f79e0..66101f3f0da 100644
--- a/app/views/projects/commits/_head.html.haml
+++ b/app/views/projects/commits/_head.html.haml
@@ -1,6 +1,6 @@
%ul.nav.nav-tabs
= nav_link(controller: [:commit, :commits]) do
- = link_to namespace_project_commits_path(@project.namespace, @project, @repository.root_ref) do
+ = link_to namespace_project_commits_path(@project.namespace, @project, @ref || @repository.root_ref) do
Commits
%span.badge= number_with_precision(@repository.commit_count, precision: 0, delimiter: ',')
= nav_link(controller: :compare) do
diff --git a/app/views/projects/commits/show.html.haml b/app/views/projects/commits/show.html.haml
index c8531b090a6..9682100a54c 100644
--- a/app/views/projects/commits/show.html.haml
+++ b/app/views/projects/commits/show.html.haml
@@ -8,11 +8,17 @@
.tree-ref-holder
= render 'shared/ref_switcher', destination: 'commits'
-- if current_user && current_user.private_token
- .commits-feed-holder.hidden-xs.hidden-sm
- = link_to namespace_project_commits_path(@project.namespace, @project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed", class: 'btn' do
- %i.fa.fa-rss
- Commits feed
+.commits-feed-holder.hidden-xs.hidden-sm
+ - if create_mr_button?(@repository.root_ref, @ref)
+ = link_to create_mr_path(@repository.root_ref, @ref), class: 'btn btn-success' do
+ = icon('plus')
+ Create Merge Request
+
+ - if current_user && current_user.private_token
+ = link_to namespace_project_commits_path(@project.namespace, @project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed", class: 'prepend-left-10 btn' do
+ = icon("rss")
+ Commits Feed
+
%ul.breadcrumb.repo-breadcrumb
= commits_breadcrumbs
diff --git a/app/views/projects/compare/_form.html.haml b/app/views/projects/compare/_form.html.haml
index dfb1dded9ea..a0e904cfd8b 100644
--- a/app/views/projects/compare/_form.html.haml
+++ b/app/views/projects/compare/_form.html.haml
@@ -13,9 +13,10 @@
= text_field_tag :to, params[:to], class: "form-control"
&nbsp;
= button_tag "Compare", class: "btn btn-create commits-compare-btn"
- - if compare_to_mr_button?
- = link_to compare_mr_path, class: 'prepend-left-10 btn' do
- %strong Make a merge request
+ - if create_mr_button?
+ = link_to create_mr_path, class: 'prepend-left-10 btn' do
+ = icon("plus")
+ Create Merge Request
:javascript
diff --git a/features/steps/project/commits/commits.rb b/features/steps/project/commits/commits.rb
index 30b1934b363..c888e82e207 100644
--- a/features/steps/project/commits/commits.rb
+++ b/features/steps/project/commits/commits.rb
@@ -12,7 +12,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end
step 'I click atom feed link' do
- click_link "Feed"
+ click_link "Commits Feed"
end
step 'I see commits atom feed' do