gitlab-org--gitlab-foss/app/services
Timothy Andrew 60245bbe22 Refactor Gitlab::GitAccess
1. Don't use case statements for dispatch anymore. This leads to a lot
   of duplication, and makes the logic harder to follow.

2. Remove duplicated logic.

    - For example, the `can_push_to_branch?` exists, but we also have a
      different way of checking the same condition within `change_access_check`.

    - This kind of duplication is removed, and the `can_push_to_branch?`
      method is used in both places.

3. Move checks returning true/false to `UserAccess`.

    - All public methods in `GitAccess` now return an instance of
      `GitAccessStatus`. Previously, some methods would return
      true/false as well, which was confusing.

    - It makes sense for these kinds of checks to be at the level of a
      user, so the `UserAccess` class was repurposed for this. The prior
      `UserAccess.allowed?` classmethod is converted into an instance
      method.

    - All external uses of these checks have been migrated to use the
      `UserAccess` class

4. Move the "change_access_check" into a separate class.

    - Create the `GitAccess::ChangeAccessCheck` class to run these
      checks, which are quite substantial.

    - `ChangeAccessCheck` returns an instance of `GitAccessStatus` as
      well.

5. Break out the boolean logic in `ChangeAccessCheck` into `if/else`
   chains - this seems more readable.

6. I can understand that this might look like overkill for !4892, but I
   think this is a good opportunity to clean it up.

    - http://martinfowler.com/bliki/OpportunisticRefactoring.html
2016-07-13 13:24:56 +05:30
..
auth Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
ci Merge remote-tracking branch 'upstream/master' into feature/runner-lock-on-project 2016-06-17 19:52:55 +08:00
commits Refactor Gitlab::GitAccess 2016-07-13 13:24:56 +05:30
files Refactor Gitlab::GitAccess 2016-07-13 13:24:56 +05:30
groups
issues Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
members Raise a new Gitlab::Access::AccessDeniedError when permission is not enough to destroy a member 2016-06-18 06:06:34 +02:00
merge_requests Enforce "developers can merge" during pre-receive. 2016-07-13 13:24:56 +05:30
milestones Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
notes Automatically update diff note positions when MR is pushed to 2016-07-06 18:51:00 -04:00
oauth2 Enable Style/EmptyLinesAroundAccessModifier rubocop cop 2016-06-03 10:34:20 +02:00
projects Reset project pushes_since_gc when we enqueue the git gc call 2016-07-12 15:54:05 +02:00
search
wiki_pages Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
audit_event_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
base_service.rb
compare_service.rb Remove unused argument to CompareService#execute 2016-07-08 13:53:17 +01:00
create_branch_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
create_commit_builds_service.rb Remove reduntant method for building pipeline builds 2016-06-15 14:12:25 +02:00
create_deployment_service.rb Revert "squashed merge and fixed conflicts" 2016-06-16 12:59:07 +02:00
create_release_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
create_snippet_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
create_spam_log_service.rb
create_tag_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
delete_branch_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
delete_tag_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
delete_user_service.rb
destroy_group_service.rb
event_create_service.rb
git_hooks_service.rb Better message for git hooks and file locks 2016-07-04 15:31:49 +03:00
git_push_service.rb Added "developers can merge" setting to protected branches 2016-07-13 13:24:26 +05:30
git_tag_push_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
gravatar_service.rb
issuable_base_service.rb Spec label add / delete in UpdateService 2016-06-03 17:14:23 -05:00
notification_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
repair_ldap_blocked_user_service.rb
system_hooks_service.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
system_note_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
test_hook_service.rb
todo_service.rb Ensure logged-out users can't see private refs 2016-06-30 16:36:10 +01:00
update_release_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
update_snippet_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00