summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-03-17 14:14:32 +0000
committerDouwe Maan <douwe@gitlab.com>2016-03-17 14:14:32 +0000
commitcf2e3ff6f985c1ffdab9b795d79f792d3ea115fa (patch)
tree74e94840970e7fcdcc810482cba3bf27d2e83f31 /app/controllers
parent4874c549c618db98888cfa5adc84543d872f655f (diff)
parent9337406671755ebd9175866cd86f1d6da4265d49 (diff)
downloadgitlab-ce-cf2e3ff6f985c1ffdab9b795d79f792d3ea115fa.tar.gz
Merge branch 'new-branch-button-issue' into 'master'
New branch button on issues Creates a button which creates a branch for you, referencing the original issue in the branch name. When creating the MR the text `Closes #iid` is appended to the description field. The button; with styling ![Screenshot_from_2016-02-13_17-28-54](/uploads/9595fbfef88c10a499829beaa3db11c1/Screenshot_from_2016-02-13_17-28-54.png) Links to the related branches on the issue ![Screenshot_from_2016-02-13_17-31-48](/uploads/ee7a78754eb5e2389f8671771bb59af9/Screenshot_from_2016-02-13_17-31-48.png) Styled like the MR links ![Screenshot_from_2016-02-13_17-31-53](/uploads/c60130333a650a16f51b014aeb1458c3/Screenshot_from_2016-02-13_17-31-53.png) Please provide input on the following; the CI repo on the GDK had the following happening with the current way I implemented the matching: ![Screenshot_from_2016-02-14_08-57-19](/uploads/35e7a3687a0fa801aba1ad66305ab2ff/Screenshot_from_2016-02-14_08-57-19.png) Closes #3886 cc @DouweM See merge request !2808
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/branches_controller.rb21
-rw-r--r--app/controllers/projects/issues_controller.rb1
2 files changed, 19 insertions, 3 deletions
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb
index 4db3b3bf23d..43ea717cbd2 100644
--- a/app/controllers/projects/branches_controller.rb
+++ b/app/controllers/projects/branches_controller.rb
@@ -9,7 +9,7 @@ class Projects::BranchesController < Projects::ApplicationController
@sort = params[:sort] || 'name'
@branches = @repository.branches_sorted_by(@sort)
@branches = Kaminari.paginate_array(@branches).page(params[:page]).per(PER_PAGE)
-
+
@max_commits = @branches.reduce(0) do |memo, branch|
diverging_commit_counts = repository.diverging_commit_counts(branch)
[memo, diverging_commit_counts[:behind], diverging_commit_counts[:ahead]].max
@@ -23,11 +23,15 @@ class Projects::BranchesController < Projects::ApplicationController
def create
branch_name = sanitize(strip_tags(params[:branch_name]))
branch_name = Addressable::URI.unescape(branch_name)
- ref = sanitize(strip_tags(params[:ref]))
- ref = Addressable::URI.unescape(ref)
+
result = CreateBranchService.new(project, current_user).
execute(branch_name, ref)
+ if params[:issue_iid]
+ issue = @project.issues.find_by(iid: params[:issue_iid])
+ SystemNoteService.new_issue_branch(issue, @project, current_user, branch_name) if issue
+ end
+
if result[:status] == :success
@branch = result[:branch]
redirect_to namespace_project_tree_path(@project.namespace, @project,
@@ -49,4 +53,15 @@ class Projects::BranchesController < Projects::ApplicationController
format.js { render status: status[:return_code] }
end
end
+
+ private
+
+ def ref
+ if params[:ref]
+ ref_escaped = sanitize(strip_tags(params[:ref]))
+ Addressable::URI.unescape(ref_escaped)
+ else
+ @project.default_branch
+ end
+ end
end
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index b0a03ee45cc..aa7a178dcf4 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -65,6 +65,7 @@ class Projects::IssuesController < Projects::ApplicationController
@notes = @issue.notes.nonawards.with_associations.fresh
@noteable = @issue
@merge_requests = @issue.referenced_merge_requests(current_user)
+ @related_branches = @issue.related_branches - @merge_requests.map(&:source_branch)
respond_with(@issue)
end