Commit Graph

208 Commits

Author SHA1 Message Date
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
Robert Speicher 87bd9c56cc Merge branch '36378-error-raising-expectation-in-spec-fix' into 'master'
Fix positive raise_error expectation without specifying the error type expected…

Closes #36378

See merge request !13542
2017-08-14 20:39:31 +00:00
Tiago Botelho 9371cf3acf Fix positive raise_error expectation without specifying the error type expected in Project::DestroyService specs 2017-08-14 19:37:22 +01: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
Robert Speicher c8b802471b Enable the RSpec/HookArgument cop and auto-correct offenses 2017-08-10 19:29:42 -04:00
blackst0ne 98535fc12c Add checks for branch existence before changing HEAD 2017-08-08 12:10:55 +11:00
Robert Speicher dd3d422193 Merge branch 'github' into 'master'
Improve GitHub importer

Closes #27429

See merge request !12886
2017-08-07 19:27:42 +00:00
Sean McGivern 4c8b666893 Merge branch 'zj-project-templates' into 'master'
Allow projects to be started from a template

Closes #32420

See merge request !13108
2017-08-07 19:24:14 +00:00
Douglas Barbosa Alexandre 517a9f97c7 Does not fetch repository when importing from GitHub on import service 2017-08-07 13:06:13 -03:00
Z.J. van de Weg 2e6aa4f25e
After merge cleanup 2017-08-07 15:09:14 +02:00
Sean McGivern 76b80d6e96 Show group milestones in autocomplete 2017-08-07 11:55:01 +01:00
Filipa Lacerda 3b9012871d Merge branch 'master' into zj-project-templates
* master: (623 commits)
  Fix issues with pdf-js dependencies
  fix missing changelog entries for security release on 2017-01-23
  Update top bar issues icon
  Fix pipeline icon in contextual nav for projects
  Since mysql is not a priority anymore, test it less
  Fix order of CI lint ace editor loading
  Add container registry and spam logs icons
  Fix different Markdown styles
  Backport to CE for:
  Make new dropdown dividers full width
  Fix spec
  Fix spec
  Fix spec
  Bump GITLAB_SHELL_VERSION and GITALY_VERSION to support unhiding refs
  Add changelog
  Install yarn via apt in update guides
  Use long curl options
  fix
  Add a spec for concurrent process
  Remove monkey-patched Array.prototype.first() and last() methods
  ...
2017-08-07 11:09:50 +01:00
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Z.J. van de Weg 3baf3dc955
Rename GitLabProjectImporterService and misc fixes
First round of review, main changes:
- templates.title is human readable, #name will be passed around
- GitLabProjectImporterService has been renamed
2017-08-01 14:36:42 +02:00
Gabriel Mazetto c6dee99803 Rename path_with_namespace -> disk_path when dealing with the filesystem 2017-08-01 07:26:58 +02:00
Gabriel Mazetto abb878326c Rename many path_with_namespace -> full_path 2017-08-01 07:26:58 +02:00
Lin Jen-Shin b720c22fb4 Avoid expect_any_instance_of because it doesn't work
well with prepend. We need to backport this
2017-07-31 20:33:21 +08:00
Z.J. van de Weg 1d3815f89b
Allow projects to be started from a template
Started implementation for the first iteration of
gitlab-org/gitlab-ce#32420. This will allow users to select a template
to start with, instead of an empty repository in the project just
created.

Internally this is basically a small extension of the ImportExport
GitLab projects we already support. We just import a certain import
tar archive. This commits includes the first one: Ruby on Rails. In the
future more will be added.
2017-07-28 11:32:46 +02:00
Rémy Coutable cddc5cacfb Use described_class when possible
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Rémy Coutable ddccd24c13 Remove superfluous lib: true, type: redis, service: true, models: true, services: true, no_db: true, api: true
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 14:31:53 +02:00
Kamil Trzciński 0c563225b6 Merge branch 'fix/gb/handle-max-pages-artifacts-size-correctly' into 'master'
Handle maximum pages artifacts size correctly

Closes #35317

See merge request !13072
2017-07-26 14:00:42 +00:00
Sean McGivern 5de3ec64da Merge branch '29289-project-destroy-clean-up-after-failure' into 'master'
Handle errors while a project is being deleted asynchronously.

Closes #29289

