Class: Projects::CommitController

Inherits:
ApplicationController show all
Includes:
CreatesCommit, DiffHelper
Defined in:
app/controllers/projects/commit_controller.rb

Overview

Controller for a specific Commit

Not to be confused with CommitsController, plural.

Instance Method Summary collapse

Methods included from DiffHelper

#commit_for_diff, #diff_file_html_data, #diff_hard_limit_enabled?, #diff_line_content, #diff_options, #diff_view, #editable_diff?, #generate_line_code, #inline_diff_btn, #line_comments, #mark_inline_diffs, #organize_comments, #parallel_diff_btn, #safe_diff_files, #submodule_link, #unfold_bottom_class, #unfold_class

Methods included from CreatesCommit

#authorize_edit_tree!, #create_commit

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Projects::ApplicationController

Instance Method Details

#branchesObject


56
57
58
59
60
# File 'app/controllers/projects/commit_controller.rb', line 56

def branches
  @branches = @project.repository.branch_names_contains(commit.id)
  @tags = @project.repository.tag_names_contains(commit.id)
  render layout: false
end

#buildsObject


37
38
# File 'app/controllers/projects/commit_controller.rb', line 37

def builds
end

#cancel_buildsObject


40
41
42
43
44
# File 'app/controllers/projects/commit_controller.rb', line 40

def cancel_builds
  ci_builds.running_or_pending.each(&:cancel)

  redirect_back_or_default default: builds_namespace_project_commit_path(project.namespace, project, commit.sha)
end

#cherry_pickObject


71
72
73
74
75
76
77
78
# File 'app/controllers/projects/commit_controller.rb', line 71

def cherry_pick
  assign_change_commit_vars(@commit.cherry_pick_branch_name)
  
  return render_404 if @target_branch.blank?

  create_commit(Commits::CherryPickService, success_notice: "The #{@commit.change_type_title} has been successfully cherry-picked.",
                                            success_path: successful_change_path, failure_path: failed_change_path)
end

#retry_buildsObject


46
47
48
49
50
51
52
53
54
# File 'app/controllers/projects/commit_controller.rb', line 46

def retry_builds
  ci_builds.latest.failed.each do |build|
    if build.retryable?
      Ci::Build.retry(build)
    end
  end

  redirect_back_or_default default: builds_namespace_project_commit_path(project.namespace, project, commit.sha)
end

#revertObject


62
63
64
65
66
67
68
69
# File 'app/controllers/projects/commit_controller.rb', line 62

def revert
  assign_change_commit_vars(@commit.revert_branch_name)

  return render_404 if @target_branch.blank?

  create_commit(Commits::RevertService, success_notice: "The #{@commit.change_type_title} has been successfully reverted.",
                                        success_path: successful_change_path, failure_path: failed_change_path)
end

#showObject


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/projects/commit_controller.rb', line 17

def show
  apply_diff_view_cookie!

  @line_notes = commit.notes.inline
  @note = @project.build_commit_note(commit)
  @notes = commit.notes.not_inline.fresh
  @noteable = @commit
  @comments_allowed = @reply_allowed = true
  @comments_target  = {
    noteable_type: 'Commit',
    commit_id: @commit.id
  }

  respond_to do |format|
    format.html
    format.diff  { render text: @commit.to_diff }
    format.patch { render text: @commit.to_patch }
  end
end