diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-11-24 15:51:15 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-11-24 15:51:15 +0000 |
commit | 54cf7dacdf3fac38161f0e962640543166715eb4 (patch) | |
tree | a7119b97d75578777c24e7a4bda66c196758081a /app/services | |
parent | 0bee018631ae199ce87125c21379e1db2f56bf67 (diff) | |
parent | 7c1e54d58d7ee0308b865d9563f1dfeb54568e16 (diff) | |
download | gitlab-ce-54cf7dacdf3fac38161f0e962640543166715eb4.tar.gz |
Merge branch 'master' into list-multiple-clusters
* master: (53 commits)
Updated timeago.js
Prevent 500 error when inspecting job after trigger was removed
Add classList polyfill for IE classList.toggle(.., force)
Use feature flag instead of application settigns to control if method calls should be instrumented
Rename wip to worker_id
add missing schema entry and application settigns helper
Use only real duration to measure method call performance via Prometheus
check method timing threshold when observing method performance
Add changelog for #15558
Reenable prometheus metrics
Move prometheus middle ware to prometheus initialized.
Fix WIP system note not being created
Update CHANGELOG.md for 10.2.2
Fix hashed storage for attachments bugs
Rename fetch_refs to refmap
Clean up repository fetch and mirror methods
Fix pulling and pushing using a personal access token with the sudo scope
Allow password authentication to be disabled entirely
Simplify the DB changes checklist
Added Rubocop config for background migrations
...
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/issuable/common_system_notes_service.rb | 14 | ||||
-rw-r--r-- | app/services/merge_requests/base_service.rb | 14 | ||||
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 2 | ||||
-rw-r--r-- | app/services/projects/import_service.rb | 20 | ||||
-rw-r--r-- | app/services/protected_branches/legacy_api_create_service.rb (renamed from app/services/protected_branches/api_create_service.rb) | 4 | ||||
-rw-r--r-- | app/services/protected_branches/legacy_api_update_service.rb (renamed from app/services/protected_branches/api_update_service.rb) | 4 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 10 | ||||
-rw-r--r-- | app/services/users/build_service.rb | 2 |
8 files changed, 28 insertions, 42 deletions
diff --git a/app/services/issuable/common_system_notes_service.rb b/app/services/issuable/common_system_notes_service.rb index 92eaa5d5115..3da21bd8b8f 100644 --- a/app/services/issuable/common_system_notes_service.rb +++ b/app/services/issuable/common_system_notes_service.rb @@ -41,6 +41,14 @@ module Issuable end end + def create_wip_note(old_title) + return unless issuable.is_a?(MergeRequest) + + if MergeRequest.work_in_progress?(old_title) != issuable.work_in_progress? + SystemNoteService.handle_merge_request_wip(issuable, issuable.project, current_user) + end + end + def create_labels_note(old_labels) added_labels = issuable.labels - old_labels removed_labels = old_labels - issuable.labels @@ -49,7 +57,11 @@ module Issuable end def create_title_change_note(old_title) - SystemNoteService.change_title(issuable, issuable.project, current_user, old_title) + create_wip_note(old_title) + + if issuable.wipless_title_changed(old_title) + SystemNoteService.change_title(issuable, issuable.project, current_user, old_title) + end end def create_description_change_note diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb index d3938b065bc..f6ffd48deae 100644 --- a/app/services/merge_requests/base_service.rb +++ b/app/services/merge_requests/base_service.rb @@ -4,20 +4,6 @@ module MergeRequests SystemNoteService.change_status(merge_request, merge_request.target_project, current_user, state, nil) end - def create_title_change_note(issuable, old_title) - removed_wip = MergeRequest.work_in_progress?(old_title) && !issuable.work_in_progress? - added_wip = !MergeRequest.work_in_progress?(old_title) && issuable.work_in_progress? - changed_title = MergeRequest.wipless_title(old_title) != issuable.wipless_title - - if removed_wip - SystemNoteService.remove_merge_request_wip(issuable, issuable.project, current_user) - elsif added_wip - SystemNoteService.add_merge_request_wip(issuable, issuable.project, current_user) - end - - super if changed_title - end - def hook_data(merge_request, action, old_rev: nil, old_labels: [], old_assignees: [], old_total_time_spent: nil) hook_data = merge_request.to_hook_data(current_user, old_labels: old_labels, old_assignees: old_assignees, old_total_time_spent: old_total_time_spent) hook_data[:object_attributes][:action] = action diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index fc100580c4f..bf3d4855122 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -35,7 +35,7 @@ module MergeRequests # target branch manually def close_merge_requests commit_ids = @commits.map(&:id) - merge_requests = @project.merge_requests.preload(:merge_request_diff).opened.where(target_branch: @branch_name).to_a + merge_requests = @project.merge_requests.preload(:latest_merge_request_diff).opened.where(target_branch: @branch_name).to_a merge_requests = merge_requests.select(&:diff_head_commit) merge_requests = merge_requests.select do |merge_request| diff --git a/app/services/projects/import_service.rb b/app/services/projects/import_service.rb index c3b11341b4d..f2d676af5c3 100644 --- a/app/services/projects/import_service.rb +++ b/app/services/projects/import_service.rb @@ -51,10 +51,13 @@ module Projects def import_repository begin - if project.gitea_import? - fetch_repository + refmap = importer_class.try(:refmap) if has_importer? + + if refmap + project.ensure_repository + project.repository.fetch_as_mirror(project.import_url, refmap: refmap) else - clone_repository + gitlab_shell.import_repository(project.repository_storage_path, project.disk_path, project.import_url) end rescue Gitlab::Shell::Error, Gitlab::Git::RepositoryMirroring::RemoteError => e # Expire cache to prevent scenarios such as: @@ -66,17 +69,6 @@ module Projects end end - def clone_repository - gitlab_shell.import_repository(project.repository_storage_path, project.disk_path, project.import_url) - end - - def fetch_repository - project.ensure_repository - project.repository.add_remote(project.import_type, project.import_url) - project.repository.set_remote_as_mirror(project.import_type) - project.repository.fetch_remote(project.import_type, forced: true) - end - def import_data return unless has_importer? diff --git a/app/services/protected_branches/api_create_service.rb b/app/services/protected_branches/legacy_api_create_service.rb index f2040dfa03a..e358fd0374e 100644 --- a/app/services/protected_branches/api_create_service.rb +++ b/app/services/protected_branches/legacy_api_create_service.rb @@ -1,9 +1,9 @@ -# The protected branches API still uses the `developers_can_push` and `developers_can_merge` +# The branches#protect API still uses the `developers_can_push` and `developers_can_merge` # flags for backward compatibility, and so performs translation between that format and the # internal data model (separate access levels). The translation code is non-trivial, and so # lives in this service. module ProtectedBranches - class ApiCreateService < BaseService + class LegacyApiCreateService < BaseService def execute push_access_level = if params.delete(:developers_can_push) diff --git a/app/services/protected_branches/api_update_service.rb b/app/services/protected_branches/legacy_api_update_service.rb index bdb0e0cc8bf..33176253ca2 100644 --- a/app/services/protected_branches/api_update_service.rb +++ b/app/services/protected_branches/legacy_api_update_service.rb @@ -1,9 +1,9 @@ -# The protected branches API still uses the `developers_can_push` and `developers_can_merge` +# The branches#protect API still uses the `developers_can_push` and `developers_can_merge` # flags for backward compatibility, and so performs translation between that format and the # internal data model (separate access levels). The translation code is non-trivial, and so # lives in this service. module ProtectedBranches - class ApiUpdateService < BaseService + class LegacyApiUpdateService < BaseService def execute(protected_branch) @developers_can_push = params.delete(:developers_can_push) @developers_can_merge = params.delete(:developers_can_merge) diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index fe71a405565..30a5aab13bf 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -241,14 +241,10 @@ module SystemNoteService create_note(NoteSummary.new(noteable, project, author, body, action: 'merge')) end - def remove_merge_request_wip(noteable, project, author) - body = 'unmarked as a **Work In Progress**' + def handle_merge_request_wip(noteable, project, author) + prefix = noteable.work_in_progress? ? "marked" : "unmarked" - create_note(NoteSummary.new(noteable, project, author, body, action: 'title')) - end - - def add_merge_request_wip(noteable, project, author) - body = 'marked as a **Work In Progress**' + body = "#{prefix} as a **Work In Progress**" create_note(NoteSummary.new(noteable, project, author, body, action: 'title')) end diff --git a/app/services/users/build_service.rb b/app/services/users/build_service.rb index 6f05500adea..61f1568f366 100644 --- a/app/services/users/build_service.rb +++ b/app/services/users/build_service.rb @@ -34,7 +34,7 @@ module Users private def can_create_user? - (current_user.nil? && current_application_settings.signup_enabled?) || current_user&.admin? + (current_user.nil? && current_application_settings.allow_signup?) || current_user&.admin? end # Allowed params for creating a user (admins only) |