Commit Graph
217 Commits
Author SHA1 Message Date
Yorick Peterse 4259878615 Fixed ordering in Project.find_with_namespace
This ensures that Project.find_with_namespace returns a row matching
literally as the first value, instead of returning a random value.

The ordering here is _only_ applied to Project.find_with_namespace and
_not_ Project.where_paths_in as currently there's no code that requires
Project.where_paths_in to return rows in a certain order. Since this
method also returns all rows that match there's no real harm in not
setting a specific order either. Another reason is that generating all
the "WHEN" arms for multiple values in Project.where_paths_in becomes
really messy.

On MySQL we have to use the "BINARY" operator to turn a "WHERE" into a
case-sensitive WHERE as otherwise MySQL may still end up returning rows
in an unpredictable order.

Fixes gitlab-org/gitlab-ce#18603
2016-06-16 13:04:59 +02:00
Rémy Coutable be09845914 Merge branch 'environments-and-deployments' into 'master'
Add environments and deployments

This MR is a continuation of https://gitlab.com/gitlab-org/gitlab-ce/issues/17009.

The current implementation is as follow:
1. We have two new tables: `environments` and `deployments`.
2. We have a new tab: `Environments` under `Pipelines` where you can see all you environments and add a new one.
3. We add a new option to `.gitlab-ci.yml` to track where we should create a deployment for environment.
4. If environment in `.gitlab-ci.yml` is specified it will create a deployment. **If environment does not exist it will be created.** (this got changed)
5. The deployment is always successful and shows the time of the action, in that case a build that presumably should do deployment. In the future we could extend deployment with statuses: success, failure. We could extend deployments with information that this is partial or full deployment.
6. User have to create environments that he will track first.
7. User can remove environments.
8. User can retry/rollback past deployment (in that case we retry past build). The new build when succeeds it will create a new deployment.
9. Currently environment have only one parameter: `name`. In the future it should have: `variables`, `credentials` and possibly `runners` and maybe other resources.
10. Currently deployment have this parameters: `sha`, `ref`, `deployable (in this case a build)`, `user (who triggered a deployment)`, `created_at`.

The `.gitlab-ci.yml`:
```
deploy to production:
  stage: deploy
  script: dpl travis...
  environment: production
```

What needs to be done:
- [x] Write initial implementation
- [x] Improve implementation (@ayufan)
- [x] Write tests (@ayufan)
- [x] Improve UX of the forms (cc @markpundsack) - reviewed by @markpundsack
- [x] Improve implementation of the views (cc @jschatz1) - done by @iamphill 
- [x] Write .gitlab-ci.yml documentation for `environments` - done by @ayufan
- [ ] Write user documentation (@ayufan and @markpundsack)

See merge request !4605
2016-06-15 13:48:09 +00:00
Kamil Trzcinski 3ade826065 Add specs for models and services 2016-06-14 13:51:12 +02:00
Rémy Coutable 515205d3c1 UI and copywriting improvements
+ Move 'Edit Project/Group' out of membership-related partial
+ Show the access request buttons only to logged-in users
+ Put the request access buttons out of in a more visible button
+ Improve the copy in the #remove_member_message helper

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-14 13:18:14 +02:00
Rémy Coutable d26f81239a Add request access for groups
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-06-14 13:07:26 +02:00
Douglas Barbosa Alexandre 0568b90c97 Remove deprecated issues_tracker and issues_tracker_id from project 2016-06-13 18:13:55 -03:00
Robert Speicher b4e84809e8 Merge branch 'finding-multiple-projects-by-paths' into 'master'
Add Project.where_paths_in

In https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4410 I'm working on reducing the SQL queries needed to render Markdown. One reason for the large amount of queries is executing a large number of queries needed to find projects and related data. Basically `Project.find_with_namespace` is called in a loop and then any relations have to be retrieved separately.

By using `Project.where_paths_in` we can work around this by doing something like:

```ruby
project_paths = [...] # populated by some method
projects = Project.where_paths_in(project_paths).includes(:namespace, ...)
```

Ref: https://gitlab.com/gitlab-org/gitlab-ce/issues/18042

