Commit graph

25 commits

Author SHA1 Message Date
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
Valery Sizov
3baed8cb6d Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
Patricio Cano
be221a30ac Revert back to not defining a default Git access protocol. 2016-07-05 16:54:22 -05:00
Patricio Cano
29c50c5315 Default Git access protocol to web 2016-07-05 16:54:22 -05:00
Patricio Cano
8b14d1d2c2 Rename ENV['PROTOCOL'] to ENV['GL_PROTOCOL'] to conform to what GitLab Shell expects and make the protocol param in GitAccess mandatory. 2016-07-05 16:54:22 -05:00
Douwe Maan
d9c82d679f Automatically fork a project when not allowed to edit a file. 2015-12-18 10:03:34 +01:00
Douwe Maan
57d71520bd Make tooltip less confusing 2015-12-08 22:30:40 +01:00
Douwe Maan
82ddd738b6 Show tooltip when trying to edit file when not on branch 2015-12-08 17:10:07 +01:00
Rubén Dávila
5145706c82 Run custom Git hooks when creating or deleting branches through the UI. #1156 2015-12-03 09:39:15 -05:00
Guilherme Garnier
2b075f16c7 Fix rubocop warnings in app 2015-10-03 00:56:37 -05:00
Dmitriy Zaporozhets
f4149bcddc Refactor how repository makes commit with pre/post receive hooks 2015-08-14 16:23:40 +02:00
Dmitriy Zaporozhets
c8614cbbe7
Capture pre-receive exception
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-13 14:29:13 +02:00
Dmitriy Zaporozhets
34690142bf
Implement commit transaction with pre-receive and post-receive hooks for web editor
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-13 12:57:24 +02:00
Dmitriy Zaporozhets
3e259ea8bc Revert "Merge branch 'revert-satellites' into 'master' "
This reverts commit 5daf44b7c8, reversing
changes made to 2f706fbd23.
2015-08-11 14:33:31 +02:00
Dmitriy Zaporozhets
34975f0180 Revert "Create activity event and execute hooks on web editor commit"
This reverts commit 3d416f1682.
2015-08-11 11:50:43 +02:00
Dmitriy Zaporozhets
24332b7b99 Revert "Make web editor work correctly after switch from satellites"
This reverts commit 435f680b89.
2015-08-11 11:49:29 +02:00
Dmitriy Zaporozhets
d4cfa0bf76
Revert "Refactor web editor"
This reverts commit dfccb06dda.

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-11 11:49:09 +02:00
Dmitriy Zaporozhets
9f10943c1a
Revert "Merge branch 'drop-satellites'"
This reverts commit 957e849f41, reversing
changes made to 6b9dbe9f5a.

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-11 10:28:42 +02:00
Dmitriy Zaporozhets
a7fded9b95
Huge refactoring for accepting merge requests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-07-16 16:03:07 +02:00
Dmitriy Zaporozhets
dfccb06dda
Refactor web editor
* fix problem with editing non-master branch
* before commit make sure branch exists
* dont allow user change file in one branch and commit to another existing branch
* remove a lot of code duplication
* remove outdated statellite errors

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-05 15:01:38 +02:00
Dmitriy Zaporozhets
435f680b89
Make web editor work correctly after switch from satellites
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-02 12:06:40 +02:00
Dmitriy Zaporozhets
3d416f1682
Create activity event and execute hooks on web editor commit
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-02 10:45:13 +02:00
Ciro Santilli
2d23522107 Use :message key, not :error for File::Service. 2014-10-13 20:55:09 +02:00
Ciro Santilli
ad47993ac4 Factor error and success methods from services. 2014-09-21 11:43:05 +02:00
Dmitriy Zaporozhets
1d2bdb4d58
Move all Context classes into Services
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-01-16 19:03:42 +02:00
Renamed from app/contexts/files/base_context.rb (Browse further)