Class: Files::BaseService
- Inherits:
-
Commits::CreateService
- Object
- BaseService
- Commits::CreateService
- Files::BaseService
- Defined in:
- app/services/files/base_service.rb
Direct Known Subclasses
CreateDirService, CreateService, DeleteService, MultiService, UpdateService
Constant Summary collapse
- FileChangedError =
Class.new(StandardError)
Constants inherited from Commits::CreateService
Commits::CreateService::ValidationError
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #file_has_changed?(path, commit_id) ⇒ Boolean
-
#initialize(*args) ⇒ BaseService
constructor
A new instance of BaseService.
Methods inherited from Commits::CreateService
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
Constructor Details
#initialize(*args) ⇒ BaseService
Returns a new instance of BaseService.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/files/base_service.rb', line 7 def initialize(*args) super git_user = Gitlab::Git::User.from_gitlab(current_user) if current_user.present? @author_email = commit_email(git_user) @author_name = params[:author_name] || git_user&.name @commit_message = params[:commit_message] @last_commit_sha = params[:last_commit_sha] @file_path = params[:file_path] @previous_path = params[:previous_path] @file_content = params[:file_content] if params[:file_content_encoding] == 'base64' && @file_content.present? @file_content = Base64.decode64(@file_content) end @execute_filemode = params[:execute_filemode] end |
Instance Method Details
#file_has_changed?(path, commit_id) ⇒ Boolean
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/services/files/base_service.rb', line 29 def file_has_changed?(path, commit_id) return false unless commit_id last_commit_from_branch = get_last_commit_for_path(ref: @start_branch, path: path) return false unless last_commit_from_branch last_commit_from_commit_id = get_last_commit_for_path(ref: commit_id, path: path) return false unless last_commit_from_commit_id last_commit_from_branch.sha != last_commit_from_commit_id.sha end |