Class: Files::UpdateService

Inherits:
BaseService show all
Defined in:
app/services/files/update_service.rb

Constant Summary

Constants inherited from BaseService

BaseService::FileChangedError

Constants inherited from Commits::CreateService

Commits::CreateService::ValidationError

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#file_has_changed?, #initialize

Methods inherited from Commits::CreateService

#execute, #initialize

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 Files::BaseService

Instance Method Details

#create_commit!Object



5
6
7
8
9
10
11
# File 'app/services/files/update_service.rb', line 5

def create_commit!
  transformer = Lfs::FileTransformer.new(project, repository, @branch_name, start_branch_name: @start_branch)

  result = transformer.new_file(@file_path, @file_content)

  create_transformed_commit(result.content)
end

#create_transformed_commit(content_or_lfs_pointer) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/services/files/update_service.rb', line 13

def create_transformed_commit(content_or_lfs_pointer)
  repository.update_file(
    current_user,
    @file_path,
    content_or_lfs_pointer,
    message: @commit_message,
    branch_name: @branch_name,
    previous_path: @previous_path,
    author_email: @author_email,
    author_name: @author_name,
    start_project: @start_project,
    start_branch_name: @start_branch,
    execute_filemode: @execute_filemode
  )
end