Commit Graph

318 Commits

Author SHA1 Message Date
Sean McGivern 2f7dffe548 Add source and target branch filters to merge requests API 2018-03-01 10:41:02 +00:00
Yorick Peterse cca61980d5
Track and act upon the number of executed queries
This ensures that we have more visibility in the number of SQL queries
that are executed in web requests. The current threshold is hardcoded to
100 as we will rarely (maybe once or twice) change it.

In production and development we use Sentry if enabled, in the test
environment we raise an error. This feature is also only enabled in
production/staging when running on GitLab.com as it's not very useful to
other users.
2018-02-01 17:00:46 +01:00
Sean McGivern 06713cb7b0 Merge branch '39214__pipeline_api' into 'master'
Add `pipelines` endpoint to merge requests API

Closes #39214

See merge request gitlab-org/gitlab-ce!15454
2018-01-11 11:29:53 +00:00
Tony Rom 7ed08fcd5d Fix style 2018-01-10 20:05:34 +03:00
Brent Greeff 34b9cc9674 API: get participants from merge_requests & issues 2018-01-05 15:21:53 +00:00
Mark Fletcher 055543b915 Add optional `search` param for Merge Requests API 2017-12-20 07:23:57 +00:00
Mark Fletcher c9732b3c6d Employ declared_params in finder methods for MR and Issue API lists
- Ensure that unwanted params are no passed to actual finder classes
2017-12-20 07:23:57 +00:00
Tony Rom fd88b0ca56 Add `pipelines` endpoint to merge requests API 2017-12-15 19:53:57 +03:00
George Andrinopoulos 7fb1bb01bd Create issue and merge request destroy services 2017-11-25 22:09:18 +02:00
Sean McGivern 991bf24ec8 Use latest_merge_request_diff association
Compared to the merge_request_diff association:

1. It's simpler to query. The query uses a foreign key to the
   merge_request_diffs table, so no ordering is necessary.
2. It's faster for preloading. The merge_request_diff association has to load
   every diff for the MRs in the set, then discard all but the most recent for
   each. This association means that Rails can just query for N diffs from N
   MRs.
3. It's more complicated to update. This is a bidirectional foreign key, so we
   need to update two tables when adding a diff record. This also means we need
   to handle this as a special case when importing a GitLab project.

There is some juggling with this association in the merge request model:

* `MergeRequest#latest_merge_request_diff` is _always_ the latest diff.
* `MergeRequest#merge_request_diff` reuses
  `MergeRequest#latest_merge_request_diff` unless:
    * Arguments are passed. These are typically to force-reload the association.
    * It doesn't exist. That means we might be trying to implicitly create a
      diff. This only seems to happen in specs.
    * The association is already loaded. This is important for the reasons
      explained in the comment, which I'll reiterate here: if we a) load a
      non-latest diff, then b) get its `merge_request`, then c) get that MR's
      `merge_request_diff`, we should get the diff we loaded in c), even though
      that's not the latest diff.

Basically, `MergeRequest#merge_request_diff` is the latest diff in most cases,
but not quite all.
2017-11-23 12:14:56 +00:00
Mark Fletcher ff1e3a47c4 Fix namespacing for MergeWhenPipelineSucceedsService in MR API 2017-10-30 17:19:51 +00:00
Sean McGivern a68a39e341 Merge branch '18608-lock-issues-v2' into 'master'
Resolve "Lock issue and merge request"

Closes #18608

See merge request gitlab-org/gitlab-ce!14531
2017-10-06 16:47:27 +00:00
Vitaliy @blackst0ne Klachkov c55a9ac4ae Remove 'Repo' prefix from API entites 2017-10-05 19:48:05 +11:00
Luke "Jared" Bennett ff7b545c8e
Merge remote-tracking branch 'origin/master' into 18608-lock-issues 2017-09-20 15:23:00 +01:00
haseeb ff4e81e0ae fix #35290 Make read-only API for public merge requests available without authentication 2017-09-18 17:29:17 +00:00
Jarka Kadlecova 073ba05d31 Support discussion lock in the API 2017-09-14 14:50:32 +02:00
Hiroyuki Sato 7e42711659 Add my_reaction_emoji param to /merge_requests API 2017-09-05 11:56:17 +09:00
Robert Schilling 6a2ee0968e API: Use defined project requirements 2017-08-31 14:57:47 +02:00
Robert Speicher 966b635221 Merge branch '28453-add-time-estimate-time-spent-to-api-issue-output' into 'master'
Add time stats to Issue and Merge Request API

Closes #28453

