Commit Graph

361 Commits

Author SHA1 Message Date
Douwe Maan c8b63a28af Improve performance of finding last deployed environment 2017-02-06 16:12:24 -06:00
Douwe Maan 3aa1264dc6 Add tests 2017-02-06 16:12:24 -06:00
Douwe Maan c07311d486 Merge branch 'jej-pages-to-ce' into 'master'
Adding GitLab Pages to CE

Closes #14605, gitlab-com/infrastructure#1058, gitlab-ee#1333, and #323

See merge request !8463
2017-02-06 18:20:38 +00:00
Semyon Pupkov 3deb66ea56 Add traits for ProjectFeatures to Project factory
https://gitlab.com/gitlab-org/gitlab-ce/issues/24007
2017-02-05 13:11:45 +05:00
Kamil Trzcinski 861129c33a Mock Dir::exist? in project_spec.rb 2017-01-31 22:55:28 +00:00
Kamil Trzcinski 06d96a9a62 Introduce pages_deployed? to Project model 2017-01-31 22:55:28 +00:00
Kamil Trzcinski 8a861c87bf Describe #pages_url instead of :pages_url 2017-01-31 22:55:28 +00:00
Kamil Trzcinski 492627c987 Fix the URL of group pages 2017-01-31 22:53:58 +00:00
Kamil Trzcinski d3b8284876 Pages domain model specs 2017-01-31 22:53:57 +00:00
Dmitriy Zaporozhets ba2d7eda61 Improve search within group logic
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-01-30 17:34:14 +02:00
Oswaldo Ferreira aeb9db6753 Present group and dashboard MR list without grouping by project 2017-01-27 20:20:18 -02:00
Berna Castro ac66268443 Refactor Project#to_reference and make full_path a keyword argument
Refactor overall code and fix failing specs

Fix Project#to_reference

Fix wrong spaces and update changelog

Refactor #to_reference for Project & Issue

Fix and improves Project#to_reference
2017-01-27 20:20:17 -02:00
Berna Castro 08481a7103 Fix and add specs for Project#to_reference 2017-01-27 20:20:17 -02:00
Kamil Trzcinski b7f4553e3e
Backport changes introduced by https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1083 2017-01-20 12:25:53 +01:00
Robert Speicher d9f53a353e Convert most Project model specs to use `:empty_project` 2017-01-19 16:16:33 -05:00
Minqi Pan d7cdcc51bd
Expire related caches after changing HEAD
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-15 12:17:56 -05:00
James Lopez d3cfa39e3c New error message recreating projects on pending delete 2017-01-11 15:07:09 +01:00
Robert Speicher 602ea41d4b Remove unused `Project#web_url_without_protocol` method 2017-01-03 09:17:49 -05:00
Markus Koller 3ef4f74b1a
Add more storage statistics
This adds counters for build artifacts and LFS objects, and moves
the preexisting repository_size and commit_count from the projects
table into a new project_statistics table.

The counters are displayed in the administration area for projects
and groups, and also available through the API for admins (on */all)
and normal users (on */owned)

The statistics are updated through ProjectCacheWorker, which can now
do more granular updates with the new :statistics argument.
2016-12-21 16:39:49 +01:00
Douglas Barbosa Alexandre d1bf557aac Rename MattermostNotificationService back to MattermostService 2016-12-20 19:42:13 -02:00
Douglas Barbosa Alexandre fed29117de Rename SlackNotificationService back to SlackService 2016-12-20 19:42:13 -02:00
Rémy Coutable 367b68a01d Merge branch '22348-gitea-importer' into 'master'
It adds a brand new importer for Gitea!

This is a continuation of !6945 started by @bkc.

Gitea aims to be 100% GitHub-compatible but there's a few differences:

- Gitea is not an OAuth provider (yet): https://github.com/go-gitea/gitea/issues/27
  - This means we cannot map Gitea users given an assignee ID => assignees are not set on imported issues and merge requests
