Commit Graph
3035 Commits
Author SHA1 Message Date
tiagonbotelho 0291473b98 fixes issues 2016-03-12 18:08:01 +00:00
tiagonbotelho 7530827eca fixes issues for mr acceptance 2016-03-12 18:08:01 +00:00
tiagonbotelho b9d13c11de implements upcoming filter in milstones 2016-03-12 18:08:01 +00:00
Dmitriy Zaporozhets a3b626bf25 Merge branch 'projects-finder-ee-compatible' into 'master'
Removed User#project_relations

This is to make things more compatible with EE so merging is easier.

cc @dzaporozhets 

See merge request !3192
2016-03-12 16:50:51 +00:00
Yorick Peterse 3b76b73ab1 Removed User#project_relations
GitLab EE adds an extra relation that selects a "project_id" column
instead of an "id" column, making it very hard for this method to be
re-used in EE. Since using User#authorized_groups in
ProjectsFinder#all_groups apparently has no performance impact we can
just use it and keep everything compatible with EE.
2016-03-12 15:44:48 +01:00
Douwe Maan 8ee1c0ffe5 Merge branch 'rs-disallow-blank-line-code' into 'master'
Disallow blank (non-null) values for a Note's `line_code` attribute

It's unclear how these blank values got added, but GitLab.com had a few:

```
irb(main):002:0> Note.where("line_code IS NOT NULL AND line_code = ''").count
=> 439
```

We've added a migration to convert any existing records to use a NULL
value when blank, and updated Note to set blank values to nil before
validation.

See merge request !3118
2016-03-12 14:01:06 +00:00
Douwe Maan 34e8c56236 Merge branch 'fix/token-timing-attack' into 'master'
fix token issue - timing attack

Updates token comparisons to use a secure version instead of `==`

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/13617

See merge request !3062
2016-03-12 12:14:32 +00:00
Robert Speicher 01f6db4f64 Disallow blank (non-null) values for a Note's line_code attribute
It's unclear how these blank values got added, but GitLab.com had a few:

```
irb(main):002:0> Note.where("line_code IS NOT NULL AND line_code = ''").count
=> 439
```

We've added a migration to convert any existing records to use a NULL
value when blank, and updated Note to set blank values to nil before
validation.
2016-03-11 17:46:50 -05:00
Yorick PeterseandRobert Speicher 4f3fa519c6 Use a UNION in MergeRequest.in_projects
The OR condition for source_project_id/target_project_id leads to a
query plan that performs rather poorly on PostgreSQL due to the use of
sub-queries. Because Rails offers no easy alternative for this
particular problem we're forced to using a UNION for both conditions.
The resulting query performs much faster than just using an OR.
2016-03-11 15:26:32 -05:00
Yorick PeterseandRobert Speicher ee75c49313 Make Namespace.search case-insensitive
This ensures searching namespaces works exactly the same as searching
for any other resource.
2016-03-11 15:25:24 -05:00
Yorick PeterseandRobert Speicher d7d5937531 Removed arel_table receiver from search methods
We can just use "arel_table" in these cases instead of
"SomeClass.arel_table".
2016-03-11 15:25:23 -05:00
Yorick PeterseandRobert Speicher 9e00a23716 Clean up ProjectsFinder for getting user projects
We don't need the extra layer of nesting of UNION queries here (as
User#authorized_projects already returns a UNION'd query).
2016-03-11 15:25:23 -05:00
Yorick PeterseandRobert Speicher 2cf7f3f410 Use ILIKE/LIKE for searching milestones 2016-03-11 15:25:22 -05:00
Yorick PeterseandRobert Speicher 87e7c3e132 Use ILIKE/LIKE for Issuable.search and full_search 2016-03-11 15:25:21 -05:00
Yorick PeterseandRobert Speicher 2076bdb62e Use ILIKE/LIKE for searching CI runners 2016-03-11 15:25:21 -05:00
Yorick PeterseandRobert Speicher ce5e831bcf Use ILIKE/LIKE for searching groups 2016-03-11 15:25:21 -05:00
Yorick PeterseandRobert Speicher 800aa29695 Use ILIKE/LIKE for searching users 2016-03-11 15:25:21 -05:00
Yorick PeterseandRobert Speicher 508b6b46fe Use ILIKE/LIKE for searching notes 2016-03-11 15:25:21 -05:00
Yorick PeterseandRobert Speicher 1f5284e5dd Use ILIKE/LIKE for searching snippets
Previously this used a regular LIKE which is case-sensitive on
PostgreSQL. This ensures that for both PostgreSQL and MySQL the
searching is case-insensitive similar to searching for projects.
2016-03-11 15:25:21 -05: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
Jacob Vosmaer f4d478a6a8 Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into expiring-lock 2016-03-10 17:07:27 +01:00
Yorick Peterse f2992cf343 Optimize Project#ci_service(s)
The method Project#ci_services would load all services into memory
(including _all_ their columns) and then use Enumerable#select to reduce
the list. Project#ci_service in turn would further reduce this list down
to just 1 Service instance.

