Commit Graph

44 Commits

Author SHA1 Message Date
blackst0ne 02aa269e34 Add branch existence check to the APIv4 branches via HEAD request 2017-09-05 20:54:12 +11:00
Sean McGivern b9d8946395 Don't use public_send in destroy_conditionally! helper
As we only override in two places, we could just ask for the value rather than
the method name.
2017-08-30 14:32:02 +01:00
Robert Schilling f0f3f38576 Use commit date for branches and tags 2017-08-28 16:40:25 +02:00
Eric fb5b2d8d0e Extending API for protected branches 2017-08-02 10:16:17 +00:00
Rémy Coutable 4e3e0dc8d4
DRY the branches API requirements definition
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:29:42 +02:00
Rémy Coutable 649382b1c2 Fix the /projects/:id/repository/branches endpoint to handle dots in the branch name when the project full patch contains a `/`
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:29:31 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Rémy Coutable aaaee8ae27 Allow unauthenticated access to some Branch API GET endpoints
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-03-20 09:37:31 +01:00
Rémy Coutable 63360adeae
Add `requirements: { id: %r{[^/]+} }` for all projects and groups namespaced API routes
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-03-16 18:00:24 +01:00
Robert Schilling 86c58687b2 Return 204 for delete endpoints 2017-02-28 08:32:38 +01:00
Oswaldo 2b001d9e7a Return 202 with JSON body on async removals on V4 API 2017-02-23 19:55:13 -03:00
Oswaldo Ferreira c79bbe26ab Change branch_name param to branch throughout V4 API 2017-02-21 16:33:14 -03:00
Robert Schilling 01ea65e0e9 Paginate all endpoints that return an array 2017-02-16 15:32:01 +01:00
Z.J. van de Weg 128b1eae09 Update Rubocop to ruby 2.3 2017-02-07 15:16:46 +01:00
Robert Schilling 4f17fc8087 Grapify last endpoint of the branches API 2017-01-24 20:24:59 +01:00
Felipe Artur 4a0ca85834 Allow branch names with dots on API endpoint 2016-12-08 16:39:56 -02:00
Toon Claes 1afab9eb79 Add button to delete all merged branches
It adds a button to the branches page that the user can use to delete
all the branches that are already merged. This can be used to clean up
all the branches that were forgotten to delete while merging MRs.

Fixes #21076.
2016-11-09 21:04:03 +01:00
Z.J. van de Weg a83d4d0128 GrapeDSL for branches endpoints 2016-10-31 13:21:29 +01:00
Timothy Andrew 1051087ac4 Implement second round of review comments from @DouweM.
- Pass `developers_and_merge` and `developers_can_push` in `params`
  instead of using keyword arguments.

- Refactor a slightly complex boolean check to a simple `nil?` check.
2016-10-24 11:33:38 +05:30
Timothy Andrew b803bc7bb8 Implement review comments from @DouweM. 2016-10-24 11:33:38 +05:30
Timothy Andrew f79f3a1dd6 Fix branch protection API.
1. Previously, we were not removing existing access levels before
   creating new ones. This is not a problem for EE, but _is_ for CE,
   since we restrict the number of access levels in CE to 1.

2. The correct approach is:

    CE -> delete all access levels before updating a protected branch
    EE -> delete developer access levels if "developers_can_{merge,push}" is switched off

3. The dispatch is performed by checking if a "length: 1" validation is
   present on the access levels or not.

4. Another source of problems was that we didn't put multiple queries in
   a transaction. If the `destroy_all` passes, but the `update` fails,
   we should have a rollback.

5. Modifying the API to provide users direct access to CRUD access
   levels will make things a lot simpler.

6. Create `create/update` services separately for this API, which
   perform the necessary data translation, before calling the regular
   `create/update` services. The translation code was getting too large
   for the API endpoint itself, so this move makes sense.
2016-10-24 11:33:38 +05:30
Timothy Andrew dd3b738d5b Fix failing tests relating to backporting ee!581.
1. `GitPushService` was still using `{merge,push}_access_level_attributes` instead
   of `{merge,push}_access_levels_attributes`.

2. The branches API creates access levels regardless of the state of the
   `developers_can_{push,merge}` parameters. This is in line with the UI,
   where Master access is the default for a new protected branch.

3. Use `after(:build)` to create access levels in the
   `protected_branches` factory, so that `factories_spec` passes. It
   only builds records, so we need to create access levels on `build` as
   well.
