Commit Graph

2262 Commits

Author SHA1 Message Date
Zeger-Jan van de Weg 1ffd0c8562
Remove CI API v1
This API was mainly for internal usage, and has been moved to the
general API: APIv4. The endpoints have been deprecated since 9.0, and
won't see 10.0. :)
2017-08-18 11:47:03 +02:00
Rémy Coutable 9ac2a51779 Merge branch '34049-public-commits-should-not-require-authentication' into 'master'
Commits API: Listing commits for public repo doesn't require authentication

Closes #34049

See merge request !13287
2017-08-16 10:39:10 +00:00
Robert Speicher 4edfad9678 Enable Layout/TrailingWhitespace cop and auto-correct offenses 2017-08-15 13:44:37 -04:00
Felipe Artur b7e9862004 Fix API responses when dealing with txt files 2017-08-15 11:32:48 -03:00
Douwe Maan e645ab2233 Merge branch 'forks-count-cache' into 'master'
Cache the number of forks of a project

See merge request !13535
2017-08-15 08:13:01 +00:00
Yorick Peterse aef9f1eb94
Cache the number of forks of a project
The number of forks of a project doesn't change very frequently and
running a COUNT(*) every time this information is requested can be quite
expensive. We also end up running such a COUNT(*) query at least twice
on the homepage of a project.