See merge request !4535
2016-06-10 17:17:19 +00:00
Paco GuzmanandYorick Peterse 136a4ea39b Cache the presence of an issue_tracker at project level
Using update_column to store the boolean flag to avoid
any side effects with the current state of the project
instance
2016-06-10 15:41:56 +02:00
Yorick Peterse 24920bc52a Add Project.where_paths_in
This method can be used to find multiple projects for multiple paths.
For example, take this snippet:

    Project.where_paths_in(%w{gitlab-org/gitlab-ce gitlab-org/gitlab-ee})

This will return an ActiveRecord::Relation containing the GitLab CE and
GitLab EE projects.

This method takes care of matching rows both case-sensitively and
case-insensitively where needed.

Project.find_with_namespace in turn has been modified to use
Project.where_paths_in without nuking any scoping (instead it uses
reorder(nil)). This means that any default scopes (e.g. those used for
"pending_delete" stay intact).

The method Project.where_paths_in was added so the various Markdown
filters can use a single query to grab all the projects referenced in a
set of documents, something Project.find_with_namespace didn't allow.
2016-06-10 15:33:05 +02:00
Kamil Trzcinski 8988c8743d Fix remaining test offenses 2016-06-07 13:14:37 +02:00
Kamil Trzcinski dbf235f514 Fix tests failures 2016-06-07 10:25:57 +02:00
Kamil Trzcinski 20c7144ed2 Rename all [ci_]commit to [ci_]pipeline in specs and features 2016-06-03 16:22:26 +02:00
Kamil Trzcinski 4d5f7aa008 Fix more places where we should rename ci_commit to pipeline 2016-06-03 14:46:17 +02:00
Kamil Trzcinski 021d3810c3 Rename Ci::Commit to Ci::Pipeline and rename some of the ci_commit to pipeline 2016-06-02 16:59:04 +02:00
Kamil Trzcinski 77cb8ec4d1 Introduce container_registry_path_with_namespace 2016-06-01 22:57:50 +02:00
Kamil Trzcinski 6e58e7ff7c Use downcased path to container repository as this is expected path by Docker 2016-06-01 20:43:33 +02:00
Robert Speicher 380966e861 Merge branch 'zero-project-creation-error-message' into 'master'
Updated error message when project limit is zero

When the project limit is zero & the user tries to create a project, the
error displayed is now 'Personal project creation is not allowed. Please
contact your administrator with questions'

Closes #17691

See merge request !4280
2016-05-25 20:38:14 +00:00
Phil Hughes 497a28c59f Fixed project model tests 2016-05-25 09:44:33 +01:00
Robert Speicher 75739e54be Enable RSpec/NotToNot cop and auto-correct offenses
Also removes the note from the development/testing.md guide
2016-05-24 15:40:29 -04:00
Kamil Trzcinski ac6992ba68 Fix specs 2016-05-16 23:40:40 -05:00
Kamil Trzcinski 04933fd572 Use container registry config stub 2016-05-16 18:07:49 -05:00
Kamil Trzcinski 91c4002a0c Improve test coverage 2016-05-16 18:03:55 -05:00
Kamil Trzcinski 154270a3d4 Test container related specs 2016-05-16 17:37:28 -05:00
Jeroen van Baarsen f1479b56b7 Remove the annotate gem and delete old annotations
In 8278b763d9 the default behaviour of annotation
has changes, which was causing a lot of noise in diffs. We decided in #17382
that it is better to get rid of the whole annotate gem, and instead let people
look at schema.rb for the columns in a table.

Fixes: #17382
2016-05-09 18:00:28 +02:00
Robert Speicher 0e29653f51 Remove wall_enabled field from Project 2016-05-08 15:47:42 -04:00
Yorick Peterse e28d1fa3cc Use a query in Project#protected_branch?
This changes Project#protected_branch? to use a query to check if a
branch is protected, instead of loading all ProtectedBranch records into
memory just to check if the list of names includes a given branch name.
2016-04-29 22:21:06 +02:00
Stan Hu 6dff1a9a2b Fix Error 500 due to stale cache when projects are renamed or transferred
Closes gitlab-org/gitlab-ee#506
2016-04-25 06:57:50 -07:00
Kamil Trzcinski 1c5b172abb Write specs for this feature 2016-04-16 22:43:40 +02:00
Kamil Trzcinski af7214d0f0 Fix specs 2016-04-11 23:32:55 +02:00
Zeger-Jan van de Weg 1e7116b34d Exclude projects pending deletion from all results 2016-03-31 20:20:18 +02:00
Stan Hu 506878970b Don't attempt to look up an avatar in repo if repo directory does not exist
Closes #14580
2016-03-25 06:30:51 -07:00
Douwe Maan 31266c5be4 Address feedback 2016-03-22 00:09:20 +01:00
Douwe Maan ae7b2ef62c Merge branch 'master' into issue_12658
# Conflicts:
#	app/models/issue.rb
#	app/views/projects/_home_panel.html.haml
#	app/views/shared/projects/_project.html.haml
#	db/schema.rb
#	spec/models/project_spec.rb
2016-03-21 23:22:21 +01:00
Yorick Peterse 68a4c98f50 Cache output of Repository#exists?
This caches the output of Repository#exists? in Redis while making sure
it's flushed properly when creating new repositories, deleting them,
etc.