See merge request !13335
2017-08-30 17:35:14 +00:00
Travis Miller 749c389345 Add time stats to issue and merge request API end points 2017-08-29 08:31:36 -05:00
Robert Schilling e80313f9ee Conditionally destroy a ressource 2017-08-28 16:40:25 +02:00
Robert Schilling 998afa5f74 API: Respect the 'If-Unmodified-Since' for delete endpoints 2017-08-28 16:40:25 +02:00
Toon Claes d77088bb0b Default /merge_request API endpoint to `scope=created-by-me`
This matches the behavior of the /issues endpoint.
2017-07-28 00:07:28 +02:00
Toon Claes d7505de8b3 Add top-level /merge_requests API endpoint
And add support for additional query parameters:
- `author_id`: Returns merge requests created by the given user `id`
- `assignee_id`: Returns merge requests assigned to the given user `id`
- `scope`: Return merge requests for the given scope: `created-by-me`, `assigned-to-me` or `all`
2017-07-27 23:34:57 +02:00
Jarka Kadlecova 7bee7b848a Support both internal and external issue trackers 2017-07-24 08:13:43 +02:00
Dmitriy Zaporozhets 6b8ad689da
Update grape gem
New version of the gem returns 200 status code on delete with content
instead of 204 so we explicitly set status code to keep existing
behavior

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-07-20 16:33:18 +03:00
Stan Hu faf9543827 Use view=simple for simplifying merge requests API 2017-07-11 08:02:13 -07:00
Stan Hu e17ac5705d Add a simple mode to merge request API
The current "basic" merge request API still loads too much data. For integrations
like the Trello Power-up, we just need the basics.

Closes #34920
2017-07-11 06:32:13 -07:00
Stan Hu 1f0ee9ca19 Fix sort ordering with merge request API 2017-07-10 15:08:07 -07:00
Stan Hu ef526ff33c Paginate the merge requests API earlier to avoid eager loading every merge request
Fixes a performance regression introduced in !12732
2017-07-10 13:56:46 -07:00
Stan Hu 88c4248ac7 Remove remaining N+1 queries in merge requests API with emojis and labels
Closes #34159
2017-07-08 22:19:34 -07:00
Stan Hu b963d45ca4 Remove many N+1 queries with merge requests API
Identified via `ENABLE_BULLET=1 bundle exec rspec spec/requests/api/merge_requests_spec.rb:34`

Improves speed of #34159
2017-07-07 16:31:21 -07:00
Rémy Coutable 9fe6c2b2c2 Merge branch 'add-since-and-until-params-to-issuables' into 'master'
add created_after and created_before params to issuables

Closes #32901

See merge request !12151
2017-06-19 12:13:27 +00:00
Kyle Bishop ef633d2478 add since and until params to issuables 2017-06-18 15:43:51 -07:00
Felipe Artur c472017078 Fix API bug accepting wrong merge requests parameters 2017-06-16 16:33:09 -03:00
mhasbini ccac05dd90 Fix 404 when upstream has disabled merge requests 2017-04-27 01:04:07 +03:00
Robert Schilling 2ea5d4b7af Ability to filter merge requests by labels and milestones 2017-04-25 22:07:38 +02:00
Chris Wilson e670cb271e Fix updating merge_when_build_succeeds via merge API endpoint
When updating a merge request via the `/merge` endpoint we
check the `mergeable` and `mergeable_state` status, these will return
`false` if the application option only_allow_merge_if_pipeline_succeeds is
enabled. We should skip CI checks if the request uses the
merge_when_pipeline_succeeds param

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/22740
2017-04-24 20:51:05 +10:00
Oswaldo Ferreira fd32960e7c Separate CE params on Grape API 2017-04-10 16:13:48 -03:00
Toon Claes d536d9590b Remove `:id/merge_requests/:merge_request_iid/comments` endpoints
Comments for a merge request should be obtained to the `notes` endpoint.
2017-03-27 10:23:14 +02: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
Timothy Andrew 719327112c
API routes referencing a specific merge request should use the MR `iid`
- As opposed to the `id` that was previously being used.
- This brings the API routes closer to the web interface's routes.
- This is specific to API v4.
2017-03-07 13:06:42 +05:30
Adam Niedzielski c727d4328f Remove "subscribed" field from API responses returning list of issues or merge requests 2017-03-06 14:17:07 +01:00
James Lopez a0101ebf84 Update occurrences of MWBS to MWPS
Rename column in the database
 Rename fields related to import/export feature
 Rename API endpoints
 Rename documentation links
 Rename the rest of occurrences in the code
 Replace the images that contain the words "build succeeds" and docs referencing to them
 Make sure pipeline is green and nothing is missing.

updated doc images

renamed only_allow_merge_if_build_succeeds in projects and fixed references

