Commit Graph

283 Commits

Author SHA1 Message Date
Shinya Maeda 56418e85ac init 2017-07-28 18:13:29 +09: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
Sean McGivern 2e483ca9e3 Merge branch 'rc/fix-tests-factories' into 'master'
Fix the :project factory by not copying the test repo twice

See merge request !13123
2017-07-27 08:55:53 +00:00
Rémy Coutable 05e152fa7f
Fix the :project factory by not copying the test repo twice
Also, fixing some calls to the :project factory with the :test_repo
trait since this trait is already included in the :project factory.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-07-27 09:58:06 +02:00
Sean McGivern 396b8f91ec Fix saving diffs that are not valid UTF-8
Previously, we used Psych, which would:

1. Check if a string was encoded as binary, and not ASCII-compatible.
2. Add the !binary tag in that case.
3. Convert to base64.

We need to do the same thing, using a new column in place of the tag.
2017-07-26 15:34:57 +01: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
Kamil Trzciński a77158ff31 Merge branch 'feature/intermediate/32568-adding-variables-to-pipelines-schedules' into 'master'
Add variables to pipelines schedules

Closes #32568

See merge request !12372
2017-07-07 15:17:02 +00:00
Felipe Artur b5f596c3ff Native group milestones 2017-07-07 15:08:49 +00:00
Shinya Maeda 08fba1327f merge from master 2017-07-07 16:12:13 +09:00
Sean McGivern aff5c9f3e5 Add table for merge request commits
This is an ID-less table with just three columns: an association to the merge
request diff the commit belongs to, the relative order of the commit within the
merge request diff, and the commit SHA itself.

Previously we stored much more information about the commits, so that we could
display them even when they were deleted from the repo. Since 8.0, we ensure
that those commits are kept around for as long as the target repo itself is, so
we don't need to duplicate that data in the database.
2017-07-06 17:36:10 +01:00
Lin Jen-Shin 9f5ac179d1 Rename ci_config_file to ci_config_path 2017-07-05 20:11:01 +08:00
Shinya Maeda 3acc91866b Fix spec 2017-07-05 18:38:35 +09:00
Shinya Maeda ff7529b39d Fix spec/lib/gitlab/import_export/all_models.yml 2017-07-05 18:38:35 +09:00
Shinya Maeda 324cfe0f9b Fix spec. Add PipelineScheduleVariable for import_export 2017-07-05 18:38:35 +09:00
Shinya Maeda 17f34e5a74 Fix spec 2017-07-05 18:36:19 +09:00
Shinya Maeda cd6aa92207 Fix spec/lib/gitlab/import_export/all_models.yml 2017-07-05 18:36:19 +09:00
Shinya Maeda b6f41544d8 Fix spec. Add PipelineScheduleVariable for import_export 2017-07-05 18:36:19 +09:00
Lin Jen-Shin fb897f53bb Merge remote-tracking branch 'upstream/master' into 32815--Add-Custom-CI-Config-Path
* upstream/master: (39 commits)
  Fix rubocop offenses
  Make entrypoint and command keys to be array of strings
  Add issuable-list class to shared mr/issue lists to fix new responsive layout
  New navigation breadcrumbs
  Restore timeago translations in renderTimeago.
  Automatically hide sidebar on smaller screens
  Fix typo in IssuesFinder comment
  Remove placeholder note when award emoji slash command is applied
  Make setSidebarHeight more efficient with SidebarHeightManager.
  Update CHANGELOG.md for 9.3.3
  Resolve "More actions dropdown hidden by end of diff"
  Use Gitaly 0.14.0
  Improve support for external issue references
  Make issuables_count_for_state public
  Only verifies top position after the request has finished to account for errors
  Clarify counter caching for users without project access
  Make finders responsible for counter cache keys
  Add changelog entry for issue / MR tab counting optimisations
  Don't count any confidential issues for non-project-members
  Cache total issue / MR counts for project by user type
  ...
