Sean McGivern
bb226a294b
Ensure that we never assume old_blob or new_blob are nil
...
These can be a `BatchLoader` which is proxying a nil, while not being concrete
nils themselves.
2018-03-16 18:19:33 +00:00
Sean McGivern
db90882665
Only cache MR diffs for one week
...
This may lead to some being evicted and having to be cached again, but many MRs
get closed or updated in that time anyway.
2018-03-15 11:49:53 +00:00
Sean McGivern
6cd7f679d0
Only cache highlight results for latest MR diffs
...
Previously, we kept them all in the cache. We don't need the highlight results
for older diffs - if someone does view that (which is rare), we can do the
highlighting on the fly.
2018-03-15 11:49:53 +00:00
Sean McGivern
4bc58ca210
Merge branch 'osw-stop-recalculating-merge-base-on-mr-loading' into 'master'
...
Avoid re-fetching merge-base SHA from Gitaly unnecessarily
See merge request gitlab-org/gitlab-ce!17630
2018-03-12 13:22:26 +00:00
Oswaldo Ferreira
ea81c27612
Submit a single batch blob RPC to Gitaly per HTTP request when viewing diffs
2018-03-09 12:36:46 -03:00
Oswaldo Ferreira
c6273ec50c
Avoid re-fetching merge-base SHA from Gitaly unnecessarily
2018-03-07 22:46:29 -03:00
Sean McGivern
cdf3ae04f8
Fix 500 error when diff context line has broken encoding
...
Rugged sometimes chops a context line in between bytes, resulting in the context
line having an invalid encoding: https://github.com/libgit2/rugged/issues/716
When that happens, we will try to detect the encoding for the diff, and
sometimes we'll get it wrong. If that difference in encoding results in a
difference in string lengths between the diff and the underlying blobs, we'd
fail to highlight any inline diffs, and return a 500 status to the user.
As we're using the underlying blobs, the encoding is 'correct' anyway, so if the
string range is invalid, we can just discard the inline diff highlighting. We
still report to Sentry to ensure that we can investigate further in future.
2018-02-22 12:26:23 +00:00
🙈 jacopo beschi 🙉
729f05f0e3
Adds Rubocop rule for line break around conditionals
2018-01-11 16:34:01 +00:00
Sean McGivern
528b5eeb76
Fix error when viewing diffs without blobs
...
Old merge requests can have diffs without corresponding blobs. (This also may be
possible for commit diffs in corrupt repositories.)
We can't use the `&.` operator on the blobs, because the blob objects are never
nil, but `BatchLoader` instances that delegate to `Blob`. We can't use
`Object#try`, because `Blob` doesn't inherit from `Object`.
`BatchLoader` provides a `__sync` method that returns the delegated object, but
using `itself` also works because it's forwarded, and will work for
non-`BatchLoader` instances too. So the simplest solution is to just use that
with the `&.` operator.
2018-01-04 14:33:12 +00:00
Douwe Maan
771bf9527f
Improve performance of DiffDiscussion#truncated_diff_lines and DiffNote#diff_line by removing expensive diff position calculation and comparison
2017-12-22 18:07:15 +01:00
Sean McGivern
7838317a14
Merge branch 'fix_39233' into 'master'
...
fix #39233 - 500 in merge request
Closes #39233
See merge request gitlab-org/gitlab-ce!15774
2017-12-07 20:35:39 +00:00
Martin Nowak
b7a5125f02
fix #39233 - 500 in merge request
...
- handle unchanged empty lines in inline diff
2017-12-07 20:19:37 +01:00
micael.bergeron
cb6f51ec9b
add support for the commit reference filter
2017-12-07 09:01:37 -05:00
Zeger-Jan van de Weg
f9565e3039
Batchload blobs for diff generation
...
After installing a new gem, batch-loader, a construct can be used to
queue data to be fetched in bulk. The gem was also introduced in both
gitlab-org/gitlab-ce!14680 and gitlab-org/gitlab-ce!14846 , but those mrs
are not merged yet.
For the generation of diffs, both the old blob and the new blob need to
be loaded. This for every file in the diff, too. Now we collect all
these so we do 1 fetch. Three `.allow_n_plus_1_calls` have been removed,
which I expect to be valid, but this needs to be confirmed by a full CI
run.
Possibly closes:
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37445
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37599
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37431
2017-11-21 13:53:26 +01:00
Jacopo
181cd299f9
Adds Rubocop rule for line break after guard clause
...
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
AlexWayfer
7ba7fa5048
Fix 500 error for old (somewhat) MRs
2017-10-30 12:30:31 +00:00
Sean McGivern
b2553840e8
Merge branch 'conflict-resolution-refactor' into 'master'
...
Conflict resolution refactor
See merge request gitlab-org/gitlab-ce!14747
2017-10-16 10:36:06 +00:00
Valery Sizov
d09895a0de
Fix diff parser so it tolerates to diff special markers in the content
2017-10-15 17:00:36 +03:00
Alejandro Rodríguez
9fdde3693b
Move line code generation into Gitlab::Git
...
Having a distinct class just for that was a bit overkill
2017-10-12 22:13:05 -03:00
Alejandro Rodríguez
faa9bd402d
Create a Gitlab::Git submodule for conlict-related files
...
Rename classes to (hopefully) clearer names while we're doing that.
2017-10-12 22:03:15 -03:00
Alejandro Rodríguez
f72598b659
Move Gitlab::Diff::LineCode to module Gitlab::Git
2017-10-12 21:45:16 -03:00
Felipe Artur
b54203f0ad
Commenting on image diffs
2017-10-07 04:25:17 +00:00
Douwe Maan
19a30595d9
Remove unnecessary comments
2017-09-25 10:23:43 +02:00
Douwe Maan
b9857d8b66
Properly compare diff refs and diff positions when shas are truncated
2017-09-25 10:22:28 +02:00
Ahmad Sherif
eb36fa17a6
Migrate Gitlab::Git::Repository#diff to Gitaly
...
Closes gitaly#524
2017-09-21 11:05:06 +02:00
Andrew Newdigate
64d7ec0a9e
Detect n+1 issues involving Gitaly
2017-09-19 10:55:37 +00:00
micael.bergeron
46e4e8f4dc
changed InlineDiffMarker to make it html_safe its output
...
updated the spec
2017-09-12 13:42:40 -04:00
Sean McGivern
e8525e107d
Show un-highlighted diffs when blobs are the same
...
For some old merge requests, we don't have enough information to figure out the
old blob and the new blob for the file. This means that we can't highlight the
diff correctly, but we can still display it without highlighting.
2017-08-24 11:11:18 +01:00
Sean McGivern
b0f09406f5
Always return a simple diff viewer
...
We didn't have a fallback case before, because we believed the conditions were
exhaustive. They weren't, so we can always fallback to not previewing.
2017-08-22 14:04:54 +01:00
Robert Speicher
260c8da060
Whitelist or fix additional `Gitlab/PublicSend` cop violations
...
An upcoming update to rubocop-gitlab-security added additional
violations.
2017-08-14 12:14:11 -04:00
Brian Neel
9770c57fab
Re-enable SqlInjection and CommandInjection
2017-08-08 10:50:54 -04:00
Jacob Vosmaer
7b18c42464
Remove unused (?) code
2017-07-31 17:19:25 +02:00
Douwe Maan
5e8aca2152
Don't display comment on unchanged line on both sides in parallel diff
2017-06-19 11:50:46 -05:00
Douwe Maan
7944254563
Implement diff viewers
2017-06-14 10:12:21 -05:00
Sean McGivern
e9002222a0
Merge branch 'dm-diff-file-diffable' into 'master'
...
Move diffable? method from Repository to Diff::File
See merge request !11980
2017-06-08 16:14:56 +00:00
Douwe Maan
e6e29f9220
Use Diff::File blob methods from diff highlighter
2017-06-08 09:39:54 -05:00
Douwe Maan
ffbbd4112e
Move diffable? method from Repository to Diff::File
2017-06-08 09:32:57 -05:00
Douwe Maan
3a5d375e49
Fix Diff::Position#diff_file for positions on straight diffs
2017-06-06 14:48:05 -05:00
Sean McGivern
c1ee45953e
Merge branch 'fix_diff_line_comments' into 'master'
...
Fix: A diff comment on a change at last line of a file shows as two comments in discussion
Closes #32353
See merge request !11802
2017-06-01 10:30:46 +00:00
Valery Sizov
563c1ca01c
Fix: A diff comment on a change at last line of a file shows as two comments in discussion
2017-05-31 18:38:10 +03:00
Douwe Maan
aed0387f97
Consistent diff and blob size limit names
2017-05-29 17:02:02 -05:00
Robert Speicher
8e2fefc6c4
Merge branch 'dm-diff-cleanup' into 'master'
...
Clean up diff rendering
See merge request !11390
2017-05-25 22:15:57 +00:00
Douwe Maan
d88a5c1db1
Address feedback
2017-05-25 15:17:57 -05:00
Douwe Maan
0bf339f0ed
Address review
2017-05-24 10:10:10 -05:00
Douwe Maan
6e698b254e
Fix specs
2017-05-23 16:27:30 -05:00
Douwe Maan
ab91f76e8b
Add system note with link to diff comparison when MR discussion becomes outdated
2017-05-23 16:27:30 -05:00
Douwe Maan
7c479d88a9
Pass fallback_diff_refs to Diff::File instead of using view helpers
2017-05-23 15:37:05 -05:00
Douwe Maan
db40c668de
Rename Diff::File {old,new}_ref to {old,new}_sha
2017-05-23 15:37:04 -05:00
Douwe Maan
d9a0188d2f
Add question mark to Gitlab::Diff::File predicate methods
2017-05-23 15:37:04 -05:00
Douwe Maan
7a7e9288d4
Stop MR conflict code from blowing up when branches are missing
2017-05-18 15:48:42 -05:00