- No releases API for now: https://github.com/go-gitea/gitea/issues/330
- API version is `v1` (GitHub is `v3`)
- The IID field for milestones is `id` compared to `number` in GitHub.
- Issues, PRs, milestones, labels don't have a `url` field (the importer now fallback to `''` in that case)

**Known issues:**

- Comments are not imported because comments JSON always have a blank `html_url`/`issue_url`/`pull_request_url`, so the IID cannot be extracted and the issuable cannot be found... :( This is tracked in https://github.com/go-gitea/gitea/issues/401, and solved by https://github.com/gogits/gogs/pull/3624 but this needs to be submitted / merged in Gitea.

This is noted in the documentation.

## Are there points in the code the reviewer needs to double check?

1. I've made `Import::GiteaController` inherit from `Import::GithubController` since both controllers should be identical in the long-term and their current differences are small.
1. I've added a base `IssuableFormatter` class from which `IssueFormatter` & `PullRequestFormatter` inherit
1. I've added shared examples for GitHub/Gitea importer classes
1. I've made `Gitlab::ImportSources` more robust and tested! 🎄 
1. I've added routing specs for import routes! 🎄 

Closes #22348

See merge request !8116
2016-12-20 11:11:24 +00:00
Grzegorz Bizon 52278412c7 Merge branch 'zj-kamil-slack-slash-commands' into 'master'
Slack slash commands

## What does this MR do?

Implement Slack Slash Commands by utilizing generalized Mattermost presenter to fulfill Slack requirements.

## Why was this MR needed?

We want to expose Slack Slash Commands as a first-class service.

## What are the relevant issue numbers?

Supersedes !8007  
Closes #22182

See merge request !8126
2016-12-20 09:41:37 +00:00
Rémy Coutable ab06313c36 Add Project#gitea_import?
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-19 17:35:51 +01:00
Kamil Trzcinski f9023adbad
Fix spec failures 2016-12-18 23:32:53 +01:00
Kamil Trzciński b1120fc3e7 Merge branch 'expose-deployment-variables' into 'master'
Pass variables from deployment project services to CI runner

## What does this MR do?

This commit introduces the concept of deployment variables - variables
that are collected from deployment services and passed to CI runner
during a deployment build.
Deployment services specify the variables by overriding
"predefined_variables" method.

This commit also configures variables for KubernetesService

## Why was this MR needed?

We need these values for https://gitlab.com/gitlab-org/gitlab-ce/issues/23580

## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- ~~[ ] API support added~~
- Tests
  - [x] Added for this feature/bug
  - [ ] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

Refers to https://gitlab.com/gitlab-org/gitlab-ce/issues/23580

See merge request !8107
2016-12-16 18:01:28 +00:00
Adam Niedzielski c945a0a714 Pass variables from deployment project services to CI runner
This commit introduces the concept of deployment variables - variables
that are collected from deployment services and passed to CI runner
during a deployment build.
Deployment services specify the variables by overriding
"predefined_variables" method.

This commit also configures variables for KubernetesService
2016-12-16 13:24:03 +01:00
Felipe Artur a5ccaded65 Change SlackService to SlackNotificationsService 2016-12-15 15:32:49 -02:00
Felipe Artur 141faaacf9 Mattermost Notifications Service 2016-12-15 11:09:31 -02:00
Douwe Maan 05efd19e89 Merge branch 'dz-nested-groups' into 'master'
Add nested groups support on data level

## What does this MR do?

- [x] Add  `parent_id` field to `Namespace`model. 
- [x] Create new database table `routes` that keeps information about full path to each group or project
- [x] Remove uniq index from `namespaces.path`
- [x] Add uniq index on `routes.path`
- [x] Fill routes table with path data from namespaces and projects
- [x] Change Namespace/Project URL lookup by routes table
- [x] Rename related routes (nested groups, projects) when parent path changes

This is solely backend preparation. UI, Permissions and API support will be added in separate merge request.   
 
## Are there points in the code the reviewer needs to double check?

migrations, Route model, Routable concern

Will require downtime. See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7121#note_19490281 discussion

## Why was this MR needed?

One step further to full nested groups support

## Screenshots (if relevant)

No UI changes in this merge request so far

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG.md) entry added~~
- ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- ~~API support added~~
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/2772