2017-07-03 14:03:10 +08:00
Alejandro Rodríguez f4e6aba1bb Set the GL_REPOSITORY env variable on Gitlab::Git::Hook 2017-06-29 15:22:40 -04:00
Lin Jen-Shin 468e8b5558 Fix doc, test, and form 2017-06-28 18:17:53 +08:00
Adam Niedzielski 0eb3d18c56 Store merge request ref_fetched status in the database
Closes #34052
2017-06-26 17:36:09 +02:00
Sean McGivern 9a73b634ab Add table for files in merge request diffs
This adds an ID-less table containing one row per file, per merge request
diff. It has a column for each attribute on Gitlab::Git::Diff that is serialised
currently, with the advantage that we can easily query the attributes of this
new table.

It does not migrate existing data, so we have fallback code when the legacy
st_diffs column is present instead. For a merge request diff to be valid, it
should have at most one of:

* Rows in this new table, with the correct merge_request_diff_id.
* A non-NULL st_diffs column.

It may have neither, if the diff is empty.
2017-06-16 18:30:01 +01:00
Kamil Trzciński 5c26f4718b Merge branch 'feature/gb/persist-pipeline-stages' into 'master'
Persist stages in the database

Closes #26481

See merge request !11790
2017-06-07 11:32:29 +00:00
Kamil Trzciński acd0b691a4 Merge branch 'feature/gb/migrate-pipeline-stages' into 'master'
Migrate pipeline stages in the database

See merge request !11714
2017-06-07 11:30:18 +00:00
Phil Hughes 563ea34692 Merge branch '12910-snippets-description' into 'master'
Support descriptions for snippets

Closes #31894

See merge request !11071
2017-06-07 09:26:48 +00:00
Grzegorz Bizon 96a7236bfd Merge branch 'feature/gb/migrate-pipeline-stages' into feature/gb/persist-pipeline-stages
* feature/gb/migrate-pipeline-stages: (76 commits)
  redesign caching of application settings
  Fix binary encoding error on MR diffs
  Fix missing tooltip and ARIA labels for accessibility
  Add info on using self-signed certs with Registry
  Actually clean gitlab-test path when TestEnv.set_repo_refs fails
  Introduce optimistic locking support via optional parameter last_commit_id on File Update API
  Move issuable bulk edit form into a new sidebar.
  Add PowerShell to CI variable docs
  Responsive environment tables
  Accept a username for User-level Events API
  Introduce an Events API
  Update GitLab Pages to v0.4.3
  Allow numeric pages domain
  Remove references to old settings location
  Resolve "API: Environment info missed"
  Fix Projects API spec
  Resolve "When changing project visibility setting, change other dropdowns automatically"
  Update explanation of job-level variable override to fit example
  change headings to improve SEO
  backports changed import logic from pull mirroring feature into CE
  ...
2017-06-06 21:22:19 +02:00
Grzegorz Bizon 36ed05faf4 Merge commit '6ac1caa01a4c059f5bcb7c9da2e83001e5469f73' into feature/gb/migrate-pipeline-stages
* commit '6ac1caa01a4c059f5bcb7c9da2e83001e5469f73': (76 commits)
  redesign caching of application settings
  Fix binary encoding error on MR diffs
  Fix missing tooltip and ARIA labels for accessibility
  Add info on using self-signed certs with Registry
  Actually clean gitlab-test path when TestEnv.set_repo_refs fails
  Introduce optimistic locking support via optional parameter last_commit_id on File Update API
  Move issuable bulk edit form into a new sidebar.
  Add PowerShell to CI variable docs
  Responsive environment tables
  Accept a username for User-level Events API
  Introduce an Events API
  Update GitLab Pages to v0.4.3
  Allow numeric pages domain
  Remove references to old settings location
  Resolve "API: Environment info missed"
  Fix Projects API spec
  Resolve "When changing project visibility setting, change other dropdowns automatically"
  Update explanation of job-level variable override to fit example
  change headings to improve SEO
  backports changed import logic from pull mirroring feature into CE
  ...
2017-06-06 21:21:11 +02:00
Tim Zallmann 43dcb0afdb Merge branch 'jej-backport-protected-tag-ee-role-refactorings' into 'master'
Backport EE refactorings for Protected Tag EE-only functionality