more updates

fix some spec failures

fix rubocop offences

fix v3 api spec

fix MR  specs

fixed issues with partials

fix MR spec

fix alignment

add missing v3 to v4 doc

wip - refactor v3 endpoints

fix specs

fix a few typos

fix project specs

copy entities fully to V3

fix  entity error

more fixes

fix failing specs

fixed missing entities in V3 API

remove comment

updated code based on feedback

typo

fix spec
2017-03-01 12:02:02 +01:00
Robert Schilling 01ea65e0e9 Paginate all endpoints that return an array 2017-02-16 15:32:01 +01:00
James Edwards-Jones 744df2dca8 Update MergeRequest API state_event option documentation 2017-02-09 14:23:49 +00:00
Oswaldo Ferreira c2d64d6702 Remove deprecated MR and Issue endpoints and preserve V3 namespace 2017-02-06 10:12:20 -02:00
Robert Speicher 3a5df1d8fc Merge branch 'fix-api-mr-permissions' into 'security'
Ensure that only privileged users can access merge requests in the API

See merge request !2053
2017-01-23 13:54:35 -05:00
Ruben Davila 0f3c9355c1 Add some API endpoints for time tracking.
New endpoints are:

POST :project_id/(issues|merge_requests)/(:issue_id|:merge_request_id)/time_estimate"

POST :project_id/(issues|merge_requests)/(:issue_id|:merge_request_id)/reset_time_estimate"

POST :project_id/(issues|merge_requests)/(:issue_id|:merge_request_id)/add_spent_time"

POST :project_id/(issues|merge_requests)/(:issue_id|:merge_request_id)/reset_spent_time"

GET  :project_id/(issues|merge_requests)/(:issue_id|:merge_request_id)/time_stats"
2017-01-18 10:48:16 -06:00
Robert Schilling 2cbd07e69c Don't allow blank MR titles in API 2016-12-13 09:01:48 +01:00
Rémy Coutable 192d40e53e Merge branch 'api-remove-source-branch' into 'master'
API: Ability to remove source branch

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/23577

See merge request !7804
2016-12-09 13:39:53 +00:00
Rémy Coutable d134c72523 Merge branch 'use-pagination-helper' into 'master'
Use the pagination helper in the API

See merge request !7920
2016-12-05 12:11:14 +00:00
Robert Schilling 74c8669b0a Use the pagination helper in the API 2016-12-04 18:11:19 +01:00
Robert Schilling 8b5c16e4b1 API: Ability to remove source branch 2016-12-04 16:52:42 +01:00
Grzegorz Bizon 00ca7adca2 Merge branch 'master' into fix/rename-mwbs-to-merge-when-pipeline-succeeds
* master: (110 commits)
  Rewrite an HTTP link to use HTTPS
  Edit /spec/features/profiles/preferences_spec.rb to match changes in 084d90ac
  Add blue back to sub nav active
  Remove JSX/React eslint plugins.
  Fix a transient spec failure
  Adds hoverstates for collapsed Issue/Merge Request sidebar
  Moved groups above projects
  Add StackProf to the Gemfile, along with a utility to get a profile for a spec
  Update Sidekiq-cron to fix compatibility issues with Sidekiq 4.2.1
  Add a CHANGELOG entry
  Alert user when logged in user email is not the same as the invitation
  Expose timestamp in build entity used by serializer
  Rename `MergeRequest#pipeline` to `head_pipeline`
  Remove unnecessary database indexes
  CE-specific changes gitlab-org/gitlab-ee#1137
  Fixing typo & Clarifying Key name
  fix started_at check
  fix blob controller spec failure - updated not to use file-path-
  fix blob controller spec failure
  Merge branch 'jej-use-issuable-finder-instead-of-access-check' into 'security'
  ...

Conflicts:
	app/controllers/projects/merge_requests_controller.rb
	lib/api/merge_requests.rb
	spec/requests/api/merge_requests_spec.rb
2016-11-30 12:21:33 +01:00
Grzegorz Bizon a49e9949c6 Rename `MergeRequest#pipeline` to `head_pipeline` 2016-11-29 14:12:49 +01:00
Douwe Maan 3d7704ae5f Merge branch 'zj-fix-label-creation-non-members' into 'security'
Fix label creation non members

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/23416

