Commit Graph

1556 Commits

Author SHA1 Message Date
Jarka Kadlecova 4464c22d6d Support descriptions for snippets 2017-05-31 07:17:03 +02:00
Douwe Maan 26bcef97d6 Merge branch 'rework-authorizations-performance' into 'master'
Rework project authorizations and nested groups for better performance

See merge request !10885
2017-05-29 15:49:56 +00:00
Grzegorz Bizon 2a1130343a Improve pipelines API specs related to special parameters 2017-05-29 10:25:48 +02:00
Stan Hu 393f24ad8c Simplify pipeline spec by using order instead of sort_by 2017-05-28 23:41:29 -07:00
Stan Hu af04113135 Fix failing spec in spec/requests/api/pipelines_spec.rb
The spec was trying to sort pipelines by user ID, but the same user ID
was being used for each pipeline in the spec.

Closes #33001
2017-05-28 23:25:52 -07:00
Douwe Maan 43b1750892 Revert "Remove changes that are not absolutely necessary"
This reverts commit b0498c176f
2017-05-24 20:59:26 +00:00
Alejandro Rodríguez de33a5bd53 Prevent errors from non-functional notify_post_receive endpoint 2017-05-18 15:33:43 -04:00
Yorick Peterse ac382b5682
Use CTEs for nested groups and authorizations
This commit introduces the usage of Common Table Expressions (CTEs) to
efficiently retrieve nested group hierarchies, without having to rely on
the "routes" table (which is an _incredibly_ inefficient way of getting
the data). This requires a patch to ActiveRecord (found in the added
initializer) to work properly as ActiveRecord doesn't support WITH
statements properly out of the box.

Unfortunately MySQL provides no efficient way of getting nested groups.
For example, the old routes setup could easily take 5-10 seconds
depending on the amount of "routes" in a database. Providing vastly
different logic for both MySQL and PostgreSQL will negatively impact the
development process. Because of this the various nested groups related
methods return empty relations when used in combination with MySQL.

For project authorizations the logic is split up into two classes:

* Gitlab::ProjectAuthorizations::WithNestedGroups
* Gitlab::ProjectAuthorizations::WithoutNestedGroups

Both classes get the fresh project authorizations (= as they should be
in the "project_authorizations" table), including nested groups if
PostgreSQL is used. The logic of these two classes is quite different
apart from their public interface. This complicates development a bit,
but unfortunately there is no way around this.

This commit also introduces Gitlab::GroupHierarchy. This class can be
used to get the ancestors and descendants of a base relation, or both by
using a UNION. This in turn is used by methods such as:

* Namespace#ancestors
* Namespace#descendants
* User#all_expanded_groups

Again this class relies on CTEs and thus only works on PostgreSQL. The
Namespace methods will return an empty relation when MySQL is used,
while User#all_expanded_groups will return only the groups a user is a
direct member of.

Performance wise the impact is quite large. For example, on GitLab.com
Namespace#descendants used to take around 580 ms to retrieve data for a
particular user. Using CTEs we are able to reduce this down to roughly 1
millisecond, returning the exact same data.

== On The Fly Refreshing

Refreshing of authorizations on the fly (= when
users.authorized_projects_populated was not set) is removed with this
commit. This simplifies the code, and ensures any queries used for
authorizations are not mutated because they are executed in a Rails
scope (e.g. Project.visible_to_user).

This commit includes a migration to schedule refreshing authorizations
for all users, ensuring all of them have their authorizations in place.
Said migration schedules users in batches of 5000, with 5 minutes
between every batch to smear the load around a bit.

== Spec Changes

This commit also introduces some changes to various specs. For example,
some specs for ProjectTeam assumed that creating a personal project
would _not_ lead to the owner having access, which is incorrect. Because
we also no longer refresh authorizations on the fly for new users some
code had to be added to the "empty_project" factory. This chunk of code
ensures that the owner's permissions are refreshed after creating the
project, something that is normally done in Projects::CreateService.
2017-05-17 16:51:08 +02:00
Douwe Maan 1fd83f972c Merge branch 'bvl-rename-build-events-to-job-events' into 'master'
Rename `build_events` to `job_events`

Closes #31620

