Commit Graph

661 Commits

Author SHA1 Message Date
Imre Farkas ba4977ab96 CE port of Move EE specific lines in API::Variables 2019-05-28 10:14:43 +00:00
Imre Farkas 3895e54741 CE port of Move EE specific lines in API::Users 2019-05-28 10:14:26 +00:00
Jan Provaznik 1db09731e7 Merge branch '51854-api-to-get-all-project-group-members-returns-duplicates' into 'master'
Resolve "API to get all project/group members returns duplicates"

Closes #51854

See merge request gitlab-org/gitlab-ce!24005
2019-05-27 14:58:31 +00:00
Jacopo a9827e0e18 Removes duplicated members from api/projects/:id/members/all
When using the members/all api the same user was returned multiple times
when he was a member of the project/group and also of one of the
ancestor groups.
Now the member is returned only once giving priority to the membership
on the project and maintaining the same behaviour of the members UI.
2019-05-27 15:40:56 +02:00
Imre Farkas a5488e452e CE-port of Refactor EE specific params override in API::Groups 2019-05-27 12:37:53 +00:00
Stan Hu fb83b82c0e Merge branch '60250-remove-mr_push_options-flag' into 'master'
Remove the mr_push_options feature flag

Closes #60250

See merge request gitlab-org/gitlab-ce!28278
2019-05-22 21:41:37 +00:00
Imre Farkas 0313795072 CE port of Move EE specific lines in API::Groups 2019-05-20 17:02:06 +00:00
Alexandru Croitor 9ff6edf690 Review updates and cleanup
* Cleaned issues and issues_statistics docs
* Renamed param with_labels_data to with_labels_details
* Added spec for N+1 check when retrieving labels from issue
* Refactoed CheckAssigneesCount validation class
2019-05-17 13:56:25 +03:00
Luke Duncalfe 515f3eb44a Remove the mr_push_options feature flag
`Gitlab::QueryLimiting.whitelist` has been moved from being inside the
feature flag conditional check to the `process_mr_push_options`
`Api::Internal` helper.

https://gitlab.com/gitlab-org/gitlab-ce/issues/60250
2019-05-17 13:47:24 +12:00
Alexandru Croitor f117c032ac Add params validations and remove extra params support
Remove label_name and milestone_title params support
Add mutually_exclusive validation for author_id and author_username
Add mutually_exclusive validation for assignee_id and assignee_username
Add validation to allow single value for asignee_username on CE
Add separate issue_stats_params helper for statistics params and
reuse in issues_params.
2019-05-15 10:15:17 +03:00
Alexandru Croitor a4fbf39eca Move issue details to from IssueBasic to Issue entity
Cleanup IssueBasic entity to keep it basic and move extra attributes
to Issue entity which contains more details
2019-05-15 10:15:17 +03:00
Alexandru Croitor 5ec28dc387 Changes to issues api
When issues_controller endpoint was used for search, the parameters
passed to the controller were slightly different then the ones
passed to API. Because the searchbar UI is reused in different
places and builds the parameters passed to request in same way
we need to account for old parameter names.


Add issues_statistics api endpoints

Adds issue_statistics api endpoints for issue lists and returns
counts of issues for all, closed and opened states.


Expose more label attributes based on a param

When requesting issues list through API expose more attributes
for labels, like color, description if with_labels_data param is
being passed, avoiding this way to change response schema for users
that already use API.

https://gitlab.com/gitlab-org/gitlab-ce/issues/57402
2019-05-15 10:15:16 +03:00
Stan Hu 58c09eb709 Use a path for the related merge requests endpoint
Hosts using a non-standard configuration may have a different
hostname/port/scheme than what may be configured on the GitLab
server. While expose_url should generate a proper URL, there are cases
where it may not work. Since we don't need the full URL, we can use the
relative path.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/61280
2019-05-07 06:16:39 -07:00
Małgorzata Ksionek 1103c09776 Add new api class for projects events
Refactor api events class to use external helper

Move specs from old class

Add changelog and magic string

Refactor events class to be more explicit

Remove blank line
2019-04-24 17:20:11 +02:00
Sean McGivern cd9ae6bb82 Revert "Remove HipChat integration from GitLab"
This reverts commit a5378665a1.
2019-04-10 12:58:18 +01:00
Imre Farkas 9bc5ed14fe Move Contribution Analytics related spec in spec/features/groups/group_page_with_external_authorization_service_spec to EE 2019-04-09 15:38:58 +00:00
Luke Duncalfe e73f537cb5 Refactor PushOptionsHandlerService from review
Exceptions are no longer raised, instead all errors encountered are
added to the errors property.

MergeRequests::BuildService is used to generate attributes of a new
merge request.

Code moved from Api::Internal to Api::Helpers::InternalHelpers.
2019-04-09 10:57:01 +12:00
Luke Duncalfe aa352a95df Support merge request create with push options
To create a new merge request:

  git push -u origin -o merge_request.create

