Commit Graph

179 Commits

Author SHA1 Message Date
James Lopez 112f470572 Fix cross-project references copy to include the project reference
Also added relevant specs and refactored to_references in a bunch of places to be more consistent.
2017-01-03 13:01:46 +01: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
Felipe Artur 9c740133a3 Allow JIRA references for project snippets 2016-11-21 12:09:41 -02:00
Nick Thomas e94cd6fdfe Add markdown cache columns to the database, but don't use them yet
This commit adds a number of _html columns and, with the exception of Note,
starts updating them whenever the content of their partner fields changes.

Note has a collision with the note_html attr_accessor; that will be fixed later

A background worker for clearing these cache columns is also introduced - use
`rake cache:clear` to set it off. You can clear the database or Redis caches
separately by running `rake cache:clear:db` or `rake cache:clear:redis`,
respectively.
2016-10-07 02:54:25 +01:00
Z.J. van de Weg 25004cbc32 Snippets get award emoji! 👍 2016-09-19 19:47:43 +03:00
Rémy Coutable 0d0f8a3b7d Merge branch 'feature/custom-highlighting' into 'master'
Add custom highlighting via .gitattributes

## What does this MR do?
Allows user control of language selection via a `gitlab-language` entry in `.gitattributes`

## Are there points in the code the reviewer needs to double check?
(paired with @stanhu)

## Why was this MR needed?
Guessing languages by filename is fraught and often wrong. In one project, `foo.pl` may be perl, and in another it may be prolog. Users might have a Thingfile that needs ruby highlighting, or depend on things that can't work in general, like `*.C` (capitalized) mapping to C++ instead of C.

This allows the user to override language choice so they never have to look at a mis-highlighted file.

## What are the relevant issue numbers?
https://github.com/jneen/rouge/issues/494
https://gitlab.com/gitlab-org/gitlab-ce/issues/13818 (*.tpl can't in general map to Smarty)
https://gitlab.com/gitlab-org/gitlab-ce/issues/13615 (in cases we don't have a language and mis-identify it, users could map to 'text' to turn off highlighting)