For the ProjectWiki tests to work I had to make ProjectWiki#create_repo!
public as testing private methods in RSpec is a bit of a pain.
2016-03-19 21:54:08 +01:00
Felipe Artur 8b830b8c3b Fix specs 2016-03-18 21:04:53 -03:00
Zeger-Jan van de WegandFelipe Artur b959ae553b Improve group visibility level feature 2016-03-18 16:58:04 -03:00
Felipe Artur 44c127447b Merge 4009-external-users into issue_12658 2016-03-16 20:16:42 -03:00
Yorick Peterse c742760289 Ignore eager loading in Project.search UNION
The queries that are UNION'd together don't need any eager loading
(since we really only use the resulting SQL instead of having
ActiveRecord actually run the queries). By dropping any eager loaded
associations queries such as the following work instead of producing a
SQL error:

    Project.all.includes(:namespace).search('foo')
2016-03-15 16:46:17 +01:00
Yorick PeterseandRobert Speicher db615d0a79 Use ILIKE in Project.search_by_title
Similar to the changes made to Project.search the method
Project.search_by_title now also uses Arel so it can automatically use
ILIKE/LIKE instead of the lower() function.
2016-03-11 15:25:21 -05:00
Yorick PeterseandRobert Speicher 135659a751 Use ILIKE/LIKE + UNION in Project.search
This chance is broken up in two steps:

1. Use ILIKE on PostgreSQL and LIKE on MySQL, instead of using
   "WHERE lower(x) LIKE lower(y)" as ILIKE is significantly faster than
   using lower(). In many cases the use of lower() will force a slow
   sequence scan.

2. Instead of using 1 query that searches both projects and namespaces
   using a JOIN we're using 2 separate queries that are UNION'd
   together. Using a JOIN would force a slow sequence scan, using a
   UNION avoids this.

This method now uses Arel as Arel automatically uses ILIKE on PostgreSQL
and LIKE on MySQL, removing the need to handle this manually.
2016-03-11 15:25:21 -05:00
Felipe Artur c3e70280df Prevent projects to have higher visibility than groups
Prevent Groups to have smaller visibility than projects
Add default_group_visibility_level to configuration
Code improvements
2016-03-10 10:38:36 -03:00
Douglas Barbosa Alexandre 9e342fb00a Destroy all related todos when removing a project 2016-03-09 11:06:58 -03:00
Robert Speicher b900304c38 Make better use of the visibility_level factory traits 2016-03-08 16:40:45 -05:00
Yorick Peterse 1dfef90a87 Flush repository caches before renaming projects
This ensures that if a project is later re-created using the old path it
doesn't end up re-using the old cache. This also ensures we don't keep
the cache around until its expired by Redis itself.

Fixes gitlab-org/gitlab-ce#13790
2016-02-26 12:36:52 +01:00
Tomasz Maczukin 49d5c35b69 Fix old usages of ci_runner factory 2016-02-19 13:18:49 +01:00
Stan Hu 79c0e7212a Annotate models 2016-01-06 13:09:55 +00:00
Tomasz Maczukin c301ab0404 Add some specs for forked project visibility_level cases 2015-12-24 10:33:26 +01:00
Dmitriy Zaporozhets b8570576e8 Merge branch 'add-open-issues-count-to-api' of https://gitlab.com/stanhu/gitlab-ce
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2015-12-16 16:08:35 +01:00
Stan Hu 3efae53bd7 Add open_issues_count to project API
This is needed to support Huboard and a generally useful value.
2015-12-11 23:17:36 -08:00
Kamil Trzcinski 513d551c8f Fix after column rename 2015-12-11 18:02:10 +01:00