Instead of doing all this in Ruby we can just offload the work to the
database, reducing the amount of time spent in these methods. These
changes reduce the time of the first call to Project#ci_services from
around 240 ms to around 10 ms, though the final timings will vary based
on database load. Because Project#ci_service is memoized there's no
further overhead introduced by using a database query.

Fixes gitlab-org/gitlab-ce#14186
2016-03-10 15:32:31 +01:00
Jacob Vosmaer e7df3f51c9 Move method to User 2016-03-10 12:37:14 +01:00
Robert Speicher 8e3485d878 Merge branch 'fix-git-push-service-specs' into 'master'
Fixed the GitPushService specs

See merge request !3139
2016-03-09 20:42:14 +00:00
Douglas Barbosa Alexandre 00a19f323b Merge branch 'fix-todos' into 'master'
Fix error 500 in Todos

Closes #14095 

Closes #14075 

Closes #14109

Closes #14151

See merge request !3141
2016-03-09 19:22:43 +00:00
Jacob Vosmaer 5e46662798 Merge branch 'commit-limits' into 'master'
Commit limits

Prevent timeouts when creating/viewing Merge Requests with many
commits. Also, reduce the number of commits shown in the UI from 500
to 100.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/14031

This MR avoids Unicorn timeouts in some places and takes 4.5 seconds
off load times in others, when manually testing with a 4500-commit
compare/MR in the linux repo. It does not limit the number of Commit
objects instantiated in memory, just the amount of HTML generated. It
seems that having 4500 commits objects is not a problem in itself. If
it ever becomes one we could do something for Commit objects like we
did for Diff (introduce a CommitCollection or something).

See merge request !3095
2016-03-09 16:39:07 +00:00
Yorick Peterse 53719ecb80 Handle permissions for ExternalIssue instances
This fixes the remainder of the GitPushService specs.
2016-03-09 17:10:43 +01:00
Douglas Barbosa Alexandre 9e342fb00a Destroy all related todos when removing a project 2016-03-09 11:06:58 -03:00
Dmitriy Zaporozhets bc14d81af0 Merge branch 'rs-snippets-dont-expire' into 'master'
Remove `Snippet#expires_at`

This was removed from the interface in
https://github.com/gitlabhq/gitlabhq/pull/6027 but its implementation
lingered around for two years.

See merge request !3103
2016-03-09 09:02:17 +00:00
Yorick Peterse 590e1b4b21 Call after_create_branch in Repository#add_branch
This ensures the right caches are flushed when adding a branch via the
UI, instead of only flushing this one random cache.
2016-03-08 18:19:40 +01:00
Yorick Peterse 4ec035b488 Call the right hooks in Repository#add_tag
This ensures Repository#add_tag calls Repository#before_push_tag instead
of just 1 random cache expiration method.
2016-03-08 18:19:40 +01:00
Yorick Peterse 177025b5dd Call the right hooks when removing branches
This ensures that Repository#rm_branch calls
before_remove_branch/after_remove_branch instead of just 1 random cache
expiration method.
2016-03-08 18:19:40 +01:00
Yorick Peterse cb5a5ba095 Cache & flush tag/branch counts
The methods used for this are Repository#tag_count and
Repository#branch_count which cache their output in Redis as well as
memoizing it in an instance variable. Both methods have a corresponding
methods/hooks to flush the caches at the right time.
2016-03-08 18:19:40 +01:00
James Lopez fc610c182e add SHA256 to secure_compare 2016-03-08 15:57:45 +01:00
James Lopez ecb1c59665 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/token-timing-attack 2016-03-08 15:55:04 +01:00
Yorick Peterse 36730e8e63 Merge branch 'master' into 'master'
adds language names to projects list [image attached]

See merge request !3000
2016-03-08 14:52:53 +00:00
Douwe Maan afb8d76f3c Merge branch 'cache-raw-2' into 'master'
Set cache headers for raw blobs

This changes allows browsers and (in the case of public projects)
proxy caches to cache raw Git blob responses.

See merge request !3113
2016-03-07 22:05:15 +00:00
tiagonbotelhoandYorick Peterse 96c0255107 moves the main_language update logic to git push service 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse 337cb45226 removes automatic setting of main_language to project for it to set a main language you have now to make a commit to the project 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse 68d6f5bce1 fixes typo 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse 93fb4ce2c5 removes redundant self 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse d72e6ad2a1 adds tests and fixes some broken code to main language mr 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse c2c5572e22 adds swp and swo to gitignore and improves migration for project main_language 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse dc31aff3da removes unused methods that I forgot 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse a14b98f858 implements project languages saving them onto the database 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse d9e646a796 moves method to repository model 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse 85de3f6955 changes if ! to unless and now asks for language instead of languages 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse fe934a2da2 adds cache to languages list 2016-03-07 21:59:39 +01:00
tiagonbotelhoandYorick Peterse 73535b80b2 adds language names to projects list github style 2016-03-07 21:59:39 +01:00