See merge request !7121
2016-12-09 01:52:36 +00:00
Dmitriy Zaporozhets 83232be0e1
Add nested groups support on data level
* add parent_id field to namespaces table to store relation with nested groups
* create routes table to keep information about full path of every group and project
* project/group lookup by full path from routes table

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-12-08 11:47:16 +02:00
Rémy Coutable 5186618bb0 Merge branch '25209-improve-length-validators' into 'master'
Use :maximum instead of :within for length validators with a 0..N range

Closes #25209

See merge request !7894
2016-12-07 10:31:21 +00:00
Rémy Coutable 4e249d5bae
Use :maximum instead of :within for length validators with a 0..N range
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-12-06 10:23:17 +01:00
Oswaldo Ferreira f272ee6eba Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
Douwe Maan 3bf34face4 Merge branch 'jej-use-issuable-finder-instead-of-access-check' into 'security'
Replace issue access checks with use of IssuableFinder

Split from !2024 to partially solve https://gitlab.com/gitlab-org/gitlab-ce/issues/23867

## Which fixes are in this MR?

⚠️ - Potentially untested  
💣 - No test coverage  
🚥 - Test coverage of some sort exists (a test failed when error raised)  
🚦 - Test coverage of return value (a test failed when nil used)  
 - Permissions check tested

### Issue lookup with access check