See merge request !11287
2017-05-16 14:12:19 +02:00
Douwe Maan 950fa32a7c Revert "Merge branch 'bvl-rename-build-events-to-job-events' into 'master'"
This reverts merge request !11287
2017-05-15 20:24:19 +00:00
Bob Van Landuyt cac7e03fa1 Rename `build_events` to `job_events` in code 2017-05-15 14:27:01 +02:00
Gabriel Mazetto cfb4404ef6 Update SystemHooks API to expose and handle new repository_update_events 2017-05-12 23:26:48 +01:00
Valery Sizov 22722659c2 fix for Follow-up from "Backport of Multiple Assignees feature 2017-05-11 19:11:49 +03:00
Regis Boudinot 81df0034f4 Merge branch 'retried-in-database-mysql' into 'master'
Retried in database

Closes #25737

See merge request !11115
2017-05-10 22:07:05 +00:00
Rémy Coutable d40e1f547e Enable the Style/TrailingCommaInLiteral cop
Use the EnforcedStyleForMultiline: no_comma option.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-05-10 18:25:45 +02:00
blackst0ne 29a3203b3f Use relative paths for group/project/user avatars 2017-05-10 15:26:17 +11:00
Sam Rose 1ebd9dad8e Add confirm delete protected branch modal 2017-05-08 07:41:58 +00:00
Kamil Trzcinski f2a4420d66
Store retried in database for CI builds 2017-05-07 22:43:53 +02:00
Kamil Trzciński 6ad3814e1b Merge branch 'feature/gb/manual-actions-protected-branches-permissions' into 'master'
Check access to a branch when user triggers manual action

Closes #20261

See merge request !10494
2017-05-06 17:17:02 +00: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 0cfe35f727 Multiple issue assignee: CE restriction for multiple assignees 2017-05-05 18:55:16 +03:00
Valery Sizov 34be1835af [Multiple issue assignee] Fix a number of specs 2017-05-05 15:30:19 +03:00
Grzegorz Bizon b6facd8313 Merge commit '3a2b60f7' from 'master'
* commit '3a2b60f7a0109cdb84e8727a2625318a746e84dc': (151 commits)
  Fixed Karma spec
  Reject EE reserved namespace paths in CE as well
  Updated webpack config
  Include the bundler:audit job into the static-analysis job
  Document serializers
  Add artifact file page that uses the blob viewer
  Pipeline table mini graph dropdown remains open when table is refreshed
  Adds off for event hub
  Compile gitlab-shell go executables
  Allow to create new branch and empty WIP merge request from issue page
  Moved to a view spec
  Improving copy of CONTRIBUTING.md, PROCESS.md, and code_review.md
  Convert seconds to minutes and hours on chat notifations
  Disable navigation to Pages config if Pages is disabled
  Sort the network graph both by commit date and topographically.
  Add tooltips to note action buttons
  Add breadcrumb, build header and pipelines submenu to artifacts browser
  Update todos screenshots
  removes the possibility of commit messages having carriage returns
  Handle incoming emails from aliases correctly
  ...
2017-05-05 12:22:46 +02:00
Valery Sizov b0a9a7cf5e [Multiple issue assignee]: reslving some conflicts 2017-05-04 17:22:24 +03:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Rémy Coutable 12c34c1cbb Merge branch '31544-size-of-project-from-api' into 'master'
Resolve "Size of project from API"

Closes #31544

See merge request !11013
2017-05-04 07:16:08 +00: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
Robert Speicher 501cb18be3 Merge branch '28408-feature-proposal-include-search-options-to-pipelines-api' into 'master'
Resolve "Feature Proposal: Include search options to pipelines API"

Closes #28408

See merge request !9367
2017-05-03 16:14:42 +00:00
Mark Fletcher 21f5515a5f Expose project statistics on single requests via the API
+ The statistics parameter was already accepted
* This commit ensure that it is respected for GET /projects/:id endpoint
+ Add documentation of the parameter and update the example response for stats
2017-05-03 18:45:19 +08:00
Grzegorz Bizon 738bf2c238 Merge branch 'master' into feature/gb/manual-actions-protected-branches-permissions
* master: (103 commits)
  Include missing project attributes to Import/Export
  Create the rest of the wiki docs
  Fill in information about creating the wiki Home page
  Move wiki doc to its own index page
  Create initial file for Wiki documentation
  Default to null user when asignee is unselected
  Re-enable ref operations with gitaly after not-found fix
  #31560 Add repo parameter to gitaly:install and workhorse:install
  Remove N+1 queries when checking nodes visible to user
  Don't validate reserved words if the format doesn't match
  Revert "Shorten and improve some job names"
  Remove unused initializer
  DRY the `<<: *except-docs` a bit in `.gitlab-ci.yml`
  Make the static-analysis job be run for docs branches too
  Add download_snippet_path helper
  Refresh the markdown cache if it was `nil`
  Add some documentation for the new migration helpers
  Update comments
  Display comments for personal snippets
  Update docs on creating a project
  ...