See merge request !11125
2017-06-05 18:32:37 +00:00
Grzegorz Bizon 25b26c2f28 Fix typo in import/export safe model attributes 2017-06-05 15:01:15 +02:00
Grzegorz Bizon 5b718d4825 Merge branch 'master' into feature/gb/migrate-pipeline-stages
* master: (524 commits)
  Improve user experience around slash commands in instant comments
  Fix LFS timeouts when trying to save large files
  retryable? is now available for CommitStatus
  Resolve "Documentation of `.gitlab-ci.yml` states incorrect example for variables"
  Fix test failures
  Add slugify project path to CI enviroment variables
  Fixed typo: craeted -> created
  32118 Make New environment empty state btn lowercase
  Expose import_status in Projects API
  32832 Remove overflow from comment form for confidential issues and vertically aligns confidential issue icon
  Fix test failures
  Allow manual bypass of auto_sign_in_with_provider
  Fix keys seed
  Allow users to be hard-deleted from the API
  fixup some classnames and media queries
  Enable the Style/PreferredHashMethods cop
  Lint our factories creation in addition to their build
  Don’t schedule workers from inside transactions
  Allow scheduling from after_commit hooks
  Forbid Sidekiq scheduling in transactions
  ...

Conflicts:
	db/schema.rb
	spec/spec_helper.rb
2017-06-05 13:13:38 +02:00
Grzegorz Bizon 79380fe5fb Merge branch 'master' into feature/gb/persist-pipeline-stages
* master: (524 commits)
  Improve user experience around slash commands in instant comments
  Fix LFS timeouts when trying to save large files
  retryable? is now available for CommitStatus
  Resolve "Documentation of `.gitlab-ci.yml` states incorrect example for variables"
  Fix test failures
  Add slugify project path to CI enviroment variables
  Fixed typo: craeted -> created
  32118 Make New environment empty state btn lowercase
  Expose import_status in Projects API
  32832 Remove overflow from comment form for confidential issues and vertically aligns confidential issue icon
  Fix test failures
  Allow manual bypass of auto_sign_in_with_provider
  Fix keys seed
  Allow users to be hard-deleted from the API
  fixup some classnames and media queries
  Enable the Style/PreferredHashMethods cop
  Lint our factories creation in addition to their build
  Don’t schedule workers from inside transactions
  Allow scheduling from after_commit hooks
  Forbid Sidekiq scheduling in transactions
  ...

Conflicts:
	app/serializers/pipeline_entity.rb
	db/schema.rb
	spec/factories/ci/stages.rb
	spec/lib/gitlab/import_export/safe_model_attributes.yml
	spec/services/ci/create_pipeline_service_spec.rb
	spec/spec_helper.rb
2017-06-05 12:51:59 +02:00
Grzegorz Bizon 3801a0df80 Export pipeline stages in import/export feature 2017-06-05 12:46:57 +02:00
Grzegorz Bizon 1a438e9f71 Use stage_id column in code that needs to know about it 2017-06-01 12:21:34 +02:00
Kamil Trzcinski 161af17c1b Introduce source to pipeline entity 2017-05-31 14:17:49 +02:00
James Edwards-Jones 0c1bf16d5f Backport EE refactorings for Protected Tag EE-only functionality
Improvements and refactorings were made while adding role based permissions for protected tags to EE. This doesn’t backport the feature, but should improve code quality and minimize divergence.
2017-05-31 13:06:29 +01:00
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
Dmitriy Zaporozhets 1ed7b7629a Merge branch '17848-web-hook-logging' into 'master'
Implement Web Hooks calls logging

Closes #17848

See merge request !11027
2017-05-25 13:26:12 +00:00
Alexander Randa 330789c23c Implement web hooks logging
* implemented logging of project and system web hooks
* implemented UI for user area (project hooks)
* implemented UI for admin area (system hooks)
* implemented retry of logged webhook
* NOT imeplemented log remover
2017-05-25 10:07:52 +03:00
Douwe Maan 6e698b254e Fix specs 2017-05-23 16:27:30 -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
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 f661980904 Added repository_update hook 2017-05-12 23:26:48 +01: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
Felipe Artur 2ccee7161a Small code improvements and add migration spec 2017-05-08 18:43:53 -03:00
Felipe Artur 24824cbb4c Fix Specs 2017-05-08 11:26:04 -03:00
Felipe Artur 4ae411ff40 Preloads head pipeline for each merge request 2017-05-08 11:24:55 -03:00