2016-08-16 13:42:34 +05:30
Timothy Andrew 0a8aeb46dc Use `Gitlab::Access` to protected branch access levels.
1. It makes sense to reuse these constants since we had them duplicated
   in the previous enum implementation. This also simplifies our
   `check_access` implementation, because we can use
   `project.team.max_member_access` directly.

2. Use `accepts_nested_attributes_for` to create push/merge access
   levels. This was a bit fiddly to set up, but this simplifies our code
   by quite a large amount. We can even get rid of
   `ProtectedBranches::BaseService`.

3. Move API handling back into the API (previously in
   `ProtectedBranches::BaseService#translate_api_params`.

4. The protected branch services now return a `ProtectedBranch` rather
   than `true/false`.

5. Run `load_protected_branches` on-demand in the `create` action, to
   prevent it being called unneccessarily.

6. "Masters" is pre-selected as the default option for "Allowed to Push"
   and "Allowed to Merge".

7. These changes were based on a review from @rymai in !5081.
2016-07-29 15:20:39 +05:30
Timothy Andrew 01d190a84a Have the `branches` API work with the new protected branches data model.
1. The new data model moves from `developers_can_{push,merge}` to
   `allowed_to_{push,merge}`.

2. The API interface has not been changed. It still accepts
   `developers_can_push` and `developers_can_merge` as options. These
   attributes are inferred from the new data model.

3. Modify the protected branch create/update services to translate from
   the API interface to our current data model.
2016-07-29 15:20:39 +05:30
Robert Schilling 3413f6fa50 Simplify entities for branches and tags API 2016-07-19 13:41:32 +02:00
Robert Schilling 3e281f9590 Only update once 2016-07-19 11:33:47 +02:00
Robert Schilling e552b4af26 API: Expose 'developers_can_merge' for branches 2016-07-19 11:12:03 +02:00
Robert Schilling 54d26c89f6 API: Expose 'developers_can_push' for branches 2016-07-19 11:11:56 +02:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Robert Schilling cc324eb4ab Ensure that branch and tag names are given in API 2016-06-30 13:46:35 +02:00
Yasser Hussain d023a85287 Changed the argument of not_found for 'unprotect'
not_found appends string "Not Found" to the argument causing the resulting message to be "Branch does not exist Not Found" which is an incorrect error message.

Changed the argument of not_found! for 'unprotect'  command to "Branch" from "Branch does not exist".  This makes the final error message to appear as "Branch Not Found" which is correct and same as error messages for other commands like 'protect'.
2016-04-06 15:07:31 +05:30
Dan Tudor a6c6335671 Added the missing comma 2015-03-31 17:08:33 +01:00
Dan Tudor 00dd44455a Allow ability to delete branches with '/` in name 2015-03-25 15:15:26 +00:00
Dan Tudor 862e1e6f17 Unescape branch param to delete
Branch names that contain `/` return a 405 error when being deleted because the slash is escaped to `%2F`
This patch will unescape the param prior to  executing the delete action.
2015-03-24 13:04:22 +00:00
Marin Jankovski 7fa80b5bd0 Update branch api not found messages to 'Branch not found'. 2014-12-30 13:37:14 +01:00
Dmitriy Zaporozhets 961a6bfcc2
API delete branch: render branch name json instead of true
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-10-30 17:28:59 +02:00
Dmitriy Zaporozhets eaeb4a90d4
Fix branch API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-25 16:22:08 +03:00
Ciro Santilli ad47993ac4 Factor error and success methods from services. 2014-09-21 11:43:05 +02:00
Robert Schilling 551145bc98 Validate branch-names and references in WebUI, API
Add specs for GitRefValidator
2014-09-03 13:08:35 +02:00
Dmitriy Zaporozhets d575ee3e90
Improve branch deletion via API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-23 15:34:02 +03:00
Dmitriy Zaporozhets a9d60b3b14
Api call to remove branch
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-22 14:39:50 +03:00
Sean Edge da9b009d31 Add fix for API when branch names have periods in them. Relates to issue #6128 (https://github.com/gitlabhq/gitlabhq/issues/6128). 2014-05-08 07:06:47 -04:00
Dmitriy Zaporozhets 33a00ceeea
Create branch via API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-04-01 10:39:53 +03:00
Dmitriy Zaporozhets 9b276f0003
Move branches api to separate class
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-03-31 16:31:53 +03:00