2017-05-03 12:27:30 +02:00
Douwe Maan 2a73f0a638 Merge branch 'rs-described_class-cop-2' into 'master'
Enable `RSpec/DescribedClass` cop and correct violations

See merge request !10930
2017-05-02 22:30:30 +00:00
Shinya Maeda 0aebc829ad Correct typo in pipelines_spec.rb 2017-05-03 02:11:51 +09:00
Shinya Maeda 0a36bfa994 Use HasStatus::AVAILABLE_STATUSES instead of hard coding 2017-05-03 02:11:51 +09:00
Shinya Maeda fda48d3091 Improve api/pipelines_spec.rb 2017-05-03 02:11:51 +09:00
Shinya Maeda 673693888a Remove unnecessary hash 2017-05-03 02:11:51 +09:00
Shinya Maeda 33c284fa8c Separate parameters from literal url string 2017-05-03 02:11:51 +09:00
Shinya Maeda 98ac988d4d Use order instead of reorder. Improve tests. 2017-05-03 02:11:51 +09:00
Shinya Maeda 8f32724fcb Ci::Pipeline to project.pipelines 2017-05-03 02:11:51 +09:00
Shinya Maeda f0e3076a32 'to be > 0' to 'not_to be_empty'. 'to eq(0)' to 'to be_empty' 2017-05-03 02:11:51 +09:00
Shinya Maeda 2e43e50e74 Finish pipelines_spec 2017-05-03 02:11:51 +09:00
Shinya Maeda 2075d7ce52 Unveil iteration 2017-05-03 02:11:51 +09:00
Shinya Maeda 959b4e99c0 Add spec for Pipeline API (Halfway) 2017-05-03 02:11:51 +09:00
Sean McGivern 3efe534255 Merge branch '26488-target-disabled-mr' into 'master'
Fix 404 when upstream disabled merge requests

Closes #26488

See merge request !10427
2017-05-02 11:14:41 +00:00
Grzegorz Bizon d276ea9372 Merge branch 'master' into feature/gb/manual-actions-protected-branches-permissions
* master: (314 commits)
  Better Explore Groups view
  Update Carrierwave and fog-core
  Add specs for Gitlab::RequestProfiler
  Add scripts/static-analysis to run all the static analysers in one go
  Shorten and improve some job names
  Group static-analysis jobs into a single job
  Don't blow up when email has no References header
  Update CHANGELOG.md for 9.1.2
  Add changelog
  Add changelog
  Show Raw button as Download for binary files
  Use blob viewers for snippets
  Fix typo
  Fixed transient failure related to dropdown animations
  Revert "Merge branch 'tc-no-todo-service-select' into 'master'"
  fix link to MR 10416
  Another change from .click -> .trigger('click') to make spec pass
  Change from .click -> .trigger('click') to make spec pass
  Disable AddColumnWithDefaultToLargeTable cop for pre-existing migrations
  Add AddColumnWithDefaultToLargeTable cop
  ...

Conflicts:
	spec/requests/api/jobs_spec.rb
2017-05-02 10:40:10 +02:00
Grzegorz Bizon 02fc184683 Improve specs for jobs API regarding manual actions 2017-05-02 10:29:09 +02:00
Robert Speicher d49768296c Auto-correct `RSpec/DescribedClass` violations 2017-05-01 11:13:33 -04:00
Robert Speicher 2952a44779 Merge branch 'enable-spec-file-name-cop' into 'master'
Enable RSpec/FilePath cop

Closes #31316

See merge request !10911
2017-04-28 18:02:17 +00:00
Dmitriy Zaporozhets 22ed9c0293 Make api/v3/deployments_spec to actually tests v3
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-04-27 20:09:04 +03:00
Rémy Coutable 86038fa5d5 Merge branch '29505-allow-admins-sudo-to-blocked-users' into 'master'
Allow admins to sudo to blocked users

See merge request !10842
2017-04-27 12:32:47 +00:00
mhasbini ccac05dd90 Fix 404 when upstream has disabled merge requests 2017-04-27 01:04:07 +03:00