Commit Graph

175 Commits

Author SHA1 Message Date
Rémy Coutable 0eea8c8857 Support slash commands in noteable description and notes
Some important things to note:

- commands are removed from noteable.description / note.note
- commands are translated to params so that they are treated as normal
  params in noteable Creation services
- the logic is not in the models but in the Creation services, which is
  the right place for advanced logic that has nothing to do with what
  models should be responsible of!
- UI/JS needs to be updated to handle notes which consist of commands
  only
- the `/merge` command is not handled yet

Other improvements:

- Don't process commands in commit notes and display a flash is note is only commands
- Add autocomplete for slash commands
- Add description and params to slash command DSL methods
- Ensure replying by email with a commands-only note works
- Use :subscription_event instead of calling noteable.subscribe
- Support :todo_event in IssuableBaseService

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-08-13 00:05:57 +02:00
Lin Jen-Shin ec298011f2 Rails prefers require_dependency so that it won't require twice:
Closes #20724
2016-08-09 06:48:23 +00:00
Douwe Maan c008a1a967 Make Compare#diffs diff_options a regular argument 2016-08-03 09:32:01 -07:00
Paco Guzman c86c1905b5 switch from diff_file_collection to diffs
So we have raw_diffs too
2016-08-03 07:00:20 +02:00
Paco Guzman 1d0c7b7492 Introduce Compare model in the codebase.
This object will manage Gitlab::Git::Compare instances
2016-08-03 07:00:20 +02:00
Paco Guzman 8f359ea917 Move to Gitlab::Diff::FileCollection
Instead calling diff_collection.count use diff_collection.size which is cache on the diff_collection
2016-08-03 07:00:20 +02:00
Paco Guzman cd7c2cb6dd Cache highlighted diff lines for merge requests
Introducing the concept of SafeDiffs which relates 
diffs with UI highlighting.
2016-08-03 07:00:19 +02:00
Lin Jen-Shin 0f7851b7be Merge remote-tracking branch 'upstream/master' into new-issue-by-email
* upstream/master: (1547 commits)
  Add margin between buttons if both retry and cancel are present
  Add margin between labels; remove underline hover style on status button
  udpated JS based on feedback
  Use default cursor for table header of project files (!5165)
  Fix duplicated entry in changelog [ci skip]
  Improves left static sidebar behaviour
  Include default callback URL (OAuth)
  Cleanup feature proposal template
  Simplify regex for string-based multi-word label surrounded in quotes
  Revert "Merge branch '18193-developers-can-merge' into 'master'
"
  Upgrade Rails from 4.2.6 to 4.2.7.
  some JS magic to fix empty URL bug
  formats my test properly
  Update CHANGELOG
  Doesn't match empty label references surrounded in quotes
  Fix markdown rendering for label references that contains `.`
  Fix markdown rendering for label references that begin with a digit
  Fix markdown rendering for consecutive label references
  Stub omniauth provider for GitLab
  Update CHANGELOG
  ...
2016-07-15 15:30:26 +08:00
Douwe Maan 521a0a20f7 Allow reply-by-email with diff notes 2016-07-06 18:51:00 -04:00
Douwe Maan a9fa45f09e Represent DiffRefs as proper class instead of tuple array 2016-07-06 18:50:58 -04:00
Lin Jen-Shin 176fa21cb7 raise UnknownIncomingEmail when there's no mail_key:
So that we don't have to pretend that CreateNoteHandler
could handle a nil mail_key. Also, since NilClass#=~ would
just return nil for any regular expression, we could just
match it without checking nilness.

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3363#note_12566407
2016-06-20 19:15:54 +08:00
Lin Jen-Shin 0671db52a8 Use keyword args to be more clear:
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3363#note_12566374
2016-06-20 19:11:42 +08:00
Lin Jen-Shin c491f66952 Use a separate line for separate actions:
Feedback from:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/3363#note_12420487
2016-06-20 17:58:05 +08:00
Sean McGivern 1022a1678b Limit push email diff size
Limit push email diff size to 30 files or 150 KB, whichever comes first.
2016-06-17 08:55:05 +01:00
Lin Jen-Shin 09c38e46e5 Only pass item name 2016-06-15 20:10:16 +08:00
Lin Jen-Shin 9417814970 More space for private concern 2016-06-15 19:41:31 +08:00
Lin Jen-Shin 3ced5ae68e Save the list of handlers in a constant 2016-06-15 16:31:28 +08:00
Lin Jen-Shin 5608e1a159 Raise first like an input check 2016-06-15 16:23:41 +08:00
Lin Jen-Shin a01623882e Avoid assignment in if 2016-06-15 16:18:40 +08:00
Lin Jen-Shin fcc6a59247 Blank line for private 2016-06-15 16:18:31 +08:00
Lin Jen-Shin 3b64c4f9d6 A blank line to separate exception raising 2016-06-15 16:16:44 +08:00
Lin Jen-Shin 4c09871450 Avoid using bang bang 2016-06-15 16:15:49 +08:00
Lin Jen-Shin 72184c16ab Rename to project_path which is more accurate 2016-06-15 15:54:04 +08:00
Lin Jen-Shin cb168c347a Remove empty lines at the beginning of files 2016-06-15 15:47:40 +08:00
Lin Jen-Shin e75391889e Merge branch 'master' into new-issue-by-email
* master: (1246 commits)
  Update CHANGELOG
  Update tests to make it work with Turbolinks approach
  Use Turbolink instead of ajax
  Reinitialize checkboxes to toggle event bindings
  Turn off handlers before binding events
  Removed console.log Uses outerWidth instead of width
  Revert "Added API endpoint for Sidekiq Metrics"
  Added API endpoint for Sidekiq Metrics
  Added CHANGELOG entry for allocations Gem/name fix
  Filter out classes without names in the sampler
  Update the allocations Gem to 1.0.5
  Put all sidebar icons in fixed width container
  Instrument private/protected methods
  Fix Ci::Build#artifacts_expire_in= when assigning invalid duration
  Fix grammar and syntax
  Update CI API docs
  UI and copywriting improvements
  Factorize members mails into a new Emails::Members module
  Factorize access request routes into a new :access_requestable route concern
  Factorize #request_access and #approve_access_request  into a new AccessRequestActions controller concern
  ...
