diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-10-15 12:47:36 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-10-15 12:47:36 +0300 |
commit | c993481d991333fe0750080eec98fd2e9eeda8d5 (patch) | |
tree | 7d1fdd7926f8542b7fbf7add052004dbfd48b206 /app/services | |
parent | 83f04853e9a749c3397ee7683a78b986e1070904 (diff) | |
parent | 123669a55107514798ba531ba3a744b3ec8503ee (diff) |
Merge branch 'master' into git-archive-golang
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/ci/create_commit_service.rb | 6 | ||||
-rw-r--r-- | app/services/ci/register_build_service.rb | 2 | ||||
-rw-r--r-- | app/services/files/create_dir_service.rb | 9 | ||||
-rw-r--r-- | app/services/files/create_service.rb | 2 | ||||
-rw-r--r-- | app/services/files/update_service.rb | 2 | ||||
-rw-r--r-- | app/services/git_push_service.rb | 50 | ||||
-rw-r--r-- | app/services/issues/create_service.rb | 2 | ||||
-rw-r--r-- | app/services/issues/update_service.rb | 2 | ||||
-rw-r--r-- | app/services/merge_requests/create_service.rb | 2 | ||||
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 2 | ||||
-rw-r--r-- | app/services/merge_requests/update_service.rb | 2 | ||||
-rw-r--r-- | app/services/notes/create_service.rb | 8 | ||||
-rw-r--r-- | app/services/notes/update_service.rb | 2 | ||||
-rw-r--r-- | app/services/projects/transfer_service.rb | 4 | ||||
-rw-r--r-- | app/services/system_hooks_service.rb | 1 |
15 files changed, 44 insertions, 52 deletions
diff --git a/app/services/ci/create_commit_service.rb b/app/services/ci/create_commit_service.rb index fc1ae5774d5..479a2d6defc 100644 --- a/app/services/ci/create_commit_service.rb +++ b/app/services/ci/create_commit_service.rb @@ -17,8 +17,10 @@ module Ci tag = origin_ref.start_with?('refs/tags/') commit = project.gl_project.ensure_ci_commit(sha) - commit.update_committed! - commit.create_builds(ref, tag, user) + unless commit.skip_ci? + commit.update_committed! + commit.create_builds(ref, tag, user) + end commit end diff --git a/app/services/ci/register_build_service.rb b/app/services/ci/register_build_service.rb index 71b61bbe389..7beb098659c 100644 --- a/app/services/ci/register_build_service.rb +++ b/app/services/ci/register_build_service.rb @@ -17,7 +17,7 @@ module Ci builds = builds.order('created_at ASC') build = builds.find do |build| - (build.tag_list - current_runner.tag_list).empty? + build.can_be_served?(current_runner) end diff --git a/app/services/files/create_dir_service.rb b/app/services/files/create_dir_service.rb new file mode 100644 index 00000000000..71272fb5707 --- /dev/null +++ b/app/services/files/create_dir_service.rb @@ -0,0 +1,9 @@ +require_relative "base_service" + +module Files + class CreateDirService < Files::BaseService + def commit + repository.commit_dir(current_user, @file_path, @commit_message, @target_branch) + end + end +end diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb index ffbb5993279..c8e3a910bba 100644 --- a/app/services/files/create_service.rb +++ b/app/services/files/create_service.rb @@ -3,7 +3,7 @@ require_relative "base_service" module Files class CreateService < Files::BaseService def commit - repository.commit_file(current_user, @file_path, @file_content, @commit_message, @target_branch) + repository.commit_file(current_user, @file_path, @file_content, @commit_message, @target_branch, false) end def validate diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb index a20903c6f02..1960dc7d949 100644 --- a/app/services/files/update_service.rb +++ b/app/services/files/update_service.rb @@ -3,7 +3,7 @@ require_relative "base_service" module Files class UpdateService < Files::BaseService def commit - repository.commit_file(current_user, @file_path, @file_content, @commit_message, @target_branch) + repository.commit_file(current_user, @file_path, @file_content, @commit_message, @target_branch, true) end end end diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb index f9a8265d2d4..81d47602f13 100644 --- a/app/services/git_push_service.rb +++ b/app/services/git_push_service.rb @@ -74,48 +74,30 @@ class GitPushService def process_commit_messages(ref) is_default_branch = is_default_branch?(ref) - @push_commits.each do |commit| - # Close issues if these commits were pushed to the project's default branch and the commit message matches the - # closing regex. Exclude any mentioned Issues from cross-referencing even if the commits are being pushed to - # a different branch. - issues_to_close = commit.closes_issues(user) + authors = Hash.new do |hash, commit| + email = commit.author_email + return hash[email] if hash.has_key?(email) - # Load commit author only if needed. - # For push with 1k commits it prevents 900+ requests in database - author = nil + hash[email] = commit_user(commit) + end + @push_commits.each do |commit| # Keep track of the issues that will be actually closed because they are on a default branch. # Hence, when creating cross-reference notes, the not-closed issues (on non-default branches) # will also have cross-reference. - actually_closed_issues = [] - - if issues_to_close.present? && is_default_branch - author ||= commit_user(commit) - actually_closed_issues = issues_to_close - issues_to_close.each do |issue| - Issues::CloseService.new(project, author, {}).execute(issue, commit) + closed_issues = [] + + if is_default_branch + # Close issues if these commits were pushed to the project's default branch and the commit message matches the + # closing regex. Exclude any mentioned Issues from cross-referencing even if the commits are being pushed to + # a different branch. + closed_issues = commit.closes_issues(user) + closed_issues.each do |issue| + Issues::CloseService.new(project, authors[commit], {}).execute(issue, commit) end end - if project.default_issues_tracker? - create_cross_reference_notes(commit, actually_closed_issues) - end - end - end - - def create_cross_reference_notes(commit, issues_to_close) - # Create cross-reference notes for any other references than those given in issues_to_close. - # Omit any issues that were referenced in an issue-closing phrase, or have already been - # mentioned from this commit (probably from this commit being pushed to a different branch). - refs = commit.references(project, user) - issues_to_close - refs.reject! { |r| commit.has_mentioned?(r) } - - if refs.present? - author ||= commit_user(commit) - - refs.each do |r| - SystemNoteService.cross_reference(r, commit, author) - end + commit.create_cross_references!(authors[commit], closed_issues) end end diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb index 1ea4b72216c..bcb380d3215 100644 --- a/app/services/issues/create_service.rb +++ b/app/services/issues/create_service.rb @@ -10,7 +10,7 @@ module Issues issue.update_attributes(label_ids: label_params) notification_service.new_issue(issue, current_user) event_service.open_issue(issue, current_user) - issue.create_cross_references!(issue.project, current_user) + issue.create_cross_references!(current_user) execute_hooks(issue, 'open') end diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb index 2fc6ef7f356..2b5426ad452 100644 --- a/app/services/issues/update_service.rb +++ b/app/services/issues/update_service.rb @@ -35,7 +35,7 @@ module Issues create_title_change_note(issue, issue.previous_changes['title'].first) end - issue.create_new_cross_references!(issue.project, current_user) + issue.create_new_cross_references! execute_hooks(issue, 'update') end diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb index 9651b16462c..009d5a6867e 100644 --- a/app/services/merge_requests/create_service.rb +++ b/app/services/merge_requests/create_service.rb @@ -18,7 +18,7 @@ module MergeRequests merge_request.update_attributes(label_ids: label_params) event_service.open_mr(merge_request, current_user) notification_service.new_merge_request(merge_request, current_user) - merge_request.create_cross_references!(merge_request.project, current_user) + merge_request.create_cross_references!(current_user) execute_hooks(merge_request) end diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index fcc0f2a6a8d..7963af127e1 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -29,7 +29,7 @@ module MergeRequests private def commit - committer = repository.user_to_comitter(current_user) + committer = repository.user_to_committer(current_user) options = { message: commit_message, diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb index 25d79e22e39..ebbe0af803b 100644 --- a/app/services/merge_requests/update_service.rb +++ b/app/services/merge_requests/update_service.rb @@ -59,7 +59,7 @@ module MergeRequests merge_request.mark_as_unchecked end - merge_request.create_new_cross_references!(merge_request.project, current_user) + merge_request.create_new_cross_references! execute_hooks(merge_request, 'update') end diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb index 482c0444049..2001dc89c33 100644 --- a/app/services/notes/create_service.rb +++ b/app/services/notes/create_service.rb @@ -11,13 +11,7 @@ module Notes # Skip system notes, like status changes and cross-references. unless note.system event_service.leave_note(note, note.author) - - # Create a cross-reference note if this Note contains GFM that names an - # issue, merge request, or commit. - note.references.each do |mentioned| - SystemNoteService.cross_reference(mentioned, note.noteable, note.author) - end - + note.create_cross_references! execute_hooks(note) end end diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb index c22a9333ef6..6c2f08e5963 100644 --- a/app/services/notes/update_service.rb +++ b/app/services/notes/update_service.rb @@ -4,7 +4,7 @@ module Notes return note unless note.editable? note.update_attributes(params.merge(updated_by: current_user)) - + note.create_new_cross_references! note.reset_events_cache note diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb index c327c244f0d..64ea6dd42eb 100644 --- a/app/services/projects/transfer_service.rb +++ b/app/services/projects/transfer_service.rb @@ -27,6 +27,7 @@ module Projects def transfer(project, new_namespace) Project.transaction do old_path = project.path_with_namespace + old_namespace = project.namespace new_path = File.join(new_namespace.try(:path) || '', project.path) if Project.where(path: project.path, namespace_id: new_namespace.try(:id)).present? @@ -51,6 +52,9 @@ module Projects # clear project cached events project.reset_events_cache + # Move uploads + Gitlab::UploadsTransfer.new.move_project(project.path, old_namespace.path, new_namespace.path) + true end end diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb index 60235b6be2a..9a5fe4af9dd 100644 --- a/app/services/system_hooks_service.rb +++ b/app/services/system_hooks_service.rb @@ -54,6 +54,7 @@ class SystemHooksService data.merge!({ project_name: model.project.name, project_path: model.project.path, + project_path_with_namespace: model.project.path_with_namespace, project_id: model.project.id, user_name: model.user.name, user_email: model.user.email, |