To create a new merge request setting target branch:

  git push -u origin -o merge_request.create \
    -o merge_request.target=123

To update an existing merge request with a new target branch:

  git push -u origin -o merge_request.target=123

A new Gitlab::PushOptions class handles parsing and validating the push
options array. This can be the start of the standard of GitLab accepting
push options that follow namespacing rules. Rules are discussed in issue
https://gitlab.com/gitlab-org/gitlab-ce/issues/43263.

E.g. these push options:

  -o merge_request.create -o merge_request.target=123

Become parsed as:

  {
    merge_request: {
      create: true,
      target: '123',
    }
  }

And are fetched with the class via:

  push_options.get(:merge_request)
  push_options.get(:merge_request, :create)
  push_options.get(:merge_request, :target)

A new MergeRequests::PushOptionsHandlerService takes the `merge_request`
namespaced push options and handles creating and updating
merge requests.

Any errors encountered are passed to the existing `output` Hash in
Api::Internal's `post_receive` endpoint, and passed to gitlab-shell
where they're output to the user.

Issue https://gitlab.com/gitlab-org/gitlab-ce/issues/43263
2019-04-09 09:36:42 +12:00
Andreas Brandl 46b1b9c1d6 Revert "Merge branch 'if-57131-external_auth_to_ce' into 'master'"
This reverts merge request !26823
2019-04-05 13:02:56 +00:00
Imre Farkas d9d7237d2e Move Contribution Analytics related spec in spec/features/groups/group_page_with_external_authorization_service_spec to EE 2019-04-05 11:45:47 +00:00
James Lopez 82da4b1fd4 Merge branch 'bvl-allow-more-repos-per-resource-ce' into 'master'
Allow multiple repositories per project

See merge request gitlab-org/gitlab-ce!26539
2019-03-27 07:37:06 +00:00
Yorick Peterse be49d9c1ba
Backport parameters from API::Projects
This backports various parameter changes EE makes to API::Projects,
along with moving some code around to make it easier to extend in EE.
2019-03-26 14:18:29 +01:00
Yorick Peterse 71046be7d5
Backport API::Issues parameters from EE
This backports the parameters that EE adds to API::Issues, and wraps
them in conditionals so they are only used in EE.
2019-03-26 14:18:29 +01:00
Yorick Peterse b5623d3fd9
Backport API::Helpers::ProjectsHelpers from EE
This backports all changes made to this module in EE to CE, and wraps EE
specific code in a conditional.
2019-03-26 14:18:28 +01:00
Bob Van Landuyt d36415b754 Allow multiple repositories per project
This changes the repository type from a binary `wiki?` to a type. So
we can have more than 2 repository types.

Now everywhere we called `.wiki?` and expected a boolean, we check
that type.
2019-03-26 13:21:03 +01:00
Alexis Reigel 0592233a1a
add users search to search api 2019-03-14 18:21:01 +01:00
Robert Speicher ccbbc1000d Merge branch 'resolve-lib-differences' into 'master'
Resolve CE to EE differences in the lib/api directory

See merge request gitlab-org/gitlab-ce!25430
2019-03-12 17:03:50 +00:00
Igor 9745d0de2f Provide EE backports for filtering by approver feature
Adds custom validator for ArrayNoneAny param
Extracts some logic in js into separate files
2019-03-07 23:55:45 +00:00
Igor e779477e8c Revert "Merge branch 'id-1951-filter-merge-requests-by-approvers' into 'master'"
This reverts merge request !24982
2019-03-07 14:59:43 +00:00
Igor 572e3f2254 Provide EE backports for filtering by approver feature
Adds custom validator for ArrayNoneAny param
Extracts some logic in js into separate files
2019-03-07 07:06:54 +00:00
Andrew Newdigate 3288e1a874 Adds the Rubocop ReturnNil cop
This style change enforces `return if ...` instead of
`return nil if ...` to save maintainers a few minor review points
2019-03-06 17:51:56 +02:00
Nick Thomas 21779d0018
Add metadata about the GitLab server to GraphQL 2019-03-05 15:00:32 +00:00
Igor Drozdov 5169dafccf Forbid creating discussions for users with restricted access 2019-03-04 18:37:08 +00:00
Yorick Peterse 3156db3293
Move API::Services constants to a helper
This moves various constants previously defined in API::Services to the
API::Helpers::ServicesHelpers module, using class methods instead of
constants. This allows EE to extend the returned values, without having
to modify the CE source code directly.
2019-03-04 17:44:57 +01:00
Yorick Peterse 712148518b
Refactor API::Search for EE
This refactors API::Search so that Enterprise Edition can more easily
extend its functionality, without having to modify the file directly.
2019-03-04 17:44:57 +01:00
Yorick Peterse 6c9e26a2a0
Move eventable types constant to a helper
This moves API::ResourceLabelEventsHelpers::EVENTABLE_TYPES to a class
method in a separate helper module, allowing EE to redefine it without
having to directly modify the source code.
2019-03-04 17:44:56 +01:00
Yorick Peterse 654c4dd922
Refactor API noteable types constants
This replaces API::Notes::NOTEABLE_TYPES and
API::Discussions::NOTEABLE_TYPES with class methods defined in a
separate helper modules. This allows EE to extend the list of noteable
types, without having to modify the constant in-place. We can't define
these methods directly in the API classes, as they would be used before
we're able to extend them in EE.
2019-03-04 17:44:56 +01:00
Rémy Coutable a91bacf51c Merge branch 'am-fix-pagination-relative-links' into 'master'
Properly implement API pagination headers and add specs