2016-06-15 15:43:12 +08:00
Lin Jen-Shin 1f5d55907a Merge the places where exceptions could be raised 2016-05-24 01:23:07 +08:00
Lin Jen-Shin 863d8e5ae5 use split and try to unify error raising 2016-05-23 22:16:40 +08:00
Lin Jen-Shin c64cd113cc Add ! for verify_record! because it could raise 2016-05-21 09:46:27 -07:00
Lin Jen-Shin 75415663f8 Rename handlers and introduce Handler.for 2016-05-21 09:40:08 -07:00
Lin Jen-Shin ee548b6ed0 Only set @raw for receiver, and handle the rest in execute 2016-05-20 19:03:39 -05:00
Lin Jen-Shin 32eae15f2f It's for Message-ID so it should be message_id 2016-05-20 18:23:04 -05:00
Lin Jen-Shin c2bc15a766 Use the authentication_token for finding the user 2016-05-20 17:38:08 -05:00
Lin Jen-Shin a7c823a573 Give ProjectNotFound when the project is not readable 2016-05-18 17:57:14 -05:00
Lin Jen-Shin c337e748d3 so we use separate classes to handle different tasks 2016-05-18 17:25:45 -05:00
Sean McGivern a9977f2b7a Syntax-highlight diffs in push emails
Based on:
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/151
2016-05-17 13:23:17 +01:00
Lin Jen-Shin 3f4a6412dc We should totally cache it 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 8156475ea5 Report better errors. TODO: Enable skipped test 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 30b3443779 Now we would be validating authentication token 2016-05-16 21:27:16 +00:00
Lin Jen-Shin a065c8d5d8 Create a new issue via: incoming+group/project+AUTH_TOKEN@... 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 634c9f403b process_reply -> process_create_note; handle_reply -> process_reply 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 869de96eea bang to indicate that this method could raise an exception 2016-05-16 21:27:16 +00:00
Lin Jen-Shin aac297adba Update style as create_note 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 68b5ded056 No need to check project because:
sent_notification.project would never be nil, and
we also have already checked message_project before
entering process_create_issue.
2016-05-16 21:27:16 +00:00
Lin Jen-Shin 87ff0107c1 Raise one by one instead of if checks 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 347ee6cc91 Alloy empty reply for new issues, but not response 2016-05-16 21:27:16 +00:00
Lin Jen-Shin a61bf17fce Try to give better names 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 0e4c2b6ec4 enable Style/MethodDefParentheses and fix parentheses 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 4f5027042a Add another TODO that we need to verify identity better 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 6cfd028278 Implement #3243 New Issue by email
So we extend Gitlab::Email::Receiver for this new behaviour,
however we might want to split it into another class for better
testing it.

Another issue is that, currently it's using this to parse project
identifier:

    Gitlab::IncomingEmail.key_from_address

Which is using:

    Gitlab.config.incoming_email.address

for the receiver name. This is probably `reply` because it's used
for replying to a specific issue. We might want to introduce another
config for this, or just use `reply` instead of `incoming`.

