gitlab-org--gitlab-foss/app/services
Douwe Maan 86d238e4bd Merge branch 'new-diff-notes' into 'master'
New diff notes

Fixes #12732, #14731, #19375, #14783 

Builds on https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4110

To do:
- [x] Get it mostly working
- [x] Validate position validity
- [x] Fix: Don’t link to `#`
- [x] Fix: Base ref can be `nil`, potentially, when the MR has an oprhan source branch => Yep, doesn’t work. We need to store a `start_id`
- [x] Optimize: Fewer duplicate `git diff` compares
- [x] Optimize: Pass paths to `PositionTracer#diff` for faster diffs
- [x] Refactor: Use `head_id` in `MergeRequest`/`MergeRequestDiff` instead of `source_sha`
- [x] Refactor: Convert existing array-based diff refs to the DiffRefs model
- [x] Tweak: Use `note_type` in `Autosave` key
- [x] Tweak: Remove `line_code: note.line_code` from `link_to_reply_discussion`
- [x] Update: `SentNotifications` and reply-by-email receiver
- [x] Update: MR diff notification email
- [x] Update: API (MR, Commit note creation and entity)
- [x] Update: GitHub importer
- [x] Address any other TODO comments
- [x] Fix: Suppress "edited 4 minutes ago"
- [x] Write tests
  - [x] `LineMapper`
  - [x] `PositionTracer`
  - [x] `Position`
  - [x] `DiffPositionUpdateService`
  - [x] `DiffNote`
  - [x] `MergeRequests::RefreshService` / `MergeRequest#update_diff_notes_positions`
- [x] Make sure commits with diff notes don't get cleaned up, since this would prevent the diff notes from being rendered (https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5062)

Future improvements:
- Display unresolved comments on files outside the diff, if the comment was added when that file _was_ part of the diff
- Allow commenting on sections between hunks, when expanding the diff using `...`
  - (We'd need to generate line code based on Position if we have it, even if it falls outside bounds of diff)
- `diff_hunk` on diff note API entity
- Show diff hunk in notification email
- Resolved line notes would have a boolean, and be inactive through `notes.any? { !active? || resolved? }`
- Multi line notes would store a number of positions, and do the right thing (™) in grouping and then rendering if the first item is multiline? => true
- Image diff notes could store x,y,width,height instead of old_line,new_line for similar grouping. Does it need a reference to say if it's on old or new? These can't have line_codes, clearly. Rendering would be interesting.
- Show commit line comments in the MR diff
- Comment on specific selected words
- Comment on file header
- Unfold top of discussion diff note
- New diff notes API for commits and MRs

/cc @rspeicher

See merge request !4101
2016-07-07 20:45:03 +00:00
..
auth Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
ci Merge remote-tracking branch 'upstream/master' into feature/runner-lock-on-project 2016-06-17 19:52:55 +08:00
commits Revert back to not defining a default Git access protocol. 2016-07-05 16:54:22 -05:00
files Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
groups Address feedback 2016-03-22 00:09:20 +01:00
issues Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
members Raise a new Gitlab::Access::AccessDeniedError when permission is not enough to destroy a member 2016-06-18 06:06:34 +02:00
merge_requests Merge branch 'new-diff-notes' into 'master' 2016-07-07 20:45:03 +00:00
milestones Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
notes Automatically update diff note positions when MR is pushed to 2016-07-06 18:51:00 -04:00
oauth2 Enable Style/EmptyLinesAroundAccessModifier rubocop cop 2016-06-03 10:34:20 +02:00
projects Merge branch 'services_refactoring1' into 'master' 2016-07-07 06:08:12 +00:00
search Restrict access to confidential issues on search results 2016-03-17 20:55:59 -03:00
wiki_pages Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
audit_event_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
base_service.rb Tweaks, refactoring, and specs 2016-03-20 21:04:07 +01:00
compare_service.rb Use Gitlab::Git::DiffCollections 2016-03-03 18:38:44 +01:00
create_branch_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
create_commit_builds_service.rb Remove reduntant method for building pipeline builds 2016-06-15 14:12:25 +02:00
create_deployment_service.rb Revert "squashed merge and fixed conflicts" 2016-06-16 12:59:07 +02:00
create_release_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
create_snippet_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
create_spam_log_service.rb Support Akismet spam checking for creation of issues via API 2016-02-02 11:25:44 -02:00
create_tag_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
delete_branch_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
delete_tag_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
delete_user_service.rb Clearify who deletes the user 2016-03-15 21:09:25 +01:00
destroy_group_service.rb Add ability to delete a user with force 2016-03-15 21:09:25 +01:00
event_create_service.rb Create a "destroyed Milestone" event and keep Milestone events around in the DB 2015-09-15 05:51:11 -07:00
git_hooks_service.rb Better message for git hooks and file locks 2016-07-04 15:31:49 +03:00
git_push_service.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
git_tag_push_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
gravatar_service.rb Add support for HiDPI displays in gravatar service 2015-09-26 20:53:16 +02:00
issuable_base_service.rb Spec label add / delete in UpdateService 2016-06-03 17:14:23 -05:00
notification_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
repair_ldap_blocked_user_service.rb Code style fixes and some code simplified 2016-01-08 16:26:04 -02:00
system_hooks_service.rb Revert "Fix merge conflicts - squashed commit" 2016-06-03 11:10:17 +02:00
system_note_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
test_hook_service.rb Added X-GitLab-Event header for web hooks 2015-05-08 16:49:03 +03:00
todo_service.rb Ensure logged-out users can't see private refs 2016-06-30 16:36:10 +01:00
update_release_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00
update_snippet_service.rb Services: code style fixes, minor refactoring 2016-07-06 20:58:43 +03:00