By caching this data and refreshing it when necessary we can reduce
project homepage loading times by around 60 milliseconds (based on the
timings of https://gitlab.com/gitlab-org/gitlab-ce).
2017-08-14 18:00:28 +02:00
Lin Jen-Shin d7e95d77d8 Use with_repo_branch_commit instead of fetch_ref directly
So that we could limit the access to Repository#fetch_ref
See: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13416#note_37487433
2017-08-14 22:55:34 +08:00
Lin Jen-Shin d1b4770d6c Add comments about why we're stubbing them 2017-08-14 20:06:55 +08:00
Lin Jen-Shin 349db4802b Merge remote-tracking branch 'upstream/master' into 36089-handle-ref-failure-better
* upstream/master: (47 commits)
  Update CHANGELOG.md for 9.4.5
  Update charlock_holmes
  add a changelog entry
  switch to multi-line before block
  restructure the #new_key notification spec
  don't send devise notifications to the ghost user
  reset_delivered_emails before testing #new_key
  skip the :read_project check for new_project_member
  move the member spec to be with the other ones
  add a spec for new_group_member
  add a spec for never emailing the ghost user
  rubocop fix
  a membership with no user is always notifiable
  check notifiability for more emails
  add Member#notifiable?(type, opts)
  make NotificationRecipient a little more customizable
  Add notes about database performance for MySQL
  fix confidential border issue as well as confidential styles leaking on new MR
  Migrate force push check to Gitaly
  Add option to disable project export on instance
  ...
2017-08-14 19:33:35 +08:00
Rémy Coutable 455dc74e65 Merge branch 'disable-project-export' into 'master'
Add option to disable project export on instance

See merge request !13211
2017-08-11 17:33:45 +00:00
Robert Speicher 5896d1b1e6 Merge branch '32004-use-timecop-safe-mode' into 'master'
Enable Timecop safe mode

Closes #32004

See merge request !13498
2017-08-11 16:59:37 +00:00
Robin Bobbitt 649d042dbc Add option to disable project export on instance 2017-08-11 12:22:37 -04:00
Sean McGivern 0887a2bd10 Merge branch '36213-return-is_admin-in-users-api-when-current_user-is-admin' into 'master'
Include the `is_admin` field in the `GET /users/:id` API when current user is an admin

Closes #36213

See merge request !13501
2017-08-11 15:46:17 +00:00
Sean McGivern e80a893ff0 Merge branch 'split-events-into-push-events' into 'master'
Use a separate table for storing push events

See merge request !12463
2017-08-11 14:40:03 +00:00
Rémy Coutable 09a348eb13
Include the `is_admin` field in the `GET /users/:id` API when current user is an admin
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-11 15:14:32 +02:00
Rémy Coutable 1b413bd62f Enable Timecop safe mode
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-11 14:53:17 +02:00
Lin Jen-Shin 3b0dcbf235 Merge remote-tracking branch 'upstream/master' into 36089-handle-ref-failure-better
* upstream/master:
  Fix merge request diff deserialisation when too_large was absent
  Bumps omniauth-ldap gem version to 2.0.4
  Remove an unnecessary `let` in spec/features/projects/user_edits_files_spec.rb
  Remove documentation about rules that are now enforced by RuboCop
  Enable the RSpec/HookArgument cop and auto-correct offenses
2017-08-11 20:30:14 +08:00
Lin Jen-Shin e04c1ae7c7 Merge remote-tracking branch 'upstream/master' into 36089-handle-ref-failure-better
* upstream/master: (62 commits)
  Update gitlab.po: Missing 'r' in "Fouché" that comes from "Fourcher" verb.
  Docs: update user docs index
  Fix minor typos in views
  Fix Layout/SpaceBeforeBlockBraces violation in bin/changelog_spec
  Merge branch 'rs-alphanumeric-ssh-params' into 'security-9-4'
  Merge branch 'import-symlinks-9-3' into 'security-9-3'
  Fix wrong method call on prometheus histogram
  Document new all-in-one Helm chart - docs
  Fix 404 on link path
  Fix line numbers not matching up to code in code viewer.
  Hide overflow-x on collapsed sidebar
  removed global use of breakpoint checker
  Increase performance of the breakpoint size checker
  Filter sensitive query string parameters from NGINX access logs
  Added a template for database changes
  Render new issue link in failed job as a regular link instead of a UJS one
  Include RE2 in the upgrade docs
  Remove affix plugin from issuable sidebar with new navigation
  Fix linter error
  alternative route for download archive
  ...
2017-08-11 19:15:35 +08:00
Lin Jen-Shin ae7c52a060 Fix more tests 2017-08-11 17:54:34 +08:00
Robert Speicher c8b802471b Enable the RSpec/HookArgument cop and auto-correct offenses 2017-08-10 19:29:42 -04:00
Yorick Peterse 0395c47193
Migrate events into a new format
This commit migrates events data in such a way that push events are
stored much more efficiently. This is done by creating a shadow table
called "events_for_migration", and a table called "push_event_payloads"
which is used for storing push data of push events. The background
migration in this commit will copy events from the "events" table into
the "events_for_migration" table, push events in will also have a row
created in "push_event_payloads".

This approach allows us to reclaim space in the next release by simply
swapping the "events" and "events_for_migration" tables, then dropping
the old events (now "events_for_migration") table.

The new table structure is also optimised for storage space, and does
not include the unused "title" column nor the "data" column (since this
data is moved to "push_event_payloads").

== Newly Created Events

Newly created events are inserted into both "events" and
"events_for_migration", both using the exact same primary key value. The
table "push_event_payloads" in turn has a foreign key to the _shadow_
table. This removes the need for recreating and validating the foreign
key after swapping the tables. Since the shadow table also has a foreign
key to "projects.id" we also don't have to worry about orphaned rows.

This approach however does require some additional storage as we're
duplicating a portion of the events data for at least 1 release. The
exact amount is hard to estimate, but for GitLab.com this is expected to
be between 10 and 20 GB at most. The background migration in this commit
deliberately does _not_ update the "events" table as doing so would put
a lot of pressure on PostgreSQL's auto vacuuming system.

== Supporting Both Old And New Events

Application code has also been adjusted to support push events using
both the old and new data formats. This is done by creating a PushEvent
class which extends the regular Event class. Using Rails' Single Table
Inheritance system we can ensure the right class is used for the right
data, which in this case is based on the value of `events.action`. To
support displaying old and new data at the same time the PushEvent class
re-defines a few methods of the Event class, falling back to their
original implementations for push events in the old format.

Once all existing events have been migrated the various push event
related methods can be removed from the Event model, and the calls to
`super` can be removed from the methods in the PushEvent model.

The UI and event atom feed have also been slightly changed to better
handle this new setup, fortunately only a few changes were necessary to
make this work.

== API Changes

The API only displays push data of events in the new format. Supporting
both formats in the API is a bit more difficult compared to the UI.
Since the old push data was not really well documented (apart from one
example that used an incorrect "action" nmae) I decided that supporting
both was not worth the effort, especially since events will be migrated
in a few days _and_ new events are created in the correct format.
2017-08-10 17:45:44 +02:00
Lin Jen-Shin c772464b68 Introduce MergeRequest#write_ref and Repository#write_ref
so that we don't have to fetch it for non-forks
2017-08-10 22:20:53 +08:00
Jacopo b982f6f94b Added tests for commits API with an unauthenticated user and a public/private project
Added test to API commits in order to handle cases for authenticated/unauthenticated user in a
private and public project.
2017-08-10 12:11:27 +02:00
Rémy Coutable 449a0587f6 Improve the Project factory to make `creator` defaults to namespace.owner
Also improves the `create_templates` transient attribute and use
`project.project_feature.update_columns` instead of
`project.project_feature.update_attributes!` since it's faster.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-10 09:28:58 +02:00
Lin Jen-Shin 412db1874f Fix some tests and report the error message 2017-08-09 21:41:45 +08:00
Rémy Coutable c946ee1282
Enable the Layout/SpaceBeforeBlockBraces cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-09 11:52:22 +02:00
Rémy Coutable 164e660411
Fix a broken Events API spec
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-08 16:27:38 +02:00
Sean McGivern 5b08d59f07 Merge branch 'rc/fix-commits-api' into 'master'
Fix the /projects/:id/repository/commits endpoint to handle dots in the ref name…

Closes #15651

See merge request !13370
2017-08-08 12:54:55 +00:00
sue445 7bc0486162 Expose noteable_iid in Note 2017-08-08 11:31:55 +00:00
Rémy Coutable 023a3f7a3b
Fix the /projects/:id/repository/commits endpoint to handle dots in the ref name when the project full path contains a `/`
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-08 12:54:07 +02:00
Rémy Coutable 10fe62ec80
Fix the /projects/:id/repository/tags endpoint to handle dots in the tag name when the project full path contains a `/`
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-08-08 11:50:58 +02:00
Sean McGivern 5bf65c9306 Merge branch 'bvl-nfs-circuitbreaker' into 'master'
Circuitbreaker for storage paths

Closes #32207, #33117, gitlab-com/infrastructure#1946, and gitlab-com/infrastructure#1775

See merge request !11449
2017-08-07 14:56:15 +00:00
Rémy Coutable 81933cfdd3 Merge branch '32300__expose_more_attributes' into 'master'
Expose more attributes to unauthenticated GET /projects/:id

See merge request !13283
2017-08-07 09:52:37 +00:00
Douwe Maan 727b6d16e5 Merge branch 'master' into 'bvl-nfs-circuitbreaker'
# Conflicts:
#   app/models/repository.rb
#   spec/models/repository_spec.rb
2017-08-07 09:13:10 +00:00
Rémy Coutable 9dab157502 Merge branch 'tc-fix-mr-query-params' into 'master'
Add spec to test combining API merge_requests query parameters

See merge request !11172
2017-08-04 16:23:14 +00:00
Bob Van Landuyt 3598e60bf2 Add a Circuitbreaker for storage paths 2017-08-04 15:38:48 +02:00
Toon Claes e15d339a5c Add spec to test combining API merge_requests query parameters
To investigate gitlab-org/gitlab-ce#31599
2017-08-03 16:44:22 +02:00
Lin Jen-Shin bb5f79d43e Don't include EmailHelpers manually, pick with rspec
`:mailer` is needed to pick it easily, while
`type: :mailer` is needed for picking it automatically for
tests located in spec/mailers/*_spec.rb

It's a bit complicated in spec/services/notification_service_spec.rb
but we'll leave it alone for now.
2017-08-03 21:55:48 +08:00
Tony 3c8b2ae168 Expose more attributes to unauthenticated GET /projects/:id 2017-08-03 16:42:11 +03:00
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Eric fb5b2d8d0e Extending API for protected branches 2017-08-02 10:16:17 +00:00
Robert Speicher 9513bd18c4 Ensure all project factories use `:repository` trait or `:empty_project` 2017-08-01 14:51:52 -04:00
Douwe Maan 4c77c30fbf Merge branch '33620-remove-events-from-notification_settings' into 'master'
Resolve "Remove `events` from `notification_settings`"

Closes #33620

See merge request !13152
2017-08-01 14:54:56 +00:00
Sean McGivern 90cb2aab38 Merge branch '28283-legacy-storage-format' into 'master'
[CE] Added Legacy Storage format

See merge request !13149
2017-08-01 12:24:24 +00:00
Kamil Trzciński 8ffd40cee7 Merge branch '34519-extend-api-group-secret-variable' into 'master'
Extend API: Group Secret Variable

Closes #34519

See merge request !12936
2017-08-01 09:29:50 +00:00
Lin Jen-Shin (godfat) 0d35b08180 Allow logged in users to read user list under public restriction 2017-08-01 07:46:13 +00:00
Gabriel Mazetto fb06a4d8fe Rename more path_with_namespace -> full_path or disk_path 2017-08-01 07:28:13 +02:00
Gabriel Mazetto abb878326c Rename many path_with_namespace -> full_path 2017-08-01 07:26:58 +02:00
Sean McGivern 57a5544f88 Remove events column from notification settings
This was migrated to separate columns in 9.4, and now just needs to be removed
for real.
2017-07-31 11:18:55 +01:00
Richard Clamp e77e9b0077 Fixup POST /v3/:id/hooks and PUT /v3/:id/hooks/:hook_id 2017-07-28 16:27:10 +00:00