I'll prefer to introduce a new config for this, or just change
`reply` to `incoming` because it would make sense for replying to
there, too.

The email template used in tests were copied and modified from:
`emails/valid_reply.eml` which I hope is ok.
2016-05-16 21:27:16 +00:00
Gabriel Mazetto f5a0ac0fc1 Codestyle: make sure we have space around operators 2016-05-13 04:46:56 -03:00
Sean McGivern 5f27e26bb4 Only generate repository push email once
The repository push email can be very expensive to generate, especially
with syntax-highlighted diffs. Instead of generating the email for each
recipient, generate one email object and reset the Message-Id and To
headers for each recipient. (Cloning would also be expensive in the case
of large emails, although probably not as bad as generating from
scratch.)
2016-05-11 09:16:01 +01:00
Yorick Peterse 84b0ab7766 Added & use Gitlab::Routing for URL helpers
Rails' "url_helpers" method creates an anonymous Module (which a bunch
of methods) on every call. By caching the output of this method in a
dedicated method we can shave off about 10 seconds of loading time for
an issue with around 200 comments.
2016-04-01 11:13:48 +02:00
Rémy Coutable 9f218fc184 Improve and finish the fallback to the In-Reply-To and References header for the reply-by-email feature
A few things to note:
- The IncomingEmail feature is now enabled even without a
  correctly-formatted sub-address
- Message-ID for new thread mail are kept the same so that subsequent
  notifications to this thread are grouped in the thread by the email
  service that receives the notification
  (i.e. In-Reply-To of the answer == Message-ID of the first thread message)
- To maximize our chance to be able to retrieve the reply key, we look
  for it in the In-Reply-To header and the References header
- The pattern for the fallback reply message id is "reply-[key]@[gitlab_host]"
- Improve docs thanks to Axil
2016-03-25 13:05:15 +01:00
David Padilla 31e76baf61 Fix #2364. Fall back to In-Reply-To header when reply key not available 2016-03-25 13:05:15 +01:00
Lin Jen-Shin 9374b7eb0b Avoid using the same name between methods and variables 2016-03-23 20:05:31 +08:00
Jacob Vosmaer 1764e1b7cb Use Gitlab::Git::DiffCollections 2016-03-03 18:38:44 +01:00
Anton Baklanov 84124380e8 Added X-GitLab-... headers to emails from CI and Email On Push services
Fixes #2098
2016-01-19 20:18:39 +02:00
Douwe Maan 1886d727f7 Add API project upload endpoint 2016-01-07 13:37:14 +01:00
Grzegorz Bizon cbeb06eb42 Mix url helpers in into `RepositoryPush` 2015-12-11 13:00:24 +00:00
Grzegorz Bizon 66f658a9b5 Check if commits are available in `RepositoryPush` 2015-12-08 08:43:09 +01:00
Grzegorz Bizon 591035968d Duplicate options in `RepositoryPush` 2015-12-08 08:43:09 +01:00
Grzegorz Bizon 75c6b29f6b Add `RepositoryPush` specs 2015-12-08 08:43:09 +01:00
Grzegorz Bizon d835fbc79f Fix url helpers in RepositoryPush 2015-12-08 08:43:09 +01:00
Grzegorz Bizon 9f2752e5dc Remove obsolete variables in `repository_push_email` 2015-12-08 08:43:08 +01:00
Grzegorz Bizon 4beba7494b Improve Messagee::RepositoryPush 2015-12-08 08:43:08 +01:00
Grzegorz Bizon e2f937ce22 Refactor RepositoryPush, move to Message namespace 2015-12-08 08:43:08 +01:00
Grzegorz Bizon 8c6db54e12 Extract repository_push_email to separate class 2015-12-08 08:43:08 +01:00
Douwe Maan ee028d9d60 Rename reply_by_email to incoming_email to prepare for the future. 2015-09-21 10:35:37 +02:00
Douwe Maan 15fc7bd613 No HTML-only email please 2015-08-21 16:09:55 -07:00
Douwe Maan 69708dab9f Block blocked users from replying to threads by email. 2015-08-21 10:14:45 -07:00
Douwe Maan f26c2905d1 Fix indentation 2015-08-20 14:25:56 -07:00
Douwe Maan 8ec5fb138d Test Gitlab::Email::Receiver. 2015-08-20 12:17:59 -07:00
Douwe Maan 2f78b5e8af Make error class names more consistent. 2015-08-20 11:33:18 -07:00
Douwe Maan 0b401f2e94 Fix a couple of whoopsy daisies. 2015-08-20 11:17:14 -07:00
Douwe Maan e9972efc2f Extract ReplyParser and AttachmentUploader from Receiver. 2015-08-20 11:05:06 -07:00