Class: Projects::UpdateService

Inherits:
BaseService show all
Includes:
UpdateVisibilityLevel, ValidatesClassificationLabel
Defined in:
app/services/projects/update_service.rb

Constant Summary collapse

ValidationError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from ValidatesClassificationLabel

#classification_label_change?, #rejection_reason_for_label, #validate_classification_label

Methods included from UpdateVisibilityLevel

#valid_visibility_level_change?

Methods inherited from BaseService

#initialize

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/services/projects/update_service.rb', line 10

def execute
  build_topics
  remove_unallowed_params
  add_pages_unique_domain

  validate!

  ensure_wiki_exists if enabling_wiki?

  if changing_repository_storage?
    storage_move = project.repository_storage_moves.build(
      source_storage_name: project.repository_storage,
      destination_storage_name: params.delete(:repository_storage)
    )
    storage_move.schedule
  end

  yield if block_given?

  validate_classification_label(project, :external_authorization_classification_label)

  # If the block added errors, don't try to save the project
  return update_failed! if project.errors.any?

  if project.update(params.except(:default_branch))
    after_update

    success
  else
    update_failed!
  end
rescue ValidationError => e
  error(e.message)
end

#run_auto_devops_pipeline?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
# File 'app/services/projects/update_service.rb', line 45

def run_auto_devops_pipeline?
  return false if project.repository.gitlab_ci_yml || !project.auto_devops&.previous_changes&.include?('enabled')

  project.auto_devops_enabled?
end