Closes #57684

See merge request gitlab-org/gitlab-ce!25267
2019-02-25 11:01:39 +00:00
Stan Hu d03b7bb1e0 Properly handle multiple X-Forwarded-For addresses in runner IP
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24624 extracted
the X-Forwarded-For address directly, but this didn't consider the case
where multiple proxies are in the chain. To fix this, we use the Rails
implementation to filter trusted proxies, as documented by Grape:
https://github.com/ruby-grape/grape#remote-ip

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/58103
2019-02-24 14:50:55 -08:00
Adam Mulvany 38bbc097fa
Properly implement API pagination headers and add specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-02-21 18:29:00 +01:00
Stan Hu 2c15cf471d Include gl_project_path in API /internal/allowed response
This will enable us to track the human-readable project path with SSH
access in gitlab-shell. Currently the Gitaly logs will only show the
hashed storage and gl_repository path (e.g. project-1234).
2019-02-16 06:57:28 -08:00
Sean McGivern d91b96458e Merge branch 'api-group-labels' into 'master'
API group labels

Closes #44901

See merge request gitlab-org/gitlab-ce!21368
2019-02-07 09:48:04 +00:00
Grzegorz Bizon 084b7edb17
Do not expose trigger token when user should not see it 2019-01-31 16:51:17 +01:00
Robert Schilling ad25e14844 Simplify label helper and correct version 2019-01-31 13:49:52 +01:00
Robert Schilling 0ce33f6b4f Factor out common label API 2019-01-31 13:49:52 +01:00
Lin Jen-Shin 61c51d3b6e Merge branch '56392-enable-the-layout-extraspacing-cop' into 'master'
Enable the Layout/ExtraSpacing cop

Closes #56392

See merge request gitlab-org/gitlab-ce!24423
2019-01-24 15:09:52 +00:00
Rémy Coutable 3a2abc1d50
Enable the Layout/ExtraSpacing cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-01-24 13:05:45 +01:00
Steve Azzopardi cb67423d48
Get remote address for runner
Check if `X-Forwarded-For` is set before getting the IP of the request,
with this the real IP address of the runner is shown if it's behind a
proxy.

closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53676
2019-01-24 09:03:14 +01:00
Rémy Coutable 26978cb270
[API] Omit X-Total{,-Pages} when count > 10k
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-01-22 18:13:04 +01:00
Grzegorz Bizon 8707827d39 Improve readablity of CI_API_V4_URL related code 2019-01-04 15:32:40 +01:00
Grzegorz Bizon 476cba6ff3 Minor improvements to CI_API_V4_URL variable exposure 2019-01-03 14:18:05 +01:00
Grzegorz Bizon f10fe3ae97 Add API::Helpers::Version and expose API root URL
This commits adds a new class that is supposed to represent Grape API
version, like `v3` or `v4`.
2019-01-03 14:18:05 +01:00
Heinrich Lee Yu e0f0c29b0c Support lowercase none / any 2018-10-26 10:47:14 +08:00
Heinrich Lee Yu bf1ed85a9d Refactor api validator to separate class 2018-10-26 10:32:14 +08:00
gfyoung 3836d69119 Enable frozen string in lib/api and lib/backup
Partially addresses #47424.

Had to make changes to spec files because
stubbing methods on frozen objects is a mess
in RSpec and leads to failures:

https://github.com/rspec/rspec-mocks/issues/1190
2018-09-29 21:04:50 -07:00
Robert Speicher c7d1eef671 Merge branch 'rubocop-code-reuse' into 'master'
Add RuboCop cops to enforce code reusing rules

See merge request gitlab-org/gitlab-ce!21391
2018-09-13 14:53:05 +00:00
Steve 175f689eb7 Initialize projects with readme 2018-09-12 13:58:31 +00:00
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Sean McGivern aff7dccc1f Use policies to determine if attributes can be set in the API
This is more idiomatic than checking membership explicitly.
2018-08-22 14:17:29 +01:00
Florent Dubois b63ed7cff6 Allow date parameters on Issues and Notes API for group owners
- Allow `created_at` and `updated_at` parameters on Issues API
- Allow `created_at` on Issue Notes API