Using `visible_to_user` likely makes these security issues too. See [Code smells](#code-smells).

- [x] 🚦 app/finders/notes_finder.rb:15 [`visible_to_user`]
- [x] 🚥 app/views/layouts/nav/_project.html.haml:73 [`visible_to_user`] [`.count`]
- [x]  app/services/merge_requests/build_service.rb:84 [`issue.try(:confidential?)`]
- [x]  lib/api/issues.rb:112 [`visible_to_user`]
  - CHANGELOG: Prevented API returning issues set to 'Only team members' to everyone
- [x]  lib/api/helpers.rb:126 [`can?(current_user, :read_issue, issue)`] Maybe here too?
- [x]  lib/gitlab/search_results.rb:53 [`visible_to_user`]

### Previous discussions
- [ ] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b2ff264eddf9819d7693c14ae213d941494fe2b3_128_126
- [ ] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#7b6375270d22f880bdcb085e47b519b426a5c6c7_87_87

See merge request !2031
2016-11-28 21:26:23 -03:00
Ahmad Sherif 916332815e Drop Project#authorized_for_user? in favor of ProjectTeam#member?
Closes #23938
2016-11-23 12:57:58 +02:00
Sean McGivern dfb21e299f Merge branch 'rs-project-team-helpers' into 'master'
Add shortcuts for adding users to a project team with a specific role

Closes #20944

See merge request !7565
2016-11-22 16:43:03 +00:00
Yorick Peterse ffb9b3ef18
Refactor cache refreshing/expiring
This refactors repository caching so it's possible to selectively
refresh certain caches, instead of just expiring and refreshing
everything.

To allow this the various methods that were cached (e.g. "tag_count" and
"readme") use a similar pattern that makes expiring and refreshing
their data much easier.

In this new setup caches are refreshed as follows:

1. After a commit (but before running ProjectCacheWorker) we expire some
   basic caches such as the commit count and repository size.

2. ProjectCacheWorker will recalculate the commit count, repository
   size, then refresh a specific set of caches based on the list of
   files changed in a push payload.

This requires a bunch of changes to the various methods that may be
cached. For one, data should not be cached if a branch used or the
entire repository does not exist. To prevent all these methods from
handling this manually this is taken care of in
Repository#cache_method_output. Some methods still manually check for
the existence of a repository but this result is also cached.

With selective flushing implemented ProjectCacheWorker no longer uses an
exclusive lease for all of its work. Instead this worker only uses a
lease to limit the number of times the repository size is updated as
this is a fairly expensive operation.
2016-11-21 15:05:13 +01:00
Douwe Maan 130c8a5198 Merge branch 'feature/precalculate-authorized-projects' into 'master'
Precalculate authorized projects in database

## What does this MR do?
It caches user's authorized projects in database instead of using multiple unions, which should simplify and speed-up things since this operation (getting authorized projects) is used a lot.

## Are there points in the code the reviewer needs to double check?
Did we miss a scenario where we need to refresh the list of projects?

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- [ ] ~~API support added~~
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?
#23150 

See merge request !6839
2016-11-18 19:42:17 +00:00
Ahmad Sherif fd05e26618 Precalculate user's authorized projects in database
Closes #23150
2016-11-18 20:25:45 +02:00
Kamil Trzciński ffc5fc6a38 Merge branch 'zj-slash-commands-mattermost' into 'master'
Slash command for mattermost

Closes  #22540

## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)


See merge request !7438
2016-11-18 18:06:36 +00:00
Kamil Trzcinski 1db1896ed2 Rename mattermost_command to mattermost_slash_commands 2016-11-18 17:27:14 +01:00
Robert Speicher eef3609123 Add shortcuts for adding users to a project team with a specific role
This also updates _some_ specs to use these new methods, just to serve
as an example for others going forward, but by no means is this
exhaustive.

Original implementations at !5992 and !6012.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/20944
2016-11-18 14:55:04 +02:00
Lin Jen-Shin 9c4e0d6445 Use `Gitlab.config.gitlab.host` over `'localhost'`
This would fix long standing failures running tests on
my development machine, which set `Gitlab.config.gitlab.host`
to another host because it's not my local computer. Now I
finally cannot withstand it and decided to fix them once and
for all.
2016-11-18 20:17:10 +08:00
Z.J. van de Weg dd826a5f20 Return a consistent not found message
This prevents leakage of project names on an endpoint which is
unauthenticated and thus open to the world.
2016-11-18 12:30:32 +01:00
Z.J. van de Weg b8607576c1 Projects have chat services 2016-11-18 10:10:41 +01:00
Z.J. van de Weg 778b5a5a04 Merge remote-tracking branch 'origin/master' into zj-slash-commands-mattermost 2016-11-17 21:56:38 +01:00
Z.J. van de Weg 166ee0965b More refactoring, push present to base command 2016-11-17 21:44:26 +01:00
Kamil Trzciński 9ad0d879fb Merge branch 'feature/environment-teardown-when-branch-deleted' into 'master'
Stop environment when branch is deleted

## What does this MR do?

This MR adds a environment teardown service, that is called when user deletes a branch. This most often happens when merge requests is merged.

## Does this MR meet the acceptance criteria?

- [x] [Changelog entry](https://docs.gitlab.com/ce/development/changelog.html) added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing

## What are the relevant issue numbers?

Closes #23218

See merge request !7355
2016-11-17 10:54:57 +00:00
Douwe Maan 4e63411daa Merge branch 'adam-build-missing-services-when-necessary' into 'master'
Defer saving project services to the database if there are no user changes

## What does this MR do?

It defers saving project services to the database as long as it is possible. It creates a project service when creating a project only if this project service has an active template. After that project services are saved on the first edit.

## Are there points in the code the reviewer needs to double check?

- tests that used `build_missing_services` before the change
- number of queries executed

## Why was this MR needed?

Motivation in #22281

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

## What are the relevant issue numbers?

Fixes #22281

See merge request !6958
2016-11-16 16:27:54 +00:00