Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/files/base_service.rb')
-rw-r--r--app/services/files/base_service.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb
index 8f722de2019..613785d01cc 100644
--- a/app/services/files/base_service.rb
+++ b/app/services/files/base_service.rb
@@ -26,16 +26,23 @@ module Files
def file_has_changed?(path, commit_id)
return false unless commit_id
- last_commit = Gitlab::Git::Commit
- .last_for_path(@start_project.repository, @start_branch, path, literal_pathspec: true)
+ last_commit_from_branch = get_last_commit_for_path(ref: @start_branch, path: path)
- return false unless last_commit
+ return false unless last_commit_from_branch
- last_commit.sha != commit_id
+ 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
private
+ def get_last_commit_for_path(ref:, path:)
+ Gitlab::Git::Commit.last_for_path(@start_project.repository, ref, path, literal_pathspec: true)
+ end
+
def commit_email(git_user)
return params[:author_email] if params[:author_email].present?
return unless current_user