Closes gitlab-org/gitlab-ce#40059
2018-08-22 12:16:48 +01:00
Francisco Javier López 🌴 On vacation; back on August 22th! 4b36f74bfe Fix bug setting http headers in Files API 2018-08-01 16:48:33 +00:00
🙈 jacopo beschi 🙉 046796cc3a Resolve "API endpoint that returns all members, including the inherited membership through ancestor group" 2018-07-25 21:45:42 +00:00
Kia Mei Somabes 37af75a2e0 Resolve "do not set updated_at when creating note" 2018-07-12 09:26:09 +00:00
Ahmet Demir 80f4e7575e Add SHA256 and HEAD on File API 2018-06-28 06:10:51 +00:00
Tomasz Maczukin a6a900256e
Change update entrypoint instead of adding new keep-alive one 2018-06-07 18:45:48 +02:00
Stan Hu 990af4fb5d Replace grape-route-helpers with our own grape-path-helpers
This gem (https://gitlab.com/gitlab-org/grape-path-helpers) makes a number of changes:

1. Brings in @mdelaossa's changes in https://github.com/reprah/grape-route-helpers/pull/21
2. Fixes some broken specs and code for Grape 1.0+
3. Optimizes the generation of paths by bringing in @dblessing's
   HashWithIndifferentAccess changes in https://gitlab.com/gitlab-org/gitlab-ce/issues/45718#note_70123793

Closes #45718
2018-05-30 03:15:03 -07:00
Grzegorz Bizon cfdd80ec10 Merge branch 'zj-internal-repo-path' into 'master'
Don't pass the repository path to Gitlab Shell

See merge request gitlab-org/gitlab-ce!19011
2018-05-28 08:13:58 +00:00
Yorick Peterse 4d3b313a90 Merge branch 'ab-42194-keyset-pagination' into 'master'
API: Keyset pagination support

Closes #45756

See merge request gitlab-org/gitlab-ce!18584
2018-05-22 11:19:34 +00:00
Francisco Javier López 0af4c56cff Fix `expose_url` helper does not include custom base url if it is set 2018-05-22 08:54:20 +00:00
Andreas Brandl f5c4203121 Add feature-flag for keyset pagination. 2018-05-21 18:02:41 +02:00
Andreas Brandl f8aee5b086 Add keyset pagination for API calls.
Closes #45756.
2018-05-21 18:02:41 +02:00
Andreas Brandl cc1d141127 Refactor and extract DefaultPaginationStrategy. 2018-05-21 18:02:40 +02:00
Zeger-Jan van de Weg a33d591602
Don't pass the repository path to Gitlab Shell
This isn't a requirement, and removes deprecated method calls
2018-05-17 15:19:32 +02:00
Jan Provaznik 7a76caa5a8 Merge request and commit discussions API 2018-05-01 12:39:44 +00:00
Roger Rüttimann bc7877e8c1 show only groups an admin is a member of in dashboards/grops 2018-05-01 09:24:21 +00:00
Lin Jen-Shin ab286656b2 Resolve "Namespace factory is problematic" 2018-04-23 15:48:26 +00:00
Nick Thomas 672733aa66
Add an API endpoint to download git repository snapshots 2018-04-19 17:25:01 +01:00
Bob Van Landuyt 11a9fbe65b Make the API project params reusable 2018-04-04 19:49:48 +02:00
Jacob Vosmaer (GitLab) b942462788 Remove support for absolute dirs from Git::Env 2018-03-30 09:19:46 +00:00
Alejandro Rodríguez cf1a1e9ac1 Send Gitaly payload for git-upload-archive SSH commands 2018-03-21 10:57:06 -03:00
Toon Claes 3802006436 Respect the protocol in `expose_url`
When https is configured in the URL, also use that, and do not set it
to http.

Closes gitlab-org/gitlab-ee#5217
2018-03-12 15:34:11 +01:00
Douwe Maan 82ea46a707 Merge branch 'gitaly-git-mandatory' into 'master'
Make git push mandatory

See merge request gitlab-org/gitlab-ce!17565
2018-03-07 15:57:45 +00:00
Sean McGivern 1da5a103ac Merge branch 'jprovazn-api' into 'master'
Add discussion API

See merge request gitlab-org/gitlab-ce!17510
2018-03-07 13:37:50 +00:00
Jan Provaznik dcdfa04b32 Add discussion API
* adds basic discussions API for issues and snippets
* reorganizes notes specs (so same tests can be used for all noteable types - issues, MRs, snippets)
2018-03-07 12:27:50 +01:00
Kim "BKC" Carlbäcker 3c0f6da546 Make git push mandatory 2018-03-06 15:17:00 +01:00
Francisco Javier López 8fe880dc06 Projects and groups badges API 2018-03-05 17:51:40 +00:00
Dylan Griffith b5a5fdf0e3 Persist runner IP address on contact (#43489) 2018-02-28 11:54:37 +11:00
Markus Koller b7cd99c376
Allow including custom attributes in API responses 2018-02-08 13:30:34 +01:00
Sean McGivern b7a2ce52ed Merge branch '41763-search-api' into 'master'
Search API

Closes #41763

See merge request gitlab-org/gitlab-ce!16878
2018-02-07 14:33:29 +00:00
Kamil Trzciński 9bd044d9a7 Merge branch '38265-stuckcijobsworker-wrongly-detects-cancels-stuck-builds-when-per-job-timeout-is-more-than-an-hour' into 'master'
Resolve "StuckCiJobsWorker wrongly detects, cancels 'stuck' builds when per-job timeout is more than an hour"

Closes #38265, #42196, and #42750

See merge request gitlab-org/gitlab-ce!16756
2018-02-07 12:44:23 +00:00
Jarka Kadlecová 1b2400b529 Return only limited pagination headers for search API endpoints 2018-02-06 17:58:18 +01:00
Tiago Botelho 1e56b3f476 Moves project creationg to git access check for git push 2018-02-06 16:52:29 +00:00
Tiago Botelho dc229c076c Abstracts ProjectMoved and ProjectCreated into a BaseProject 2018-02-06 13:35:35 +00:00
Tiago Botelho e42a548f1d Move new project on push logic to a service 2018-02-06 13:35:35 +00:00
Tiago Botelho bc78ae6985 Add specs 2018-02-06 13:35:35 +00:00
Tiago Botelho 32b2ff2601 Adds remote messsage when project is created in a push over SSH or HTTP 2018-02-06 13:35:35 +00:00
Matija Čupić 3366f377c1
Merge branch 'master' into 38265-stuckcijobsworker-wrongly-detects-cancels-stuck-builds-when-per-job-timeout-is-more-than-an-hour 2018-02-04 23:38:59 +01:00
Matija Čupić 38c242126d
Refactor runner attribute caching implementation 2018-02-04 18:34:21 +01:00
Mario de la Ossa eaada9d706 use Gitlab::UserSettings directly as a singleton instead of including/extending it 2018-02-02 18:39:55 +00:00
Matija Čupić bdd3e39b0b
Move info update implementation to Ci::Runner model 2018-01-29 20:56:28 +01:00
Matija Čupić 397442a061
Update runner info on all authenticated requests 2018-01-29 17:21:30 +01:00
Matija Čupić b1c40590e7
Extend Runner API helpers with cache info storage 2018-01-29 00:23:36 +01:00
Jacob Vosmaer (GitLab) 583cff8d61 Default to Gitaly for 'git push' HTTP/SSH, and make Gitaly mandatory for SSH pull 2018-01-22 16:51:47 +00:00
Valery Sizov 1b1cc6fb14 [API] Fix creating issue when assignee_id is empty
see https://gitlab.com/gitlab-org/gitlab-ce/issues/42025
2018-01-15 14:24:16 +02:00
Lin Jen-Shin 59ac184fcf Merge remote-tracking branch 'upstream/master' into no-ivar-in-modules
* upstream/master: (671 commits)
  Make rubocop happy
  Use guard clause
  Improve language
  Prettify
  Use temp branch
  Pass info about who started the job and which job triggered it
  Docs: add indexes for monitoring and performance monitoring
  clearer-documentation-on-inline-diffs
  Add docs for commit diff discussion in merge requests
  sorting for tags api
  Clear BatchLoader after each spec to prevent holding onto records longer than necessary
  Include project in BatchLoader key to prevent returning blobs for the wrong project
  moved lfs_blob_ids method into ExtractsPath module
  Converted JS modules into exported modules
  spec fixes
  Bump gitlab-shell version to 5.10.3
  Clear caches before updating MR diffs
  Use new Ruby version 2.4 in GitLab QA images
  moved lfs blob fetch from extractspath file
  Update GitLab QA dependencies
  ...
2017-12-15 17:14:26 +08:00
Francisco Javier López 7c2b7296d4 Added default order to UserFinder 2017-12-04 09:49:53 +00:00
Lin Jen-Shin 85be6d83be Merge remote-tracking branch 'upstream/master' into no-ivar-in-modules
* upstream/master: (170 commits)
  support ordering of project notes in notes api
  Redirect to an already forked project if it exists
  Reschedule the migration to populate fork networks
  Create fork networks for forks for which the source was deleted.
  Fix item name and namespace text overflow in Projects dropdown
  Minor backport from EE
  fix link that was linking to `html` instead of `md`
  Backport epic tasklist
  Add timeouts for Gitaly calls
  SSHUploadPack over Gitaly is now OptOut
  fix icon colors in commit list
  Fix star icon color/stroke
  Backport border inline edit
  Add checkboxes to automatically run AutoDevops pipeline
  BE for automatic pipeline when enabling Auto DevOps
  I am certainly weary of debugging sidekiq but I don't think that's what was meant
  Ensure MRs always use branch refs for comparison
  Fix issue comment submit button disabled on GFM paste
  Lock seed-fu at the correct version in Gemfile.lock
  Improve indexes on merge_request_diffs
  ...
2017-11-30 15:20:00 +08:00
Kim "BKC" Carlbäcker a402056472 SSHUploadPack over Gitaly is now OptOut
- Better gitaly-handling in /api/internal/allowed specs
2017-11-29 08:21:41 +01:00
Lin Jen-Shin 663593e87e Merge remote-tracking branch 'upstream/master' into no-ivar-in-modules
* upstream/master: (126 commits)
  Update VERSION to 10.3.0-pre
  Update CHANGELOG.md for 10.2.0
  default fill color for SVGs
  ignore hashed repos (for now) when using `rake gitlab:cleanup:repos`
  Use Redis cache for branch existence checks
  Update CONTRIBUTING.md: Link definition of done to criteria
  Use `make install` for Gitaly setups in non-test environments
  FileUploader should check for hashed_storage?(:attachments) to use disk_path
  Set the default gitlab-shell timeout to 3 hours
  Update composite pipelines index to include "id"
  Use arrays in Pipeline#latest_builds_with_artifacts
  Fix blank states using old css
  Skip confirmation user api
  Custom issue tracker
  Revert "check for `read_only?` first before seeing if request is disallowed"
  add `#with_metadata` scope to remove a N+1 from the notes' API
  Fix promoting milestone updating all issuables without milestone
  Batchload blobs for diff generation
  check for `read_only?` first before seeing if request is disallowed
  use `Gitlab::Routing.url_helpers` instead of `Rails.application.routes.url_helpers`
  ...
2017-11-22 17:07:01 +08:00
Lin Jen-Shin 07d3d44775 Move ModuleWithInstanceVariables to Gitlab namespace
And use .rubocop.yml to exclude paths we don't care,
rather than using the cop itself to exclude.
2017-11-22 17:06:57 +08:00
Rémy Coutable 4f09d099e9 Merge branch '18040-rubocop-line-break-after-guard-clause' into 'master'
Adds Rubocop rule for line break after guard clause

Closes #18040

See merge request gitlab-org/gitlab-ce!15188
2017-11-20 09:22:14 +00:00
Lin Jen-Shin 9ac0c76b78 Use StrongMemoize and enable/disable cops properly 2017-11-18 01:01:53 +08:00
Lin Jen-Shin 0af35d7e30 Merge remote-tracking branch 'upstream/master' into no-ivar-in-modules
* upstream/master: (507 commits)
  Add dropdowns documentation
  Convert migration to populate latest merge request ID into a background migration
  Set 0.69.0 instead of latest for codeclimate image
  De-duplicate background migration matchers defined in spec/support/migrations_helpers.rb
  Update database_debugging.md
  Update database_debugging.md
  Move installation of apps higher
  Change to Google Kubernetes Cluster and add internal links
  Add Ingress description from official docs
  Add info on creating your own k8s cluster from the cluster page
  Add info about the installed apps in the Cluster docs
  Resolve "lock/confidential issuable sidebar custom svg icons iteration"
  Update HA README.md to clarify GitLab support does not troubleshoot DRBD.
  Update license_finder to 3.1.1
  Make sure NotesActions#noteable returns a Noteable in the update action
  Cache the number of user SSH keys
  Adjust openid_connect_spec to use `raise_error`
  Resolve "Clicking on GPG verification badge jumps to top of the page"
  Add changelog for container repository path update
  Update container repository path reference
  ...
2017-11-17 19:19:06 +08:00
Jacopo 181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Ahmad Sherif 52bfd06462 Use relative git object paths to construct absolute ones before setting Env 2017-11-14 20:26:39 +01:00
Lin Jen-Shin 6a4ee9aa71 Allow simple ivar ||= form. Update accordingly 2017-09-19 01:29:32 +08:00
Lin Jen-Shin 9ae92b8caa Add cop to make sure we don't use ivar in a module 2017-09-18 21:23:45 +08:00
Alejandro Rodríguez 8323e55b6c Return a value to check if redis is available on /internal/check 2017-09-05 20:12:18 -03:00
Dmitriy Zaporozhets 6f96ccaa7d Merge branch 'gitaly-shell-redis' into 'master'
Implement /internal/post_receive unified endpoint for PostReceive tasks

See merge request !13916
2017-09-01 06:49:28 +00:00
Alejandro Rodríguez eaf60bb544 Implement /internal/post_receive unified endpoint for PostReceive tasks 2017-08-31 11:31:45 -03:00
Sean McGivern 5883ce95ef `current_application_settings` belongs on `Gitlab::CurrentSettings`
The initializers including this were doing so at the top level, so every object
loaded after them had a `current_application_settings` method. However, if
someone had rack-attack enabled (which was loaded before these initializers), it
would try to load the API, and fail, because `Gitlab::CurrentSettings` didn't
have that method.

To fix this:

1. Don't include `Gitlab::CurrentSettings` at the top level. We do not need
   `Object.new.current_application_settings` to work.
2. Make `Gitlab::CurrentSettings` explicitly `extend self`, as we already use it
   like that in several places.
3. Change the initializers to use that new form.
2017-08-31 13:38:33 +01:00
Toon Claes e17d9529fa Total Pages should be at least one
And the link to the last page cannot be `page=0`.
2017-08-17 21:47:01 +02:00
Jordan Patterson fdf4f0fc08 don't add next page link if current page is out of range 2017-08-17 21:47:01 +02:00
Brian Neel 9770c57fab Re-enable SqlInjection and CommandInjection 2017-08-08 10:50:54 -04:00
Rémy Coutable 60797a42b4 Ensure Gitlab::Application.routes.default_url_options are set correctly in Capybara + :js specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-28 16:33:30 +02:00
Oswaldo Ferreira 33dc5171e5 Resolve "More RESTful API: include resource URLs in responses" 2017-07-25 09:35:45 +00:00
Kim "BKC" Carlbäcker 8b074b4e78 Send Gitaly Repository with /api/internal/allowed
- Make single gitaly payload
- Add feature-flag specs to verify payload
2017-07-07 22:24:16 +02:00
Tiago Botelho 34f57b462b Fix current feature related specs 2017-06-28 11:32:34 +01:00
Michael Kozono af784cc6e2 Add “Project moved” error to Git-over-SSH 2017-06-16 14:14:19 -07:00
Michael Kozono b50a22894d Refactor construction of response 2017-06-05 05:32:26 -07:00
Valery Sizov 22722659c2 fix for Follow-up from "Backport of Multiple Assignees feature 2017-05-11 19:11:49 +03:00
Sean McGivern 9e041f2185 Merge branch '29925-gitlab-shell-hooks-can-no-longer-send-absolute-paths-to-gitlab-ce' into 'master'
Generate and handle a gl_repository param to pass around components

Closes #29925

See merge request !10992
2017-05-05 22:08:29 +00:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Alejandro Rodríguez c45341c816 Generate and handle a gl_repository param to pass around components
This new param allows us to share project information between components
that don't share or don't have access to the same filesystem
mountpoints, for example between Gitaly and Rails or between Rails and
Gitlab-Shell hooks. The previous parameters are still supported, but if
found, gl_repository is prefered. The old parameters should be deprecated
once all components support the new format.
2017-05-03 17:37:30 -03:00
Sean McGivern 380e40fee3 Remove unused user activities code 2017-04-14 15:20:55 +02:00
James Lopez 3cb84e06b7 Remove user activities table and use redis instead of PG for recording activities
Refactored specs and added a post deployment migration to remove the activity users table.
2017-04-14 15:20:55 +02:00
Rémy Coutable 710cd82cc1 Set Git-specific env in /api/internal/allowed
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-04-10 16:10:18 +02:00
Yorick Peterse d2283f4f0e
Backport API changes needed to fix sticking in EE
These changes are ported over from
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1502 to reduce
the number of merge conflicts that may occur.
2017-03-31 13:56:53 +02:00
Tomasz Maczukin e79ab1115b
Remove legacy Runners support in /api/v4/jobs/request
In Runner v1.3.0 we've started to send User-Agent header with Runner's
version data. Since GitLab v8.12.0 we've started to use this header to check
if used Runner's version supports 204 status code instead of 404 as a
response when there is no jobs to execute by a Runner.

In APIv4 (introduced in GitLab 9.0.0) will require Runner v9.0.0. And
writing more accurately: GitLab Runner v9.0.0 will require GitLab at
least 9.0.0. Because of such breaking change we are able to switch
entirely to 204 response code and there is no need to do check of
User-Agent.

This commit removes useless code and complexity.
2017-03-20 09:40:36 +01:00
Sean McGivern a5db7f5425 Merge branch '28447-hybrid-repository-storages' into 'master'
Update storage settings to allow extra values per shard

See merge request !9597
2017-03-07 16:55:03 +00:00
Alejandro Rodríguez 0b9d56f960 Update storage settings to allow extra values per shard
This will be necessary when adding gitaly settings. This version
doesn't make any functional changes, but allows us to include this
breaking change in 9.0 and add the needed extra settings in the future
with backwards compatibility
2017-03-03 12:13:30 -03:00
Tomasz Maczukin 1bbf2c2cd1
Fix rubocop offenses 2017-03-02 17:45:46 +01:00
Tomasz Maczukin 2a7f555caf
Add artifacts uploading authorize API 2017-03-02 17:45:46 +01:00
Tomasz Maczukin 7e46db0f5a
Add job patch trace API 2017-03-02 17:45:46 +01:00
Tomasz Maczukin d5f7e54211
Add job update API 2017-03-02 17:45:46 +01:00
Tomasz Maczukin bbf5bb7070
Fix rubocop offenses 2017-03-02 17:45:45 +01:00
Tomasz Maczukin 3d26a8d0b6
Add jobs requesting API 2017-03-02 17:45:45 +01:00
Kamil Trzciński 3e8d63293e Merge branch 'feature/runners-v4-api' into 'master'
Add Runner registration/deletion API

See merge request !9246
2017-02-27 11:46:55 +00:00
Robert Schilling 01ea65e0e9 Paginate all endpoints that return an array 2017-02-16 15:32:01 +01:00
Tomasz Maczukin e25f26e550
Rename API::Ci to API::Runner 2017-02-16 01:30:46 +01:00
Tomasz Maczukin 22c983d7a0
Fix rubocop offenses 2017-02-16 01:20:17 +01:00
Tomasz Maczukin 618ce94164
Add Runner registration/deletion API 2017-02-16 01:16:41 +01:00
Adam Pahlevi a0586dbc16 replace `find_with_namespace` with `find_by_full_path`
add complete changelog for !8949
2017-02-03 07:14:04 +07:00
Grzegorz Bizon 3deaf1342e Merge branch 'master' into auto-pipelines-vue
* master: (367 commits)
  Set “Remove branch” button to default size
  remove unused helper method
  reduce common code even further to satisfy rake flay
  remove button class size alteration from revert and cherry pick links
  factor out common code to satisfy rake flay
  homogenize revert and cherry-pick button styles generated by commits_helper
  apply margin on alert banners only when there is one or more alerts
  Rename MattermostNotificationService back to MattermostService
  Rename SlackNotificationService back to SlackService
  Fix stage and pipeline specs and rubocop offenses
  Added QueryRecorder to test N+1 fix on Milestone#show
  Use gitlab-workhorse 1.2.1
  Make 'unmarked as WIP' message more consistent
  Improve specs for Files API
  Allow unauthenticated access to Repositories Files API GET endpoints
  Add isolated view spec for pipeline stage partial
  Move test for HTML stage endpoint to controller specs
  Fix sizing of avatar circles; add border
  Fix broken test
  Fix broken test Changes after review
  ...

Conflicts:
	app/assets/stylesheets/pages/pipelines.scss
	app/controllers/projects/pipelines_controller.rb
	app/views/projects/pipelines/index.html.haml
	spec/features/projects/pipelines/pipelines_spec.rb
2016-12-21 12:09:06 +01:00
Timothy Andrew f82d549d26 Accept environment variables from the `pre-receive` script.
1. Starting version 2.11, git changed the way the pre-receive flow works.

  - Previously, the new potential objects would be added to the main repo. If the
    pre-receive passes, the new objects stay in the repo but are linked up. If
    the pre-receive fails, the new objects stay orphaned in the repo, and are
    cleaned up during the next `git gc`.

  - In 2.11, the new potential objects are added to a temporary "alternate object
    directory", that git creates for this purpose. If the pre-receive passes, the
    objects from the alternate object directory are migrated to the main repo. If
    the pre-receive fails the alternate object directory is simply deleted.

2. In our workflow, the pre-recieve script (in `gitlab-shell) calls the
   `/allowed` endpoint, which calls out directly to git to perform
   various checks. These direct calls to git do _not_ have the necessary
   environment variables set which allow access to the "alternate object
   directory" (explained above). Therefore these calls to git are not able to
   access any of the new potential objects to be added during this push.

3. We fix this by accepting the relevant environment variables
   (GIT_ALTERNATE_OBJECT_DIRECTORIES, GIT_OBJECT_DIRECTORY) on the
   `/allowed` endpoint, and then include these environment variables while
   calling out to git.

4. This commit includes (whitelisted) these environment variables while making
   the "force push" check. A `Gitlab::Git::RevList` module is extracted to
   prevent `ForcePush` from being littered with these checks.
2016-12-16 23:32:25 +05:30
Regis 211ee4b97c Merge branch 'master' into auto-pipelines-vue 2016-12-16 09:50:23 -07:00
Nick Thomas 93a03cd92f Add an environment slug 2016-12-15 13:57:03 +00:00
Grzegorz Bizon 7870614fb9 Extract API pagination code to a separete module 2016-12-07 15:23:07 +01:00
Rémy Coutable 81ba3f9177
API: Introduce `#find_group!` which also check access permission
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-24 16:58:32 +01:00
Nick Thomas 1c994dbc05 Fix POST /internal/allowed to cope with gitlab-shell v4.0.0 project paths
gitlab-shell v3.6.6 would give project paths like so:

* namespace/project

gitlab-shell v4.0.0 can give project paths like so:

* /namespace1/namespace2/project
* /namespace/project
* /path/to/repository/storage/namespace1/namespace2/project
* /path/to/repository/storage/namespace/project
2016-11-16 14:30:56 +00:00
Rémy Coutable 29850364ec New AccessRequests API endpoints for Group & Project
Also, mutualize AccessRequests and Members endpoints for Group &
Project.
New API documentation for the AccessRequests endpoints.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-08-10 19:07:05 +02:00