Class: Projects::UpdateService

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

Constant Summary collapse

ValidationError =
Class.new(StandardError)
ApiError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Ci::JobToken::InternalEventsTracking

#track_job_token_scope_setting_changes

Methods included from Gitlab::InternalEventsTracking

#track_internal_event

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?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#executeObject



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
44
45
46
47
48
# File 'app/services/projects/update_service.rb', line 12

def execute
  build_topics
  ensure_ci_cd_settings
  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 ApiError => e
  error(e.message, status: :api_error)
rescue ValidationError, Gitlab::Pages::UniqueDomainGenerationFailure => e
  error(e.message)
end

#run_auto_devops_pipeline?Boolean

Returns:

  • (Boolean)


50
51
52
53
54
# File 'app/services/projects/update_service.rb', line 50

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

  project.auto_devops_enabled?
end