See merge request !11088
2017-07-26 12:49:54 +00:00
Tiago Botelho b5bdc55d23 Move exception handling to execute 2017-07-26 12:47:50 +01:00
Grzegorz Bizon 7151fb754b Fix rubocop offense in update pages service specs 2017-07-25 13:47:03 +02:00
Grzegorz Bizon 77a6ec22ba Handle maximum pages artifacts size correctly 2017-07-25 12:45:45 +02:00
Grzegorz Bizon 4ad8f12e44 Fix editing project with container images present 2017-07-24 10:47:33 +00:00
Timothy Andrew 72a85ae9ac Handle errors while a project is being deleted asynchronously.
1. Rescue all errors that `Projects::DestroyService` might throw, to prevent the
   worker from leaving things in an inconsistent state

2. Unmark the project as `pending_delete`

3. Add a `delete_error` text column to `projects`, and save the error message in
   there, to be shown to the project masters/owners.
2017-07-20 09:56:52 +01:00
Bob Van Landuyt 458f3cf9b0 Update specs for new upload path 2017-07-18 15:38:54 +02:00
Grzegorz Bizon 418af1010a Adds specs for renaming a project with container images 2017-07-14 11:27:50 +02:00
Grzegorz Bizon 14fbff00b5 Add specs for changing default branch in a project 2017-07-14 11:21:52 +02:00
Grzegorz Bizon 613208c360 Recover from renaming project that has container images 2017-07-13 15:34:36 +02:00
Paul Charlton cb3b4a15e6 Support multiple Redis instances based on queue type 2017-07-11 03:35:47 +00:00
Douglas Barbosa Alexandre b3b034b849 Expires full_path cache after repository is transferred 2017-06-29 19:13:37 -03:00
Gabriel Mazetto b6118afd88 Fixed DestroyService spec to actually test if removal was successful 2017-06-24 03:46:50 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Douwe Maan 780adff549 Merge branch '30213-project-transfer-move-rollback' into 'master'
Rollback project folder move after error in Projects::TransferService

Closes #30213

See merge request !11877
2017-06-20 18:20:00 +00:00
James Edwards-Jones 6db1a28016 Rollback project folder move after error in Projects::TransferService 2017-06-20 17:35:33 +01:00
Robert Speicher a6ec5121f0 Correct RSpec/SingleLineHook cop offenses 2017-06-14 13:18:56 -05:00
DJ Mountney 1d1363e2bb Bring in security changes from the 9.2.5 release
Ran:
 - git format-patch v9.2.2..v9.2.5 --stdout > patchfile.patch
 - git checkout -b 9-2-5-security-patch origin/v9.2.2
 - git apply patchfile.patch
 - git commit
 - [Got the sha ref for the commit]
 - git checkout -b upstream-9-2-security master
 - git cherry-pick <SHA of the patchfile commit>
 - [Resolved conflicts]
 - git cherry-pick --continue
2017-06-07 21:16:20 -07:00
Bob Van Landuyt bdebe849b8 Translate project & repository pages 2017-06-07 20:13:44 +00:00
Lin Jen-Shin bf6961cad8 Just let the user to create the namespace 2017-06-06 23:39:22 +08:00
Douwe Maan 9464456597 Merge branch 'pull-mirror-overhaul-ce-backport' into 'master'
backports changed import logic from pull mirroring feature into CE

See merge request !11850
2017-06-05 23:40:53 +00:00
Tiago Botelho 810866ecb6 backports changed import logic from pull mirroring feature into CE 2017-06-05 23:09:10 +01:00
Maxime Besson 9326d89623
Allow manual bypass of auto_sign_in_with_provider
This commit lets a user bypass the automatic signin on the login form,
in order to login with a technical (admin, etc) account

Closes #3786

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 20:00:11 +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
James Lopez 4731ae75c6 Fix propagate service spec transient failure 2017-05-23 08:52:23 +02:00
Jose Ivan Vargas acd573f1e6 minor adjustments to the specs 2017-05-22 15:14:13 -05:00
Jose Ivan Vargas fbde5e3313 Renamed some messages and refactored the project_edit class to a function 2017-05-22 12:55:01 -05:00
Jose Ivan Vargas 42604d4c33 Prevent project transfer if a new group is not selected 2017-05-22 12:55:01 -05: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