## Screenshots (if relevant)

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added (N/A)
- [x] Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [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 you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !4606
2016-06-28 08:42:42 +00:00
http://jneen.net/ e7b512efa6 move the path alias to a more appropriate location 2016-06-27 14:17:49 -07:00
http://jneen.net/ 5ff8371c5e add an alias for Snippet#path 2016-06-27 14:17:49 -07:00
Douglas Barbosa Alexandre 256cd8e498 Fix visibility of private project snippets for members when searching 2016-06-22 20:09:19 -03:00
Douglas Barbosa Alexandre 8f9b64c720 Fix internal snippets can be searched by anyone 2016-06-22 17:44:24 -03:00
Alejandro Rodríguez ad83c30855 Remove `projects` inclusion in `notes_with_associations` to skip some unnecessary queries
`notes_with_associations` are used for `participant` declarations, but `Participable`
only really cares about the target entity project, and not the participants
projects.

`notes_with_associations` are also used in `Commit::has_been_reverted?` which
employs the reference extractor of the commit, so no references to the notes
projects are made there (`Mentionable::all_references` cares only about the
`author` and other `attr_mentionable`). A paralel situation occurs on
`Issue::referenced_merge_requests`.
2016-06-08 10:26:05 -04:00
Yorick Peterse 580d250166
Refactor Participable
There are several changes to this module:

1. The use of an explicit stack in Participable#participants
2. Proc behaviour has been changed
3. Batch permissions checking

== Explicit Stack

Participable#participants no longer uses recursion to process "self" and
all child objects, instead it uses an Array and processes objects in
breadth-first order. This allows us to for example create a single
Gitlab::ReferenceExtractor instance and pass this to any Procs. Re-using
a ReferenceExtractor removes the need for running potentially many SQL
queries every time a Proc is called on a new object.

== Proc Behaviour Changed

Previously a Proc in Participable was expected to return an Array of
User instances. This has been changed and instead it's now expected that
a Proc modifies the Gitlab::ReferenceExtractor passed to it. The return
value of the Proc is ignored.

== Permissions Checking

The method Participable#participants uses
Ability.users_that_can_read_project to check if the returned users have
access to the project of "self" _without_ running multiple SQL queries
for every user.
2016-06-01 16:22:35 +02: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
Zeger-Jan van de Weg 47da013cf8 Annotate the models 2016-05-06 08:27:46 +02:00
Zeger-Jan van de Weg ad99404d25 Properly handle bigger files 2016-04-28 21:28:39 +02:00
Yorick Peterse e7849b0b25 Memoize reference_pattern/link_reference_pattern
These methods are called quite often in loops so by memoizing their
output we can reduce timings a bit.
2016-04-01 11:13:30 +02:00
Yorick Peterse 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 Peterse 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
Robert Speicher 836d593033 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.
2016-03-05 18:12:17 -05:00
Douwe Maan f3ea06eb7f Autolink first so we don't pick up numeric anchors as issue references. 2015-12-01 15:53:32 +01:00
Douwe Maan d6a5b45c8e Recognize issue/MR/snippet/commit links as references. 2015-11-30 21:36:34 +01:00
Nicolas aecc989154 Make snippet filename optional.
Fixes #2384.
2015-06-20 01:06:57 +02:00
Robert Speicher 1a9da9178c Surround Project.reference_pattern in parenthesis inside other patterns 2015-05-26 15:49:22 -04:00
Robert Speicher b88da58cb6 Add `reference_pattern` to Referable models 2015-05-26 15:48:32 -04:00
Robert Speicher 8773f339a3 Minor model spec cleanups
Snippet model was missing project association
2015-05-26 15:48:30 -04:00
Robert Speicher c0faf91ff2 Add `to_reference` for models that support references
Now there is a single source of information for which attribute a model
uses to be referenced, and its special character.
2015-05-26 15:48:30 -04:00
Douwe Maan e739eb036d Move participants method to shared Participable concern. 2015-04-24 12:30:36 +02:00
Douwe Maan 630e879066 Clean up code somewhat. 2015-04-17 11:03:33 +02:00
Douwe Maan a9b04c4536 Fix Snippet#participants. 2015-04-15 18:59:01 +02:00
Douwe Maan 7633d60268 Include snippet author in recipients of snippet note notification. 2015-04-15 17:57:31 +02:00
Douwe Maan dfe0f9eedf Use more specific regexes. 2015-03-27 11:09:29 +01:00
Stan Hu 7e204cf389 Added comment notification events to HipChat and Slack services.
Supports four different event types all bundled under the "note" event type:

- comments on a commit
- comments on an issue
- comments on a merge request
- comments on a code snippet
2015-03-06 06:54:00 -08:00
Dmitriy Zaporozhets 62ed1c537e Explicitly define ordering in models using default_scope 2015-02-05 14:20:55 -08:00
Dmitriy Zaporozhets cc39bca3fa Rubocop: Style/AlignHash enabled 2015-02-02 21:15:44 -08:00
Dmitriy Zaporozhets 118bd7178b
Sanitize snippet file name in raw headers
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-12 13:28:48 +02:00
Dmitriy Zaporozhets f28a12a559
Add strict validation to snippet file names
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-12 13:15:42 +02:00
Valery Sizov 82c938ad75 annotate 2014-10-09 18:22:20 +03:00
Valery Sizov 47f539f5a6 Snippets: public/internal/private 2014-10-09 17:09:53 +03:00
Valery Sizov fd8d1d9b62 Snippets: rename public to internal 2014-10-07 11:54:00 +03:00
Charles Bushong 4cca1b050a Adding in snippet search functionality
http://feedback.gitlab.com/forums/176466-general/suggestions/5529795-search-though-snippets
2014-08-29 15:32:07 -04:00
Dmitriy Zaporozhets 2acde87e0d
Project hook, milestone, snippet strong params
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-26 18:51:11 +03:00
Dmitriy Zaporozhets 98ba075c32
User model to strong params. Comment other attr_accessible to let tests run
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-26 15:11:45 +03:00
Marin Jankovski 18b1f171bd Rename snippets scopes to plural names. 2014-06-04 08:37:19 +02:00
Marin Jankovski 90c2e0d971 Replace now forbidden keywords public and private for snippets scope 2014-06-03 11:37:23 +02:00
Dmitriy Zaporozhets 36f861f1b1
Re-annotate models
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-04-09 15:05:03 +03:00
Dmitriy Zaporozhets de855e2420
Default value for Snippet#private
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-03-17 15:50:16 +02:00
Dmitriy Zaporozhets 8dd37afe34 Reannotate 2013-08-21 12:34:02 +03:00
Dmitriy Zaporozhets 6e35aceff2 Annotated 2013-06-19 15:40:33 +03:00
Andrew8xx8 3e695acfa2 Notes fixed 2013-03-25 15:58:09 +04:00
Andrew8xx8 3b6228dc27 It's better to use STI instead 2013-03-25 00:37:14 +04:00
Andrew8xx8 8adf9c7956 Additional scopes added 2013-03-25 00:23:12 +04:00
Andrew8xx8 770f262a6a Private added to attr_accessible 2013-03-25 00:22:45 +04:00
Andrew8xx8 bc7c5f87bb Project snippet moved to separate model 2013-03-24 19:26:49 +04:00
Andrew8xx8 b5db541338 All scopes must be in lambdas 2013-02-12 11:16:45 +04:00
Valeriy Sizov 69ec189ad2 remove length of snippet content 2013-01-22 17:10:00 +02:00
Dmitriy Zaporozhets 190e483fb4 Rework of milestones 2012-12-14 08:34:05 +03:00
Dmitriy Zaporozhets 95c23b2f97 Annotated. schema updated 2012-11-19 21:24:05 +03:00
Dmitriy Zaporozhets 41e53eb980 Annotated 2012-10-09 11:14:17 +03:00
Andrey Kumanyaev df7c52489a simple refactoring 2012-10-09 04:10:04 +04:00
Nihad Abbasov 841e4fbd08 cosmetical cleanup of models 2012-09-27 02:05:53 -07:00
Nihad Abbasov 2a4359a572 annotate models 2012-09-27 02:05:53 -07:00
Nihad Abbasov 83efcabc82 set activerecord whitelist_attributes to true 2012-09-26 11:18:35 -07:00
Robert Speicher 7754189187 Fully embrace Ruby 1.9 hash syntax
Didn't bother with files in db/, config/, or features/
2012-08-10 18:25:15 -04:00
randx 6abc649590 Reannotated 2012-06-26 21:23:09 +03:00
Dmitriy Zaporozhets 9c76bd9540 Project linguist integration 2012-04-21 01:26:22 +03:00
Dmitriy Zaporozhets 10df55e11d Added missing dependent for notes assoc 2011-12-18 12:10:20 +02:00
Dmitriy Zaporozhets 0712e78597 Snippet restyle 2011-12-15 08:12:24 +02:00
Dmitriy Zaporozhets 23a1ba7362 Fix different styles/button positions 2011-12-08 01:35:57 +02:00
Nihad Abbasov b6cdd1c819 test expired snippets 2011-10-28 00:25:50 +05:00
Nihad Abbasov 325b84545c don't count expired snippets 2011-10-27 13:12:12 +05:00
Nihad Abbasov 000c032482 display recent snippets at top 2011-10-27 12:14:50 +05:00
Nihad Abbasov 8e1e17763f implement snippets lifetime 2011-10-27 11:46:21 +05:00
Nihad Abbasov d62200cad4 clean-up code
* Remove trailing whitespace
  * Converts hard-tabs into two-space soft-tabs
  * Remove consecutive blank lines
2011-10-26 18:46:25 +05:00
gitlabhq b3279b9b51 moved from albino -> pygments.rb 2011-10-22 14:08:03 +03:00
gitlabhq c463eeb090 refactoring 2011-10-20 22:00:00 +03:00
gitlabhq d03f2687c5 annotated 2011-10-17 18:31:21 +03:00
gitlabhq 9265de3d25 snippets are ready 2011-10-17 00:07:10 +03:00