gitlab-org--gitlab-foss/lib/api
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
..
api.rb Add Todos API 2016-07-01 10:49:34 +02:00
api_guard.rb Fix a few places where autoloading would fail 2016-05-10 11:51:19 +02:00
award_emoji.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
branches.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
builds.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
commit_statuses.rb Rename all ci_commit[s] in application code to pipeline[s] 2016-06-03 16:27:50 +02:00
commits.rb Extract LegacyDiffNote out of Note 2016-05-13 17:31:43 -05:00
deploy_keys.rb
entities.rb Merge branch 'remove-branch-api' into 'master' 2016-07-12 10:28:35 +00:00
files.rb WIP lazy blobs 2016-02-01 10:41:52 +01:00
group_members.rb Enable Style/SpaceAfterComma Rubocop cop 2016-06-29 15:23:44 +02:00
groups.rb Fix groups API to list only user's accessible projects 2016-05-24 18:14:12 -07:00
helpers.rb Refactor `Gitlab::GitAccess` 2016-07-13 13:24:56 +05:30
internal.rb Only allow Git Access on the allowed protocol 2016-07-05 16:54:22 -05:00
issues.rb gitlab-org/gitlab-ce#17818 - add api call for issues by group 2016-06-23 16:31:48 +00:00
keys.rb
labels.rb Add API endpoints for un/subscribing from/to a label 2016-05-12 22:48:09 +02:00
license_templates.rb Rename Licenses API to License Templates API 2016-06-27 14:42:05 -05:00
merge_requests.rb Rename MergeRequest methods that return commits or shas to be more clear and consistent 2016-07-06 18:50:58 -04:00
milestones.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
namespaces.rb
notes.rb Sort API endpoints and implement feedback 2016-06-17 20:08:16 +02:00
project_hooks.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
project_members.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
project_snippets.rb Prevent private snippets in public/internal projects from being leaked via API 2016-04-25 12:02:06 -07:00
projects.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
repositories.rb Add workhorse controller and API helpers 2016-06-06 13:16:30 +02:00
runners.rb Return the association and check it in controller instead: 2016-06-14 23:11:43 +08:00
services.rb Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
session.rb Improve Gitlab::Auth method names 2016-06-10 14:51:16 +02:00
settings.rb
sidekiq_metrics.rb Fixed Rubocop error 2016-06-17 11:16:25 -05:00
subscriptions.rb Add API endpoints for un/subscribing from/to a label 2016-05-12 22:48:09 +02:00
system_hooks.rb
tags.rb Ensure that branch and tag names are given in API 2016-06-30 13:46:35 +02:00
templates.rb fixup! override content method 2016-06-20 14:48:28 -05:00
todos.rb Support creating a todo on issuables via API 2016-07-01 14:52:04 +02:00
triggers.rb Make the CI permission model simpler 2016-02-02 09:18:08 +01:00
users.rb Enable Style/RedundantParentheses rubocop cop 2016-05-30 15:07:18 +02:00
variables.rb Make the CI permission model simpler 2016-02-02 09:18:08 +01:00