See merge request !2006
2016-11-28 21:24:19 -03:00
Grzegorz Bizon 895d97af87 Merge branch 'master' into fix/rename-mwbs-to-merge-when-pipeline-succeeds
* master: (312 commits)
  Fix bad selection on dropdown menu for tags filter
  Fixed issue boards scrolling with a lot of lists & issues
  You can only assign default_branch when editing a project ...
  Don't convert data which already is the target type
  Stop supporting Google and Azure as backup strategies
  renames some of the specs and adds changelog entry
  Fixed dragging issue moving wrong issue after multiple drags of issue
  Fixed issue boards issue sorting when dragging issue into list
  Rephrase some system notes to be compatible with new system note style
  Add missing JIRA file that redirects to the new location
  Fix documentation to create the `pg_trm` extension before creating the DB
  Document that we always use `do...end` for `before` in RSpec
  Backport Note#commands_changes from EE
  Log mv_namespace parameters
  Add default_branch attr to Project API payload in docs.
  Fix title case to sentence case
  properly escape username validation error message flash
  Remove header ids from University docs
  Add missing documentation.
  Added test that checks the correct select box is there for the LFS ...
  ...

Conflicts:
	app/services/system_note_service.rb
	spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb
	spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
	spec/services/system_note_service_spec.rb
2016-11-25 11:05:34 +01:00
Rémy Coutable 7902395f1f Merge branch 'fix-api-iid-filter' into 'master'
Fix IID filter for merge requests and milestones

I updated the example in the docs and added a test. The milestones API was also broken for the same reason.

Related to !7358 and !7373

See merge request !7648
2016-11-22 16:16:43 +00:00
Robert Schilling 9e608b41a1 Avoid helper call with default parameters 2016-11-22 11:26:29 +01:00
Robert Schilling cb11d3521c Fix IID filter for merge requests and milestones 2016-11-22 08:25:07 +01:00
Grzegorz Bizon c6a4f9fc5b Update some docs to reflect MWPS name change 2016-11-21 11:27:28 +01:00
Grzegorz Bizon 01f238893a Rename MWBS service to Merge When Pipeline Succeeds 2016-11-21 10:22:09 +01:00
Douglas Barbosa Alexandre 0c052f116c Remove default value for `project` argument on subscribable concern 2016-11-17 15:10:13 -02:00
Robert Schilling 9dbb0417ba Grapify the merge request API 2016-11-15 10:31:18 +01:00
Douglas Barbosa Alexandre 033ea9d1e8 Move label management to services on merge requests API 2016-10-19 14:58:26 -02:00
Douglas Barbosa Alexandre 7e11ca86fd Reuse LabelsFinder on Issueable#add_labels_by_names 2016-10-19 14:58:25 -02:00
Robert Schilling 839aec1a61 Replace parse_boolean with to_boolean 2016-07-20 08:55:44 +02:00
Douwe Maan 6ce25e7b4c Rename MergeRequest methods that return commits or shas to be more clear and consistent 2016-07-06 18:50:58 -04:00
Stan Hu a85dde9182 Fix Error 500 when using closes_issues API with an external issue tracker
Closes #18484
2016-06-11 19:50:08 -07:00
Rémy Coutable 6dff7c1771 Improve initial implementation of the 'only_allow_merge_if_build_succeeds.rb' feature
Based on the feedback from reviewers.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-10 14:36:57 +02:00
Rui Anderson 07dbd6b388 Allow or not merge MR with failed build
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-10 14:36:54 +02:00
Alejandro Rodríguez fade1a4cde Fix pseudo n+1 queries with Note and Note Authors in issuables APIs
This was not a clear cut n+1 query, given that if you're directly subscribed to all issues
that the API is returning you never really need to check for the notes. However, if you're
subscribed to _all_ of them, then for each issuable you need to go once to `notes`, and
once to `users` (for the authors). By preemtively loading notes and authors, at worst you have
1 extra query, and at best you saved 2n extra queries. We also took advantage of this preloading
of notes when counting user notes.
2016-06-08 10:26:05 -04:00
Kamil Trzcinski 8ce1896b46 Merge commit 'ca3c5c295ed653b483fe81c3918ffe60f46666b9' into rename-ci-commit
* commit 'ca3c5c295ed653b483fe81c3918ffe60f46666b9':
  Let contributors know where to start
  Ensure branch cleanup regardless of whether the import process succeeds
  Fix failing todo tests
  Reorder the todos because the use of the project finder attempts to order them differently
  Update target todo test to use a public project
  Use the project finder in the todos finder to limit todos to just ones within projects you have access to.
  Move filtering todos by projects not pending deletion into a scope on the todo model
  Reduce the filters on the todos joins project query by being explicit about the join
  Ensure we don't show TODOS for projects pending delete
  Fix deprecation warnings in spec/services/issues/bulk_update_service_spec.rb
  Remove unused Issuable#is_assigned? method
  fixup! Don't allow merges with new commits
  fixup! Add `sha` parameter to MR accept API
  Reduce Namespace queries in UserReferenceFilter
  Added ReferenceFilter#nodes
  Returning enums in ReferenceFilter#each_node
  Don't allow merges with new commits
  Add `sha` parameter to MR accept API
