summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-03-07 09:01:26 +0000
committerDouwe Maan <douwe@gitlab.com>2016-03-07 09:01:26 +0000
commitd43c778402b481569cb8b2fffed45a7c939e0c75 (patch)
tree463ca3d213963d98ecc6f8ca4b8b60cc52195163 /features
parentbe1ae2d660ad98cf6a44cefa3148f9c48b66806f (diff)
parent543845f7efe0b70926ea699eaf1e413fa878b285 (diff)
downloadgitlab-ce-d43c778402b481569cb8b2fffed45a7c939e0c75.tar.gz
Merge branch 'indicate-mr-diverged-from-target' into 'master'
Indicate when an MR diverged from the target branch This adds an indicator to the "Merge MR" box, to tell if and how much an MR diverged from its target branch. For instance, consider an MR to merge the branch `feature` into `master`. Some other commits were added to `master` since `feature` was created, and the two branches diverged. ```text o master | o o feature | | o o | / o ``` In this case, there will be a label in the MR Merge box stating: > This MR is by 3 commits behind the target branch `master`. ## Screenshots ### The branch diverged from the target (UI Proposal) ![UI_suggestion_1](/uploads/cd5bee3959e68026ec7d5097259d53f4/UI_suggestion_1.png) ### The branch diverged from the target (alternative UI Proposal) ![UI_suggestion_2](/uploads/f36977101b59a610850e129837dfbc83/UI_suggestion_2.png) ## How is this useful? - In a _rebase-workflow_ (MR are preferably rebased before being merged), the reviewer wants to know if an MR is rebased on the target branch before merging it. _With this indicator, the reviewer knows immediately if the branch is rebased, or if she needs to ask the committer to rebase its branch._ <br> - To keep the git history readable, a team prefers to avoid merging branches that really lag a lot behind the target branch. Merging an MR that is 10 commits behind is fine, but 200 is too much. _With this indicator, the reviewer can see on the MR page if the branch is really far behind the target – or only a few commits behind._ ## Open questions We've been using this at @captaintrain for a few months now, and found it quite useful. I guess the open-questions are mostly: what UI would be the more adequate? Any thoughts on this, on the general usefulness and/or on the code? See merge request !2217
Diffstat (limited to 'features')
-rw-r--r--features/project/merge_requests.feature10
-rw-r--r--features/steps/project/merge_requests.rb29
-rw-r--r--features/steps/shared/paths.rb19
3 files changed, 53 insertions, 5 deletions
diff --git a/features/project/merge_requests.feature b/features/project/merge_requests.feature
index 495f25f28e7..a69089f00c4 100644
--- a/features/project/merge_requests.feature
+++ b/features/project/merge_requests.feature
@@ -26,6 +26,16 @@ Feature: Project Merge Requests
When I visit project "Shop" merge requests page
Then I should see "other_branch" branch
+ Scenario: I should not see the numbers of diverged commits if the branch is rebased on the target
+ Given project "Shop" have "Bug NS-07" open merge request with rebased branch
+ When I visit merge request page "Bug NS-07"
+ Then I should not see the diverged commits count
+
+ Scenario: I should see the numbers of diverged commits if the branch diverged from the target
+ Given project "Shop" have "Bug NS-08" open merge request with diverged branch
+ When I visit merge request page "Bug NS-08"
+ Then I should see the diverged commits count
+
Scenario: I should see rejected merge requests
Given I click link "Closed"
Then I should see "Feature NS-03" in merge requests
diff --git a/features/steps/project/merge_requests.rb b/features/steps/project/merge_requests.rb
index dde864f5180..8bf423cc64b 100644
--- a/features/steps/project/merge_requests.rb
+++ b/features/steps/project/merge_requests.rb
@@ -60,7 +60,6 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
expect(page).not_to have_content "Feature NS-03"
end
-
step 'I should not see "Bug NS-04" in merge requests' do
expect(page).not_to have_content "Bug NS-04"
end
@@ -121,6 +120,22 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
author: project.users.first)
end
+ step 'project "Shop" have "Bug NS-07" open merge request with rebased branch' do
+ create(:merge_request, :rebased,
+ title: "Bug NS-07",
+ source_project: project,
+ target_project: project,
+ author: project.users.first)
+ end
+
+ step 'project "Shop" have "Bug NS-08" open merge request with diverged branch' do
+ create(:merge_request, :diverged,
+ title: "Bug NS-08",
+ source_project: project,
+ target_project: project,
+ author: project.users.first)
+ end
+
step 'project "Shop" have "Feature NS-03" closed merge request' do
create(:closed_merge_request,
title: "Feature NS-03",
@@ -490,6 +505,18 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
end
+ step 'I should see the diverged commits count' do
+ page.within ".mr-source-target" do
+ expect(page).to have_content /([0-9]+ commits behind)/
+ end
+ end
+
+ step 'I should not see the diverged commits count' do
+ page.within ".mr-source-target" do
+ expect(page).not_to have_content /([0-9]+ commit[s]? behind)/
+ end
+ end
+
step 'I should see "Bug NS-05" at the top' do
expect(page.find('ul.content-list.mr-list li.merge-request:first-child')).to have_content("Bug NS-05")
end
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index 6432a786bfc..da9d1503ebc 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -388,13 +388,19 @@ module SharedPaths
end
step 'I visit merge request page "Bug NS-04"' do
- mr = MergeRequest.find_by(title: "Bug NS-04")
- visit namespace_project_merge_request_path(mr.target_project.namespace, mr.target_project, mr)
+ visit merge_request_path("Bug NS-04")
end
step 'I visit merge request page "Bug NS-05"' do
- mr = MergeRequest.find_by(title: "Bug NS-05")
- visit namespace_project_merge_request_path(mr.target_project.namespace, mr.target_project, mr)
+ visit merge_request_path("Bug NS-05")
+ end
+
+ step 'I visit merge request page "Bug NS-07"' do
+ visit merge_request_path("Bug NS-07")
+ end
+
+ step 'I visit merge request page "Bug NS-08"' do
+ visit merge_request_path("Bug NS-08")
end
step 'I visit merge request page "Bug CO-01"' do
@@ -503,6 +509,11 @@ module SharedPaths
Project.find_by!(name: 'Shop')
end
+ def merge_request_path(title)
+ mr = MergeRequest.find_by(title: title)
+ namespace_project_merge_request_path(mr.target_project.namespace, mr.target_project, mr)
+ end
+
# ----------------------------------------
# Errors
# ----------------------------------------