Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/commit_controller.rb')
-rw-r--r--app/controllers/projects/commit_controller.rb39
1 files changed, 21 insertions, 18 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index 8154128da29..0c3ff07bc76 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -19,13 +19,8 @@ class Projects::CommitController < Projects::ApplicationController
before_action :define_commit_box_vars, only: [:show, :pipelines]
before_action :define_note_vars, only: [:show, :diff_for_path, :diff_files]
before_action :authorize_edit_tree!, only: [:revert, :cherry_pick]
-
- before_action only: [:show, :pipelines] do
- push_frontend_feature_flag(:ci_commit_pipeline_mini_graph_vue, @project, default_enabled: :yaml)
- end
-
before_action do
- push_frontend_feature_flag(:pick_into_project)
+ push_frontend_feature_flag(:pick_into_project, @project, default_enabled: :yaml)
end
BRANCH_SEARCH_LIMIT = 1000
@@ -59,8 +54,6 @@ class Projects::CommitController < Projects::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def pipelines
- set_pipeline_feature_flag
-
@pipelines = @commit.pipelines.order(id: :desc)
@pipelines = @pipelines.where(ref: params[:ref]).page(params[:page]).per(30) if params[:ref]
@@ -119,7 +112,7 @@ class Projects::CommitController < Projects::ApplicationController
@branch_name = create_new_branch? ? @commit.revert_branch_name : @start_branch
create_commit(Commits::RevertService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully reverted.",
- success_path: -> { successful_change_path }, failure_path: failed_change_path)
+ success_path: -> { successful_change_path(@project) }, failure_path: failed_change_path)
end
def cherry_pick
@@ -127,24 +120,25 @@ class Projects::CommitController < Projects::ApplicationController
return render_404 if @start_branch.blank?
+ target_project = find_cherry_pick_target_project
+ return render_404 unless target_project
+
@branch_name = create_new_branch? ? @commit.cherry_pick_branch_name : @start_branch
create_commit(Commits::CherryPickService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked into #{@branch_name}.",
- success_path: -> { successful_change_path }, failure_path: failed_change_path)
+ success_path: -> { successful_change_path(target_project) },
+ failure_path: failed_change_path,
+ target_project: target_project)
end
private
- def set_pipeline_feature_flag
- push_frontend_feature_flag(:new_pipelines_table, @project, default_enabled: :yaml)
- end
-
def create_new_branch?
params[:create_merge_request].present? || !can?(current_user, :push_code, @project)
end
- def successful_change_path
- referenced_merge_request_url || project_commits_url(@project, @branch_name)
+ def successful_change_path(target_project)
+ referenced_merge_request_url || project_commits_url(target_project, @branch_name)
end
def failed_change_path
@@ -173,7 +167,7 @@ class Projects::CommitController < Projects::ApplicationController
@diffs = commit.diffs(opts)
@notes_count = commit.notes.count
- @environment = EnvironmentsFinder.new(@project, current_user, commit: @commit, find_latest: true).execute.last
+ @environment = EnvironmentsByDeploymentsFinder.new(@project, current_user, commit: @commit, find_latest: true).execute.last
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -214,7 +208,6 @@ class Projects::CommitController < Projects::ApplicationController
def define_commit_box_vars
@last_pipeline = @commit.last_pipeline
- return unless ::Gitlab::Ci::Features.ci_commit_pipeline_mini_graph_vue_enabled?(@project)
return unless @commit.last_pipeline
@last_pipeline_stages = StageSerializer.new(project: @project, current_user: @current_user).represent(@last_pipeline.stages)
@@ -224,4 +217,14 @@ class Projects::CommitController < Projects::ApplicationController
@start_branch = params[:start_branch]
@commit_params = { commit: @commit }
end
+
+ def find_cherry_pick_target_project
+ return @project if params[:target_project_id].blank?
+ return @project unless Feature.enabled?(:pick_into_project, @project, default_enabled: :yaml)
+
+ MergeRequestTargetProjectFinder
+ .new(current_user: current_user, source_project: @project, project_feature: :repository)
+ .execute
+ .find_by_id(params[:target_project_id])
+ end
end