2016-06-03 15:53:26 +02:00
Sean McGivern 04fdf4b9a9 fixup! Add `sha` parameter to MR accept API 2016-06-02 17:00:16 +01:00
Kamil Trzcinski 021d3810c3 Rename Ci::Commit to Ci::Pipeline and rename some of the ci_commit to pipeline 2016-06-02 16:59:04 +02:00
Sean McGivern d863d86aeb Add `sha` parameter to MR accept API
The `sha` parameter is optional, and when present, must match the
current HEAD SHA of the source branch. Otherwise, the API call fails
with a 409 Conflict and a message containing the current HEAD for the
source branch.

Also tidy up some doc wording.
2016-06-01 20:29:54 +01:00
Ahmad Sherif 0c22698bd4 Add API endpoints for un/subscribing from/to a label
Closes #15638
2016-05-12 22:48:09 +02:00
Robert Schilling fa3009095f Make subscription API more RESTful 2016-04-13 13:52:13 +02:00
Robert Schilling f875189b39 API: Ability to subscribe and unsubscribe from a merge request 2016-04-13 13:45:01 +02:00
Robert Schilling fb2fde9d62 API: Expose subscribed? on issues 2016-04-08 15:53:04 +02:00
Zeger-Jan van de Weg 3b088fc5b5 Minor improvements on IssuableActions 2016-03-21 16:59:35 +01:00
Zeger-Jan van de Weg 1d77822816 minor improvements and fixed specs 2016-03-19 21:24:05 +01:00
Zeger-Jan van de Weg 212e83bab3 Soft delete issuables 2016-03-19 21:23:03 +01:00
Douwe Maan 0807bd5130 Merge branch 'skakirill/gitlab-ce-api-merge-request-setup-milestone' into 'master'
API: Allow to set or update a merge-request's milestone

_Originally opened at !2107 by @ skakirill._

- - -


See merge request !2755
2016-02-12 08:39:18 +00:00
Rémy Coutable b91d1890a8 Pass current_user to merge_request.closes_issues in API ans streamline MR API specs 2016-02-11 09:34:07 +01:00
Gal Schlezinger 78e36780be Added '/api/v3/projects/:id/merge_requests/:merge_request_id/closes_issues' route in the API
Added some documentation for it

Added to changelog

Added curl example and an attribute table

Moved the api route definition from "lib/api/issues.rb" to "lib/api/merge_requests.rb"

Fixed the attributes and changed the documentation to be at "merge_requests.md" too

Changed generic titles to more specific titles

added an underscore

added tests. it depends on a newer version of gitlab-test project
I'm doing a  since I need to add a branch to the `gitlab-test` repo

removed the before

using 'iid' instead of 'id' in the description to reference the issues. that makes the tests pass

Removed the 'closes-issues' key from test_env. so it should pass the tests

Moved the two initializations to the describe block

Changed the changelog
2016-02-11 09:34:07 +01:00
Kirill Skachkov 81f2a9e5b0 API: Allow to set or update a merge-request's milestone 2016-02-08 15:49:35 +01:00
Dmitriy Zaporozhets dfb8803c1c
Improve consistency and duplication for Merge Request API
* Follow REST for merge request API route
* Remove repeating comments API for MR

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-01-28 14:26:12 +01:00
Douwe Maan 097faeb481 Get "Merge when build succeeds" to work when commits were pushed to MR target branch while builds were running 2016-01-05 16:30:03 +01:00
Zeger-Jan van de Weg 0e96d6eb10 Merge branch 'master' into merge-if-green 2015-12-07 10:06:07 +01:00
Dmitriy Zaporozhets 0b68a0e79e
Add API endpoint to fetch merge request commits list
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-12-04 11:08:10 +01:00
Zeger-Jan van de Weg a7682f8775 Specs for 'Merge When Build Succeeds' 2015-12-02 13:27:16 +01:00
Zeger-Jan van de Weg 8608c6325e Refactor MergeWhenBuildSucceedsService and incorporate feedback 2015-11-23 10:11:54 +01:00
Zeger-Jan van de Weg 2f048df4a4 API support, incorporated feedback 2015-11-18 11:17:41 +01:00
Dmitriy Zaporozhets 353ddbc795 Merge branch 'stanhu/gitlab-ce-fix-api-mr-comment-notifications' 2015-10-15 15:56:43 +02:00
sue445 a092d27025 [ci skip] Fix wrong comment
According to `attributes_for_keys` and API doc, `POST /projects/:id/merge_requests`
is received `target_project_id` (NOT `target_project`)
2015-10-14 00:36:54 +09:00
Stan Hu 2df573dac3 Fix bug where merge request comments created by API would not trigger notifications
Closes https://github.com/gitlabhq/gitlabhq/issues/9715
2015-10-10 10:59:02 -07:00
Stan Hu 1c289ac0c3 Fix broken sort in merge request API
Closes #2266
2015-09-15 22:55:22 -07: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 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 b48b07044b
Merge branch 'master' into drop-satellites
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-04 16:42:36 +02:00
Dmitriy Zaporozhets c17f5d06aa
Fix merge api and spec
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-08-04 16:33:53 +02:00
Stan Hu 6c9f527b3f Return comments in created order in merge request API
Closes #1832
2015-07-16 22:33:58 -07: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 342d553709
Rename abilities to correspond contoller/model action names
write_ was renamed to create_
modify_  was renamed to update_

