summaryrefslogtreecommitdiff
path: root/app/models/merge_request_diff.rb
Commit message (Collapse)AuthorAgeFilesLines
* Delete non-latest merge request diff files upon diffs reloadosw-delete-non-latest-mr-diff-files-upon-mergeOswaldo Ferreira2018-06-241-0/+27
|
* Cleanup after adding MR diff's commit_count (try 2)Jan Provaznik2018-04-251-4/+0
| | | | | | * processes any pending records which are not migrated yet * bumps import_export version because of new commits_count attribute * removes commits_count fallback method
* Revert "Cleanup after adding MR diff's commit_count"Jan Provaznik2018-03-081-0/+4
| | | | This reverts commit 0b7d10851456018328da137beeca931767b4fd0a.
* Cleanup after adding MR diff's commit_countJan Provaznik2018-03-051-4/+0
| | | | | | * processes any pending records which are not migrated yet * bumps import_export version because of new commits_count attribute * removes commits_count fallback method
* Check for keep-around commits once if target and source projects are the sameAhmad Sherif2018-02-071-1/+1
| | | | This reduces the number of RefExists RPC call.
* Display related merge requests in commit detail pageHiroyuki Sato2018-01-121-0/+3
|
* Denormalize commits count for merge request diffs38068-commits-countJan Provaznik2018-01-101-4/+7
| | | | | | | | | For each MR diff an extra 'SELECT COUNT()' is executed to get number of commits for the diff. Overall time to get counts for all MR diffs may be quite expensive. To speed up loading of MR info, information about number of commits is stored in a MR diff's extra column. Closes #38068
* Use memoization for commits on diffsZeger-Jan van de Weg2017-12-121-3/+3
| | | | | | | | | | | | | | | | The Gitaly CommitService is being hammered by n + 1 calls, mostly when finding commits. This leads to this gRPC being turned of on production: https://gitlab.com/gitlab-org/gitaly/issues/514#note_48991378 Hunting down where it came from, most of them were due to MergeRequest#show. To prove this, I set a script to request the MergeRequest#show page 50 times. The GDK was being scraped by Prometheus, where we have metrics on controller#action and their Gitaly calls performed. On both occations I've restarted the full GDK so all caches had to be rebuild. Current master, 806a68a81f1baee, needed 435 requests After this commit, 154 requests
* Remove serialised diff and commit columnsSean McGivern2017-11-281-62/+10
| | | | | | | | | | | | | | | | The st_commits and st_diffs columns on merge_request_diffs historically held the YAML-serialised data for a merge request diff, in a variety of formats. Since 9.5, these have been migrated in the background to two new tables: merge_request_diff_commits and merge_request_diff_files. That has the advantage that we can actually query the data (for instance, to find out how many commits we've stored), and that it can't be in a variety of formats, but must match the new schema. This is the final step of that journey, where we drop those columns and remove all references to them. This is a breaking change to the importer, because we can no longer import diffs created in the old format, and we cannot guarantee the export will be in the new format unless it was generated after this commit.
* Use latest_merge_request_diff associationSean McGivern2017-11-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compared to the merge_request_diff association: 1. It's simpler to query. The query uses a foreign key to the merge_request_diffs table, so no ordering is necessary. 2. It's faster for preloading. The merge_request_diff association has to load every diff for the MRs in the set, then discard all but the most recent for each. This association means that Rails can just query for N diffs from N MRs. 3. It's more complicated to update. This is a bidirectional foreign key, so we need to update two tables when adding a diff record. This also means we need to handle this as a special case when importing a GitLab project. There is some juggling with this association in the merge request model: * `MergeRequest#latest_merge_request_diff` is _always_ the latest diff. * `MergeRequest#merge_request_diff` reuses `MergeRequest#latest_merge_request_diff` unless: * Arguments are passed. These are typically to force-reload the association. * It doesn't exist. That means we might be trying to implicitly create a diff. This only seems to happen in specs. * The association is already loaded. This is important for the reasons explained in the comment, which I'll reiterate here: if we a) load a non-latest diff, then b) get its `merge_request`, then c) get that MR's `merge_request_diff`, we should get the diff we loaded in c), even though that's not the latest diff. Basically, `MergeRequest#merge_request_diff` is the latest diff in most cases, but not quite all.
* Optimise getting the pipeline status of commitsci-pipeline-status-queryYorick Peterse2017-11-161-1/+3
| | | | | This adds an optimised way of getting the latest pipeline status for a list of Commit objects (or just a single one).
* Set merge_request_diff_id on MR when creatingSean McGivern2017-11-021-0/+4
| | | | | | Once we migrate existing MRs to have this column, we will be able to get the latest diff for a single merge request more efficiently, and (more importantly) get all latest diffs for a collection of MRs efficiently.
* Move `fetch_ref` from MergeRequestDiff#ensure_commit_shas to MergeRequestRémy Coutable2017-10-051-2/+0
| | | | | | | | | | | | MergeRequest#create_merge_request_diff and MergeRequest#reload_diff are the only places where we generate a new MR diff so that's where we should fetch the ref. This also ensures that the ref is not fetched when we call merge_request.merge_request_diffs.create in Github::Import#fetch_pull_requests. Signed-off-by: Rémy Coutable <remy@rymai.me>
* Keep only the changes that are known to work wellRémy Coutable2017-10-051-1/+1
| | | | | | | | | | | | Also, improved a bit the method names in Github::Representation::PullRequest. Last but not least, ensure temp branch names doesn't contain a `/` as this would create the ref in a subfolder in `refs/heads` (e.g. `refs/heads/gh-123/456/rymai/foo`), and would leave empty directories upon branch deletion (e.g. `refs/heads/gh-123/456/rymai/`. Signed-off-by: Rémy Coutable <remy@rymai.me>
* Fetch and map refs/pull to refs/merge-requests in the GH importJames Lopez2017-10-051-1/+2
| | | | update MR diff
* Refactor Gitlab::Git::Commit to include a repositoryAlejandro Rodríguez2017-08-071-3/+1
|
* Migrate MR commits and diffs to new tablesmerge-request-commits-background-migrationSean McGivern2017-08-031-5/+1
| | | | | | | | | | | | Previously, we stored these as serialised fields - `st_{commits,diffs}` - on the `merge_request_diffs` table. These now have their own tables - `merge_request_diff_{commits,diffs}` - with a column for each attribute of the serialised data. Add a background migration to go through the existing MR diffs and migrate them to the new format. Ignore any contents that cannot be displayed. Assuming that we have 5 million rows to migrate, and each batch of 2,500 rows can be completed in 5 minutes, this will take about 7 days to migrate everything.
* Fix saving diffs that are not valid UTF-835539-can-t-create-a-merge-request-containing-a-binary-file-with-non-utf-8-charactersSean McGivern2017-07-261-4/+13
| | | | | | | | | | Previously, we used Psych, which would: 1. Check if a string was encoded as binary, and not ASCII-compatible. 2. Add the !binary tag in that case. 3. Convert to base64. We need to do the same thing, using a new column in place of the tag.
* Add table for merge request commitsSean McGivern2017-07-061-65/+34
| | | | | | | | | | | This is an ID-less table with just three columns: an association to the merge request diff the commit belongs to, the relative order of the commit within the merge request diff, and the commit SHA itself. Previously we stored much more information about the commits, so that we could display them even when they were deleted from the repo. Since 8.0, we ensure that those commits are kept around for as long as the target repo itself is, so we don't need to duplicate that data in the database.
* Rename ActiverecordSerialize copYorick Peterse2017-07-061-2/+2
| | | | | This cop has been renamed to ActiveRecordSerialize to match the way "ActiveRecord" is usually written.
* Add table for files in merge request diffsSean McGivern2017-06-161-17/+37
| | | | | | | | | | | | | | | | This adds an ID-less table containing one row per file, per merge request diff. It has a column for each attribute on Gitlab::Git::Diff that is serialised currently, with the advantage that we can easily query the attributes of this new table. It does not migrate existing data, so we have fallback code when the legacy st_diffs column is present instead. For a merge request diff to be valid, it should have at most one of: * Rows in this new table, with the correct merge_request_diff_id. * A non-NULL st_diffs column. It may have neither, if the diff is empty.
* Rename `Gitlab::Git::EncodingHelper` to `Gitlab::EncodingHelper`Bob Van Landuyt2017-06-011-1/+1
|
* Added Cop to blacklist the use of serializedocument-not-using-serializeYorick Peterse2017-05-311-2/+2
| | | | | This Cop blacklists the use of ActiveRecord's "serialize" method, except for cases where we already use this.
* Merge branch 'dm-diff-cleanup' into 'master'Robert Speicher2017-05-251-0/+23
|\ | | | | | | | | Clean up diff rendering See merge request !11390
| * Change code comment formattingdm-diff-cleanupDouwe Maan2017-05-231-1/+3
| |
| * Remove @commit in compare and MR controllersDouwe Maan2017-05-231-0/+3
| |
| * Pass fallback_diff_refs to Diff::File instead of using view helpersDouwe Maan2017-05-231-0/+18
| |
* | Add system note with link to diff comparison when MR discussion becomes outdatedDouwe Maan2017-05-231-3/+2
|/
* Show correct size when MR diff overflowsSean McGivern2017-04-251-1/+1
| | | | | | | The problem is that we often go via a diff object constructed from the diffs stored in the DB. Those diffs, by definition, don't overflow, so we don't have access to the 'correct' `real_size` - that is stored on the MR diff object iself.
* Statisfy Robertcop and Seancopdm-outdated-diff-linkDouwe Maan2017-04-111-9/+3
|
* Add specsDouwe Maan2017-04-101-0/+12
|
* Fix find_by_diff_refsDouwe Maan2017-04-081-1/+1
|
* Fix specs and make tweaksDouwe Maan2017-04-081-1/+4
|
* Link to outdated diff in older MR version from outdated diff discussionDouwe Maan2017-04-081-0/+1
|
* Fix issues importing forked projectsJames Lopez2017-04-041-8/+10
|
* Revert "Enable Style/DotPosition"Douwe Maan2017-02-231-2/+2
| | | | | | | | | | | | | | | This reverts commit e00fb2bdc2090e9cabeb1eb35a2672a882cc96e9. # Conflicts: # .rubocop.yml # .rubocop_todo.yml # lib/gitlab/ci/config/entry/global.rb # lib/gitlab/ci/config/entry/jobs.rb # spec/lib/gitlab/ci/config/entry/factory_spec.rb # spec/lib/gitlab/ci/config/entry/global_spec.rb # spec/lib/gitlab/ci/config/entry/job_spec.rb # spec/lib/gitlab/ci/status/build/factory_spec.rb # spec/lib/gitlab/incoming_email_spec.rb
* Revert "Prefer leading style for Style/DotPosition"Douwe Maan2017-02-231-2/+2
| | | | This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
* Prefer leading style for Style/DotPositionDouwe Maan2017-02-231-2/+2
|
* Enable Style/MutableConstantDouwe Maan2017-02-231-1/+1
|
* Enable Style/DotPositionDouwe Maan2017-02-231-2/+2
|
* Merge remote-tracking branch 'upstream/master' into ↵Lin Jen-Shin2017-01-261-11/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fix-git-hooks-when-creating-file * upstream/master: (1122 commits) Update CHANGELOG.md for 8.16.2 Display project ID in project settings (!8572) fixed points from comments to improve code quality Update CHANGELOG.md for 8.14.8 Statisfy eslint Add CHANGELOG entry Fix access to the wiki code via HTTP when repository feature disabled Display fullscreen button on small screens (!5302) Prevent removing fields from dropdowns on input elements fix for all themes Return struct instead of multiple values Fix race conditions for AuthorizedProjectsWorker Add User#nested_groups and User#nested_projects methods Fix spec failure due to timestamp ordering issue in mySQL Fixed error with filter keyboard tests `can?` already includes the `feature_available?` check Test there is no Merge Request button when MRs are disabled Ensure the correct Merge Request button is found Add 409 conflict tests Add CHANGELOG ...
| * Merge branch 'issue_25017' into 'master' Sean McGivern2017-01-171-10/+10
| |\ | | | | | | | | | | | | | | | | | | Show 'too many changes' message for merge request Closes #25017 See merge request !8444
| | * Show 'too many changes' message for merge requestissue_25017Felipe Artur2017-01-121-10/+10
| | |
| * | Absorb gitlab_gitRobert Speicher2017-01-041-1/+1
| |/
* | Prefer leading dots over trailing dotsLin Jen-Shin2017-01-061-2/+2
| |
* | Introduce Repository#with_tmp_ref which we needLin Jen-Shin2016-12-081-1/+2
|/ | | | | commits from the other repository. We'll cleanup the tmp ref after we're done with our business.
* Replace references to MergeRequestDiff#commits with st_commitsuse-st-commits-where-possibleAdam Niedzielski2016-12-011-5/+5
| | | | | | when we care only about the number of commits We do not have to instantiate all objects in this case.
* Hide empty merge request diffs when comparing versionsAdam Niedzielski2016-11-211-2/+4
|
* Also keep commits from source_project around, feedback:Lin Jen-Shin2016-10-251-3/+5
| | | | https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6658#note_17190236
* Refactor straight compare diff codeDmitriy Zaporozhets2016-10-121-2/+2
| | | | Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>