So now in update action we have next code

def create
  can?(current_user, :create_issue, @issue)
end

def update
  can?(current_user, :update_issue, @issue)
end

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-06-26 15:55:56 +02:00
Stan Hu 85145d1d77 Disable changing of the source branch in merge request update API 2015-05-29 09:40:35 -07:00
jubianchi 2c544d43c8 Query issues, merge requests and milestones with their IID through API 2015-05-02 10:44:52 +02:00
Douwe Maan 7e0eb486ed Don't allow a merge request to be merged when its title starts with "WIP". 2015-04-30 15:46:36 +02:00
Douwe Maan 4830b2be5e Refactor GitAccess to use instance variables. 2015-03-24 14:11:48 +01:00
Dmitriy Zaporozhets bdfb349ff7 Refactor and improve sorting objects in API for projects, issues and merge requests 2015-02-05 22:00:54 -08:00
Jeroen van Baarsen b60d06eb2c Added a way to retrieve MR files
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
2015-02-04 10:24:25 +01:00
Valery Sizov ab7a79bf3b developer can push to protected branches 2015-01-20 17:34:23 -08:00
Marin Jankovski 8dd672776e Fix failing tests due to updates on the return messages. 2015-01-07 11:39:20 +01:00
Marin Jankovski cd0aed3d54 Add a message when unable to save an object through api. 2015-01-07 10:46:00 +01:00
Dmitriy Zaporozhets d0e3ab5826 Merge branch 'api/improve-error-reporting' of https://github.com/jubianchi/gitlabhq into jubianchi-api/improve-error-reporting 2014-09-23 21:35:45 +03:00
Marin Jankovski 685754b088 Fix typo in comment. 2014-09-16 08:44:50 +02:00
jubianchi 998cd3cb63 Improve error reporting on users API
* users (#6878, #3526, #4209): Validation error messages are now exposed through 400 responses, 409 response are sent in case of duplicate email or username
* MRs (#5335): 409 responses are sent in case of duplicate merge request (source/target branches), 422 responses are sent when submiting MR fo/from unrelated forks
* issues
* labels
* projects
2014-09-16 01:25:24 +02:00
Marin Jankovski b99b2e60d5 Ordering and sorting for MR in api. 2014-09-15 11:54:49 +02:00
Robert Schilling 66f6ca0770 Fix tests after #7526 2014-08-20 20:34:55 +02:00
Robert Schilling cbc90565b5 Do label validation for issues/merge requests API 2014-08-14 10:17:52 +02:00
Dmitriy Zaporozhets d9d8d3b799
Fix old api compatibility and tests
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-07-30 17:17:29 +03:00
Dmitriy Zaporozhets f8ea52c3a0
Remove thread vars usage from API notes and mr's
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-10 17:56:35 +03:00
Dmitriy Zaporozhets 1f1c59b61d Merge pull request #6778 from dblessing/feature/mr_labels
Merge Request Labels
2014-05-13 14:43:46 +03:00
Drew Blessing 5f25cdfe19 Implement Merge Request Labels 2014-05-13 06:41:36 -05:00
Dmitriy Zaporozhets ab032256da
Add some tests for merge API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-13 11:01:40 +03:00
Dmitriy Zaporozhets 5880d7df62
Docs for merge api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-12 18:01:22 +03:00
Dmitriy Zaporozhets 0c73e66643
Specify error codes for merge api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-12 17:51:43 +03:00
Dmitriy Zaporozhets fe6d392236
Draft API method for merge MR
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-12 16:34:41 +03:00
Stuart Pook 66209fbc76 Add optional parameter to list merge requests
Add an optional parameter to list merge requests to restrict the
returned merge requests to those that are "opened", "merged" or
"closed". By default all merge requests are returned. Note that
"all" can be given to explicitly request all merge requests.
2014-04-07 16:18:25 +02:00
Dmitriy Zaporozhets 9ee697dd68
Use MergeRequest services in API and controllers
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-04-02 21:51:53 +03:00
Stuart Pook 9886998f24 Add method to get the comments on a merge request
Add method to get the comments for a merge request and
document that you can change the status of a merge request.
2014-03-19 19:07:51 +01:00
Greg Messner 7e14f86c71 Added description parameter support to Create and Update MR API endpoints (issue-110). 2014-03-03 23:08:39 -08:00
Dmitriy Zaporozhets 1c61ac1c64
Refactor MR code reload
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-02-18 20:17:26 +02:00
Dmitriy Zaporozhets 28e13634dc
Merge branch 'improve/mr_diff'
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

Conflicts:
	features/steps/project/project_fork.rb
	features/steps/project/project_forked_merge_requests.rb
	features/steps/project/project_issue_tracker.rb
	features/steps/project/project_markdown_render.rb
	features/steps/shared/project.rb
2014-01-23 14:38:23 +02:00
Dmitriy Zaporozhets 4b3afe2325
Always create merge_request_diff if MR created
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-01-22 20:22:20 +02:00
skv a3f645ef51 Remove deprecated finders 2014-01-19 23:39:56 +04:00
Angus MacArthur aefe2e952f Fixing unsafe use of Thread.current variable :current_user 2013-10-16 01:20:53 -04:00
Hiroyuki Sato d426195df8 Fix API::MergeRequest
Fixes #5144 Refs #4996
2013-09-22 08:21:22 +09:00
Hiroyuki Sato df9cbbc924 Drop support of root namespace in routing 2013-09-13 07:00:24 +09:00
Izaak Alpert fae3f46615 Refactor merge api create
-Made the api method a little more readable
-removed some missed extra newline's

Change-Id: Ic38baafc813aaeda0a8b283f39916182c8ec37d5
2013-07-17 22:48:03 -04:00
Izaak Alpert 489fa5d726 MR on Fork multiple fixes
-Disable observers post test run
-Allow db:seed_fu RAILS_ENV=test to be run more than once without error
-fix diffs_in_between, was passing in the default_options for grit, but grit in this case doesn't take options, fixed the test to actually fail if the incorrect diffs are returned
-make notes/commits render against proper project
-MR discussion file links should reference note's project
-Added tests for commit links on edit merge request
-fixes edit issues (canceling an edited mr, updating an edited mr)
-updates tests with checks for source code updates
-still forked_merge_requests.feature (project_forked_merge_requests) test not passing (commented out -- "stable" not being set)

MR API: error on bad target_project

-If the target project id is specified and it is not the same as the project the request is being made on (the source), and the it isn't a fork of that project, error out, otherwise use it as the target
-Fixes some busted (but hidden) test cases

Conflicts:
	app/views/merge_requests/show/_diffs.html.haml
	spec/features/notes_on_merge_requests_spec.rb

Change-Id: I20e595c156d0e8a63048baaead7be6330c738a05
2013-07-17 22:42:51 -04:00
Izaak Alpert 3d7194f011 Merge Request on forked projects
The good:

 - You can do a merge request for a forked commit and it will merge properly (i.e. it does work).
 - Push events take into account merge requests on forked projects
 - Tests around merge_actions now present, spinach, and other rspec tests
 - Satellites now clean themselves up rather then recreate

The questionable:

 - Events only know about target projects
 - Project's merge requests only hold on to MR's where they are the target
 - All operations performed in the satellite

The bad:

  -  Duplication between project's repositories and satellites (e.g. commits_between)

(for reference: http://feedback.gitlab.com/forums/176466-general/suggestions/3456722-merge-requests-between-projects-repos)

Fixes:

Make test repos/satellites only create when needed
-Spinach/Rspec now only initialize test directory, and setup stubs (things that are relatively cheap)
-project_with_code, source_project_with_code, and target_project_with_code now create/destroy their repos individually
-fixed remote removal
-How to merge renders properly
-Update emails to show project/branches
-Edit MR doesn't set target branch
-Fix some failures on editing/creating merge requests, added a test
-Added back a test around merge request observer
-Clean up project_transfer_spec, Remove duplicate enable/disable observers
-Ensure satellite lock files are cleaned up, Attempted to add some testing around these as well
-Signifant speed ups for tests
-Update formatting ordering in notes_on_merge_requests
-Remove wiki schema update
Fixes for search/search results
-Search results was using by_project for a list of projects, updated this to use in_projects
-updated search results to reference the correct (target) project
-udpated search results to print both sides of the merge request

Change-Id: I19407990a0950945cc95d62089cbcc6262dab1a8
2013-07-17 22:41:30 -04:00
Dmitriy Zaporozhets 993af5d0d2 cattr_accessor is not threadsafe! 2013-06-11 18:15:18 +03:00
Dmitriy Zaporozhets 634cbd7138 Refactor API classes. So api classes like Gitlab::Issues become API::Issues 2013-05-14 15:33:31 +03:00
Dmitriy Zaporozhets 63e6f055f1 Fix notify specs. Fix merge request close via api 2013-03-28 13:24:01 +02:00
Sebastian Ziebell 3374027e3a Merge branch 'master' into fixes/api, code clean up and tests fixed
Conflicts:
	doc/api/projects.md
	spec/requests/api/projects_spec.rb
2013-03-07 14:51:56 +01:00
Sebastian Ziebell b5ef6d2268 API: refactored and simplified error handling in merge requests API 2013-03-05 23:43:05 +01:00
Sebastian Ziebell 7499f65014 API: extracted helper method to validate required parameters, code clean up
Added a helper method to check if required parameters are given in an API call. Can be used
to return a `400 Bad Request` return code if a required attribute is missing.
Code clean up and fixed tests.
2013-02-27 17:50:30 +01:00
Sebastian Ziebell 3b3add35fb API: merge request documentation updated, added return codes to functions
The API documentation of merge requests contains info to status codes for all functions.
Required arguments are now checked in the merge requests API functions and a `400 Bad Request` error is
returned if they are not given.
2013-02-27 15:07:42 +01:00
Sebastian Ziebell eefb27f5ae Merge branch 'master' into fixes/api
Conflicts:
	spec/requests/api/projects_spec.rb
2013-02-20 12:43:32 +01:00
Andrew8xx8 29f70acc98 Merge Request uses StateMachine now 2013-02-18 14:43:50 +04:00
Sebastian Ziebell 6fc3263e15 API: extracted helper method to provide 400 bad request error with description
Extracted a method for 400 error (Bad request) and adjusted code accordingly. The name of
the missing attribute is used to show which one was missing from the request. It is used to
give an appropriate message in the json response.
2013-02-13 15:48:52 +01:00
Sebastian Ziebell f978a71f41 Creating MR comment without a note returns status code 400 (Bad request)
Creating a comment to an existing merge request via API without providing a note
returns a status code 400 now, suggesting a bad request. The reason for this
is the resource itself (MR) exists but the required property is not set.
2013-02-06 17:02:30 +01:00
Sebastian Ziebell 3f4e215c80 Extracted helper method to avoid code duplication 2013-02-06 17:02:30 +01:00
Sebastian Ziebell 413952ff94 Creating or updating a MR returns more informative status codes.
Using the API library to create or update a merge request at the moment a 404 error is returned.
This is fine when the merge request in question does not exist, but does not provide good
information that for example a required attribute is missing.
A status code of 400 (Bad request) is returned when creating or updating a merge request
when either `source_branch` or `target_branch` is missing. A status code of 409 is returned
when `source_branch` and `target_branch` are the same. Tests are added for these cases.
2013-02-06 16:57:00 +01:00
Riyad Preukschas 8f01190eb5 Remove all references tp the project code parameter from the API 2012-12-21 18:47:04 +01:00
Nihad Abbasov 961cb285b0 API: restore broken merge request commenting 2012-11-29 12:11:01 -08:00
Valeriy Sizov 4281de3640 API: review 2 2012-10-25 13:38:55 +03:00
Valeriy Sizov e6cdfb607a API: tests for merge_requests 2012-10-25 13:13:01 +03:00
Valeriy Sizov 77bc110107 API: help page and comment 2012-10-22 23:09:21 +03:00
Valeriy Sizov 6ffd2f3db6 Changes after review 2012-10-22 23:09:21 +03:00
Valeriy Sizov 93e8d426c5 API: merge request: post comment call 2012-10-22 23:09:21 +03:00
Valeriy Sizov b32a8eea93 API: MergeRequest: authorization 2012-10-22 23:09:21 +03:00
Valeriy Sizov 524b907042 API: MergeRequest refactoring 2012-10-22 23:09:21 +03:00
Valeriy Sizov 5a89934af8 API: update merge request call 2012-10-22 23:09:21 +03:00
Valeriy Sizov fe59547ae5 API: create merge request 2012-10-22 23:09:21 +03:00
Valeriy Sizov bd049e5e7c API:merge request show && list 2012-10-22 23:09:21 +03:00