Commit Graph

740 Commits

Author SHA1 Message Date
blackst0ne 5a7fbb8d89 [Rails5] Fix params passed to MergeWorker 2018-05-03 08:52:51 +00:00
Andreas Brandl 9ea2fc85a3 Atomic internal ids for all models 2018-04-20 14:00:15 +00:00
Sean McGivern 39c9928cfb Fix N+1 in `MergeRequest#merge_request_diff_for`
Previously, this would issue a query for each unique `diff_refs_or_sha`
passed. This was because we didn't want to load other MR diffs into memory, as
they had some very large columns.

Now they are actually very small, and it's more efficient to just load them all
at once and do the finding in Ruby.
2018-03-21 17:24:46 +00:00
Andreas Brandl a0abb90478 Deprecate InternalId concern and rename. 2018-03-16 13:35:25 +01: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
Bob Van Landuyt cfa9d1ed6b Only allow users that can merge to push to source
We only allow users that can merge the merge request to push to the
fork.
2018-03-07 17:00:50 +01:00
Bob Van Landuyt 792ab0631c Allow a user to select `allow maintainer to push`
When a project is not private, and the source branch not protected the
user can now select the option to allow maintainers to push to this
branch
2018-03-07 15:12:31 +01:00
Alejandro Rodríguez bc365bd15a Use persisted/memoized value for MRs shas instead of doing git lookups 2018-03-06 16:05:34 -03:00
Stan Hu 9a323c7e1f Memoize MergeRequest#rebase_in_progress? to prevent N+1 queries in Gitaly
MergeRequest#rebase_in_progress? and MergeRequest#rebase_path were called
twice each time per request. This memoization helps reduce the overall number
of queries.

See https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/51616319 as a failing
job.

Closes gitlab-org/gitlab-ee#4857
2018-02-08 10:28:50 +00:00
Oswaldo Ferreira dbfedb5adb Check MR state before submitting queries for discussion state 2018-01-29 23:53:47 -02:00
Sean McGivern f0df45fb8a Fix MR revert check when no merged_at is present 2018-01-29 10:49:14 +00:00
Nick Thomas b02f9b6141
Look at notes created just before merge when deciding if an MR can be reverted
On MySQL, at least, `Note#created_at` doesn't seem to store fractional seconds,
while `MergeRequest::Metrics#merged_at` does. This breaks the optimization
assumption that we only need to search for notes created *after* the MR has
been merged.

Unsynchronized system clocks also make this a dangerous assumption to make.

Adding a minute of leeway still optimizes away most notes, but allows both
cases to be handled more gracefully. If the system clocks are more than a
minute out, we'll still be broken, of course.
2018-01-25 11:39:46 +00:00
Hiroyuki Sato a7d26f00c3 Display related merge requests in commit detail page 2018-01-12 20:38:36 +00:00
Rémy Coutable 6438a1afa7 Merge branch '41807-15665-consistently-502s-because-it-fetches-every-commit' into 'master'
Resolve "!15665 consistently 502s because it fetches every commit"

Closes #41807

See merge request gitlab-org/gitlab-ce!16320
2018-01-12 15:47:50 +00:00
Sean McGivern f3cf8cc8d1 Only search for MR revert commits on notes after MR was merged
If we search for notes before the MR was merged, we have to load every commit
that was ever part of the MR, or mentioned in a push. In extreme cases, this can
be tens of thousands of commits to load, but we know they can't revert the merge
commit, because they are from before the MR was merged.

In the (rare) case that we don't have a `merged_at` value for the MR, we can
still search all notes.
2018-01-12 13:19:05 +00:00
🙈 jacopo beschi 🙉 729f05f0e3 Adds Rubocop rule for line break around conditionals 2018-01-11 16:34:01 +00:00
Yorick Peterse d0b8f536a1
Remove soft removals related code
This removes all usage of soft removals except for the "pending delete"
system implemented for projects. This in turn simplifies all the query
plans of the models that used soft removals. Since we don't really use
soft removals for anything useful there's no point in keeping it around.

This _does_ mean that hard removals of issues (which only admins can do
if I'm not mistaken) can influence the "iid" values, but that code is
broken to begin with. More on this (and how to fix it) can be found in
https://gitlab.com/gitlab-org/gitlab-ce/issues/31114.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/37447
2018-01-08 17:04:45 +01:00
Jan Provaznik 27a75ea175 Backport 'Rebase' feature from EE to CE
When a project uses fast-forward merging strategy user has
to rebase MRs to target branch before it can be merged.
Now user can do rebase in UI by clicking 'Rebase' button
instead of doing rebase locally.

This feature was already present in EE, this is only backport
of the feature to CE. Couple of changes:
* removed rebase license check
* renamed migration (changed timestamp)

Closes #40301
2018-01-05 09:34:59 +01:00
Sean McGivern b0bc676f20 Merge branch 'zj-mr-diff-memoization-bug' into 'master'
Clear caches before updating MR diffs

See merge request gitlab-org/gitlab-ce!15916
2017-12-14 13:27:00 +00:00
Zeger-Jan van de Weg 8ad412559d
Clear caches before updating MR diffs
The hook ordering influenced the diffs being generated as these used
values from before the update due to the memoization still being in
place. This commit reorders them and tests against this behaviour.
2017-12-14 11:22:34 +01:00
Annabel Dunstone Gray 9d0fc98c7d Merge branch '33926-update-issuable-icons' into 'master'
Update issuable status icons

Closes #33926

See merge request gitlab-org/gitlab-ce!15898
2017-12-13 19:14:38 +00:00
Sean McGivern 013e681625 Merge branch 'issue_41021' into 'master'
Prevent worker that updates merge requests head pipeline from failing jobs

Closes #41021

See merge request gitlab-org/gitlab-ce!15870
2017-12-13 16:45:48 +00:00
Felipe Artur 504f77b43a Prevent worker that updates merge requests head pipeline from failing jobs 2017-12-13 13:36:52 -02:00
Eric Eastwood a5439897d2 Update issuable status icons
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/33926

Changed file icons already addressed in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15367
2017-12-13 00:11:57 -06:00
Zeger-Jan van de Weg 3ab026b7d6
Use memoization for commits on diffs
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, 806a68a81f, needed 435 requests
After this commit, 154 requests
2017-12-12 16:28:26 +01:00
micael.bergeron 360b94ceba adding view and feature specs 2017-12-07 09:06:59 -05:00
micael.bergeron 16c8b91092 revert the `#all_pipelines` method to use the pluck
the `ci_pipelines.sha` column is not the same type than the
`merge_request_diff_commits.sha` column (varchar, bytea)
2017-12-07 09:02:42 -05:00
micael.bergeron cb6f51ec9b add support for the commit reference filter 2017-12-07 09:01:37 -05:00
micael.bergeron 716f9cbb41 tidying up the changes 2017-12-07 09:01:37 -05:00
micael.bergeron 3d8fbd12b8 add support for commit (in mr) to reference filter 2017-12-07 09:01:27 -05:00
Yorick Peterse 856447ccd3
Throttle the number of UPDATEs triggered by touch
This throttles the number of UPDATE queries that can be triggered by
calling "touch" on a Note, Issue, or MergeRequest. For Note objects we
also take care of updating the associated "noteable" relation in a
smarter way than Rails does by default.
2017-12-06 15:59:37 +01:00
Felipe Artur 5cf3ff27c8 Use actual head pipeline on merge request serializer 2017-12-05 12:54:10 -02:00
Felipe Artur f586dc0735 Check if head_pipeline is correct before merging 2017-12-05 12:54:10 -02:00
Felipe Artur 8f78ba554d Improve MergeRequest#head_pipeline 2017-12-05 12:54:10 -02:00
Jarka Kadlecova fe673b4927 Ensure pippeline corresponds with the sha of an MR 2017-12-05 12:54:10 -02:00
Lin Jen-Shin 4925ec5087 We could simply count the commits 2017-11-30 16:03:28 +08:00
Yorick Peterse 124fa93a8a Merge branch 'remove-mr-diff-serialised-columns' into 'master'
Remove serialised diff and commit columns

Closes #39533

See merge request gitlab-org/gitlab-ce!15582
2017-11-29 13:33:06 +00:00
Rémy Coutable becf29e3ab Merge branch '40530-merge-request-generates-wrong-diff-when-branch-and-tag-have-the-same-name' into 'master'
Resolve "Merge request generates wrong diff when branch and tag have the same name"

Closes #40530

See merge request gitlab-org/gitlab-ce!15591
2017-11-28 18:01:09 +00:00
Sean McGivern 3c6a4d6363 Ensure MRs always use branch refs for comparison
If a merge request was created with a branch name that also matched a tag name,
we'd generate a comparison to or from the tag respectively, rather than the
branch. Merging would still use the branch, of course.

To avoid this, ensure that when we get the branch heads, we prepend the
reference prefix for branches, which will ensure that we generate the correct
comparison.
2017-11-28 17:01:38 +00:00
Sean McGivern 4ebbfe5d3e Remove serialised diff and commit columns
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.
2017-11-28 16:13:40 +00:00
George Andrinopoulos 7fb1bb01bd Create issue and merge request destroy services 2017-11-25 22:09:18 +02:00
Sean McGivern c4d844f08b Merge branch 'issue_40374' into 'master'
Fix WIP system note not being created

Closes #40374

See merge request gitlab-org/gitlab-ce!15528
2017-11-24 09:38:45 +00:00
Felipe Artur 5c2c471a83 Fix WIP system note not being created 2017-11-23 17:25:14 -02:00
Sean McGivern 991bf24ec8 Use latest_merge_request_diff association
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.
2017-11-23 12:14:56 +00:00
George Andrinopoulos 3963f91ee3 Move update_project_counter_caches? out of issue and merge request 2017-11-11 21:06:28 +02:00
Sean McGivern ec73ecb0a8 Fix another timeout when searching for pipelines
When we consider 'all' pipelines for MRs, we now mean:

1. The last 10,000 commits (unordered).
2. From the last 100 MR versions (newest first).

This seems to fix the MRs that time out on GitLab.com.
2017-11-10 14:27:26 +00:00
Rémy Coutable bf13746fd8 Merge branch 'dm-notes-for-commit-id' into 'master'
Use Commit#notes and Note.for_commit_id when possible to make sure we use all indexes available to us

Closes #34509

See merge request gitlab-org/gitlab-ce!15253
2017-11-08 16:04:15 +00:00
Douwe Maan fec48c6e17 Use Commit#notes and Note.for_commit_id when possible to make sure we use all the indexes available to us 2017-11-08 12:22:11 +01:00
Jarka Kadlecova ad6e650262 Refactor issuables index actions 2017-11-07 14:34:12 +01:00
micael.bergeron bb0543ef47 ignore the column before the migration
reword the changelog
remove dead code in the specs
2017-11-06 09:03:11 -05:00
micael.bergeron cd88fa8f80 removed the #ensure_ref_fetched from all controllers
also, I refactored the MergeRequest#fetch_ref method to express
the side-effect that this method has.

  MergeRequest#fetch_ref -> MergeRequest#fetch_ref!
  Repository#fetch_source_branch -> Repository#fetch_source_branch!
2017-11-03 08:13:11 -04:00
Jarka Kadlecova 064c8949bd CE port of code changed for epics 2017-11-02 07:14:35 +01:00
Yorick Peterse c14697a50b Merge branch '39054-activerecord-statementinvalid-pg-querycanceled-error-canceling-statement-due-to-statement-timeout' into 'master'
Resolve "ActiveRecord::StatementInvalid: PG::QueryCanceled: ERROR:  canceling statement due to statement timeout"

Closes #39054

See merge request gitlab-org/gitlab-ce!15063
2017-10-30 11:57:09 +00:00
Oswaldo Ferreira c4124fce48 Move locked check to a guard-clause 2017-10-30 11:21:23 +01:00
Oswaldo Ferreira a6c52c4e59 Make merge_jid handling less stateful in MergeService 2017-10-27 22:33:48 +02:00
Sean McGivern ba9b4c4de8 Avoid hitting statement timeout finding MR pipelines
For MRs with many thousands of commits, `SELECT DISTINCT(sha)` will be very
slow.

What we can't do to fix this:

1. Add an index. Postgres won't use it for DISTINCT without a lot of ceremony.
2. Do the `uniq` in Ruby. That can still be very slow with hundreds of
   thousands of commits.
3. Use a subquery. We haven't removed the `st_commits` column yet, but we will
   soon.

Until 3 is available to us, we can just do 2, but also add a limit clause. There
is no ordering, so this may return different results, but our goal with these
MRs is just to get them to load, so it's not a huge deal.
2017-10-27 14:20:55 +01:00
Oswaldo Ferreira b78954c13d Simplify check for running job on Redis 2017-10-13 10:17:41 +02:00
Oswaldo Ferreira 9ab0254085 Make "merge ongoing" check more consistent 2017-10-11 18:48:39 +02:00
Andrew Newdigate 47d19c2de1 Stop using `branch_names.include?` and use `branch_exists?` 2017-10-10 14:56:04 +00:00
Rémy Coutable f070265a6d
Introduce new hook data builders for Issue and MergeRequest
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 16:44:47 +02:00
Rémy Coutable 075d651604 Start adding Gitlab::HookData::IssuableBuilder
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 15:07:10 +02:00
Rémy Coutable 67d5ca9f92 Include the changes in issuable webhook payloads
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-10-09 15:07:10 +02:00
Douwe Maan 546b18b903 Merge branch 'tc-geo-read-only-idea' into 'master'
Create idea of read-only database

Closes #37534

See merge request gitlab-org/gitlab-ce!14688
2017-10-07 11:01:21 +00:00
Bob Van Landuyt 70716a1292 Allow creating merge requests across forks of a project 2017-10-07 11:46:23 +02:00
Toon Claes d13669716a Create idea of read-only database
In GitLab EE, a GitLab instance can be read-only (e.g. when it's a Geo
secondary node). But in GitLab CE it also might be useful to have the
"read-only" idea around. So port it back to GitLab CE.

Also having the principle of read-only in GitLab CE would hopefully
lead to less errors introduced, doing write operations when there
aren't allowed for read-only calls.

Closes gitlab-org/gitlab-ce#37534.
2017-10-06 22:37:40 +02:00
Rémy Coutable 67de21c15b Move `fetch_ref` from MergeRequestDiff#ensure_commit_shas to MergeRequest
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>
2017-10-05 10:48:25 +02:00
Sean McGivern b1050bfe39 Merge branch 'merge-request-notes-performance' into 'master'
Use a UNION ALL for getting merge request notes

Closes #38508

See merge request gitlab-org/gitlab-ce!14620
2017-10-04 12:03:32 +00:00
Douwe Maan 2ee93c486c Merge branch '36876-mr-show-json-controller-perf-improvements' into 'master'
Reduce method calls while evaluating Projects::MergeRequestsController#show.json

See merge request gitlab-org/gitlab-ce!14285
2017-10-04 07:33:05 +00:00
Oswaldo Ferreira 1f54c9216f Reduce method calls while evaluating Projects::MergeRequestsController#show.json 2017-10-04 00:09:48 -03:00
Yorick Peterse c16b99a49c
Use a UNION ALL for getting merge request notes
In this particular case the use of UNION ALL leads to a better query
plan compared to using 1 big query that uses an OR statement to combine
different data sources.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/38508 for more
information.
2017-10-02 15:31:59 +02:00
Eric Eastwood 439e3f0735 Port semi-linear merge strategy to CE (mostly FE) 2017-09-29 14:13:35 -05:00
Yorick Peterse 57b96eb6db
Fix refreshing of issues/MR count caches
This ensures the open issues/MR count caches are refreshed properly when
creating new issues or MRs. This MR also includes a change to the cache
keys to ensure all caches are rebuilt on the fly.

This particular problem was not caught in the test suite due to a null
cache being used, resulting in all calls that would use a cache using
the underlying data directly. In production the code would fail because
a newly saved record returns an empty hash in #changes meaning checks
such as `state_changed? || confidential_changed?` would return false for
new rows, thus never updating the counters.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/38061
2017-09-19 17:16:45 +02:00
Andrew Newdigate 64d7ec0a9e Detect n+1 issues involving Gitaly 2017-09-19 10:55:37 +00:00
micael.bergeron 65bcd141c8 add controller spec
also fix some code styling issues
2017-09-06 09:00:57 -04:00
micael.bergeron b44a1bcd0b rework the contributor badge
- only show in merge-requests
 - show as a little glyph
2017-09-06 09:00:57 -04:00
Sean McGivern e8f29569bc Resolve outdated diff discussions on push 2017-09-06 10:08:03 +01:00
Sean McGivern dabce2c571 Merge branch 'git-operation-service-to-git' into 'master'
Prepare GitOperationService for moving to Gitlab::Git

See merge request !13773
2017-09-04 10:56:26 +00:00
Sean McGivern 2fc500819f Merge branch 'issue_36820' into 'master'
Remove closing external issues by reference error

Closes #36820

See merge request !13910
2017-09-01 09:15:40 +00:00
Felipe Artur 3e4013f217 Remove closing external issues by reference error 2017-08-31 17:15:30 -03:00
Sean McGivern dd406182cb Merge branch 'sidebar-cache-updates' into 'master'
Only update the sidebar count caches when needed

See merge request !13878
2017-08-31 14:30:03 +00:00
Jacob Vosmaer 8ad690b0d4 Prepare GitOperationService for move to Gitlab::Git 2017-08-31 15:35:59 +02:00
Yorick Peterse c158a22fd3
Only update the sidebar count caches when needed
This ensures the issues/MR cache of the sidebar is only updated when the
state or confidential flags changes, instead of changing this for every
update.
2017-08-30 15:49:40 +02:00
Lin Jen-Shin 86149a8216 Merge remote-tracking branch 'upstream/master' into 36807-gc-unwanted-refs-after-import
* upstream/master: (225 commits)
  Add changelog entry
  Backports EE 2756 logic to CE.
  Make rubocop happy
  Make profile settings dropdown consistent
  Add filter by my reaction
  Update spec initialization with it being a shared component
  Update identicon path and selector
  Renamed to `identicon` and make shared component
  Merge branch 'master-i18n' into 'master'
  Fix broken Frontend JS guide
  Replace 'project/star.feature' spinach test with an rspec analog
  Adds position fixed to right sidebar
  Fixes the margin of the top buttons of the pipeline page
  Remove commented out code
  Better align fallback image emojis
  Decrease Metrics/CyclomaticComplexity threshold to 15
  Add changelog
  Respect the default visibility level when creating a group
  Further break with_repo_branch_commit into parts
  Make sure inspect doesn't generate crazy string
  ...
2017-08-30 21:13:19 +08:00
Oswaldo Ferreira ffc576d7df Rename MergeRequest#async_merge to merge_async 2017-08-28 15:55:25 -03:00
Oswaldo Ferreira 9068083f86 Add changelog 2017-08-28 15:48:09 -03:00
Oswaldo Ferreira 4f17c6b763 Track enqueued and ongoing MRs 2017-08-28 15:48:09 -03:00
Oswaldo Ferreira d7f61bae8b Remove locked? check when unlocking a merge request
Our state machine shall have enough knowledge to not allow states other
than locked from transitioning to opened (e.g. MergeRequest#unlock_mr).
2017-08-28 15:48:09 -03:00
Lin Jen-Shin 081e2fce82 Try to make reserved ref names more obvious
So that whenever we want to reserve more, we're aware,
and don't mess it up.
2017-08-25 23:00:06 +08:00
Sean McGivern 7ab4efa8f8 Merge branch '36262_merge_request_reference_in_merge_commit_global' into 'master'
fix Merge request reference in merge commit is not global

Closes #36262

See merge request !13518
2017-08-24 09:09:45 +00:00
haseeb f5046e5258 [ci skip] changelog entry added for full merge request ref changes 2017-08-23 21:43:23 +05:30
Douwe Maan 75d1283e59 Merge branch 'cache-issue-and-mr-counts' into 'master'
Cache the number of open issues and merge requests

Closes #36622

See merge request !13639
2017-08-23 14:21:41 +00:00
Yorick Peterse 6ec53f5d48
Cache the number of open issues and merge requests
Every project page displays a navigation menu that in turn displays the
number of open issues and merge requests. This means that for every
project page we run two COUNT(*) queries, each taking up roughly 30
milliseconds on GitLab.com. By caching these numbers and refreshing them
whenever necessary we can reduce loading times of all these pages by up
to roughly 60 milliseconds.

The number of open issues does not include confidential issues. This is
a trade-off to keep the code simple and to ensure refreshing the data
only needs 2 COUNT(*) queries instead of 3. A downside is that if a
project only has 5 confidential issues the counter will be set to 0.

Because we now have 3 similar counting service classes the code
previously used in Projects::ForksCountService has mostly been moved to
Projects::CountService, which in turn is reused by the various service
classes.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36622
2017-08-23 13:42:29 +02:00
Felipe Artur 998833dfdc Remove ignore columns 2017-08-18 13:03:58 -03:00
Lin Jen-Shin d7e95d77d8 Use with_repo_branch_commit instead of fetch_ref directly
So that we could limit the access to Repository#fetch_ref
See: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/13416#note_37487433
2017-08-14 22:55:34 +08:00
haseeb df948f8ac2 fix Merge request reference in merge commit is not global 2017-08-13 12:58:19 +05:30
Lin Jen-Shin 41a5adca75 Don't try to create diffs if one of the branch is missing
Also fix a few tests
2017-08-10 23:53:55 +08:00
Lin Jen-Shin c772464b68 Introduce MergeRequest#write_ref and Repository#write_ref
so that we don't have to fetch it for non-forks
2017-08-10 22:20:53 +08:00
Brian Neel 9770c57fab Re-enable SqlInjection and CommandInjection 2017-08-08 10:50:54 -04:00
Oswaldo Ferreira 16cffa97f6 Move locked_at removal to post-deployment migration 2017-08-07 16:46:30 -03:00
Oswaldo Ferreira 0640b3d1d8 Store MergeWorker JID on merge request, and clean up stuck merges 2017-08-07 15:23:37 -03:00
Gabriel Mazetto abb878326c Rename many path_with_namespace -> full_path 2017-08-01 07:26:58 +02:00
Yorick Peterse 6ef87a2083
Merge issuable "reopened" state into "opened"
Having two states that essentially mean the same thing is very much like
having a boolean "true" and boolean "mostly-true": it's rather silly.
This commit merges the "reopened" state into the "opened" state while
taking care of system notes still showing messages along the lines of
"Alice reopened this issue".

A big benefit from having only two states (opened and closed) is that
indexing and querying becomes simpler and more performant. For example,
to get all the opened queries we no longer have to query both states:

    SELECT *
    FROM issues
    WHERE project_id = 2
    AND state IN ('opened', 'reopened');

Instead we can query a single state directly, which can be much faster:

    SELECT *
    FROM issues
    WHERE project_id = 2
    AND state = 'opened';

Further, only having two states makes indexing easier as we will only
ever filter (and thus scan an index) using a single value. Partial
indexes could help but aren't supported on MySQL, complicating the
development process and not being helpful for MySQL.
2017-07-28 13:31:51 +02:00
Jarka Kadlecova 7bee7b848a Support both internal and external issue trackers 2017-07-24 08:13:43 +02:00
Douwe Maan 87cb74a7bc Make sure MergeRequest commit methods work when either compare_commits or merge_request_diff is set 2017-07-13 18:53:11 -07:00
Stan Hu 43b9141c36 Merge branch 'sh-optimize-mr-api' into 'master'
Remove many N+1 queries with merge requests API

See merge request !12726
2017-07-08 06:22:09 +00:00
Stan Hu b963d45ca4 Remove many N+1 queries with merge requests API
Identified via `ENABLE_BULLET=1 bundle exec rspec spec/requests/api/merge_requests_spec.rb:34`

Improves speed of #34159
2017-07-07 16:31:21 -07:00
Douwe Maan 94e2a28684 Merge branch 'feature/user-datetime-search-api-mysql' into 'master'
Add creation time filters to user search API for admins

Closes #29507

See merge request !12682
2017-07-07 20:52:17 +00:00
James Lopez 6d28ad844d fix spec 2017-07-07 20:48:16 +02:00
Sean McGivern 4c0864fd9e Speed up `all_commit_shas` for new merge requests
For merge requests created after 9.4, we have a `merge_request_diff_commits`
table we can get all the SHAs from very quickly. We just need to exclude these
when we load from the legacy format, by ignoring diffs with no serialised
commits.

Once these have been migrated in the background, every MR will see this
improvement.
2017-07-07 13:59:23 +01:00
Sean McGivern aff5c9f3e5 Add table for merge request commits
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.
2017-07-06 17:36:10 +01:00
Yorick Peterse e1a3bf30b6
Rename ActiverecordSerialize cop
This cop has been renamed to ActiveRecordSerialize to match the way
"ActiveRecord" is usually written.
2017-07-06 12:01:36 +02:00
Yorick Peterse 8fbbf41e29
Added Cop to blacklist the use of `dependent:`
This is allowed for existing instances so we don't end up 76 offenses
right away, but for new code one should _only_ use this if they _have_
to remove non database data. Even then it's usually better to do this in
a service class as this gives you more control over how to remove the
data (e.g. in bulk).
2017-07-06 12:01:36 +02:00
Yorick Peterse c63e322158
Add many foreign keys to the projects table
This removes the need for relying on Rails' "dependent" option for data
removal, which is _incredibly_ slow (even when using :delete_all) when
deleting large amounts of data. This also ensures data consistency is
enforced on DB level and not on application level (something Rails is
really bad at).

This commit also includes various migrations to add foreign keys to
tables that eventually point to "projects" to ensure no rows get
orphaned upon removing a project.
2017-07-06 12:01:36 +02:00
Douwe Maan 6ee0436c89 Merge branch 'tc-namespace-license-checks--multiple-assignees' into 'master'
CE counterpart of: Namespace license checks for multiple assignees

See merge request !11825
2017-07-04 14:49:08 +00:00
Adam Niedzielski 0eb3d18c56 Store merge request ref_fetched status in the database
Closes #34052
2017-06-26 17:36:09 +02:00
Grzegorz Bizon 0430b76441 Enable Style/DotPosition Rubocop 👮 2017-06-21 13:48:12 +00:00
Toon Claes 451e25532f Make MergeRequest respond to assignee_ids & assignee_ids=
To make it simpler to assign users to an Issuable, make MergeRequest
support the attribute `assignee_ids`.
2017-06-20 21:32:49 +02:00
Sean McGivern 352a9ed562 Merge branch '27070-rename-slash-commands-to-quick-actions' into 'master'
Rename "Slash commands" to "Quick actions"

Closes #27070

See merge request !11811
2017-06-16 16:32:53 +00:00
Felipe Artur 85cdde8d33 Migration - Remove position field from issues and merge requests 2017-06-16 12:03:15 -03:00
Eric Eastwood ea090291bb Rename "Slash commands" to "Quick actions"
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/27070

Deprecate "chat commands" in favor of "slash commands"

We looked for things like:

 - `slash commmand`
 - `slash_command`
 - `slash-command`
 - `SlashCommand`
2017-06-15 09:01:56 -05:00
Grzegorz Bizon 0218a0bd23 Merge branch 'dm-update-discussion-diff-position' into 'master'
Update diff discussion position per discussion instead of per note

Closes #33157

See merge request !11833
2017-06-01 14:00:00 +00:00
Douwe Maan 483d88a9cd Merge branch 'document-not-using-serialize' into 'master'
Document not using ActiveRecord's serialize method

See merge request !11821
2017-06-01 13:06:30 +00:00
Douwe Maan 09838ac626 Update diff discussion position per discussion instead of per note 2017-05-31 14:34:56 -05:00
Yorick Peterse cd74c1434e
Added Cop to blacklist the use of serialize
This Cop blacklists the use of ActiveRecord's "serialize" method, except
for cases where we already use this.
2017-05-31 14:03:37 +02: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 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 7a7e9288d4 Stop MR conflict code from blowing up when branches are missing 2017-05-18 15:48:42 -05:00
Douwe Maan e4261fe3ce Merge branch 'fix-conflict-resolution-with-corrupt-repos' into 'master'
Fix conflict resolution from corrupted upstream

Closes gitlab-ee#2128

See merge request !11298
2017-05-12 20:37:30 +00:00
Sean McGivern ad2bfeb857 Fix conflict resolution from corrupted upstream
I don't know why this happens exactly, but given an upstream and fork repository
from a customer, both of which required GC, resolving conflicts would corrupt
the fork so badly that it couldn't be cloned.

This isn't a perfect fix for that case, because the MR may still need to be
merged manually, but it does ensure that the repository is at least usable.

My best guess is that when we generate the index for the conflict
resolution (which we previously did in the target project), we obtain a
reference to an OID that doesn't exist in the source, even though we already
fetch the refs from the target into the source.

Explicitly setting the source project as the place to get the merge index from
seems to prevent repository corruption in this way.
2017-05-12 20:47:51 +01:00
Valery Sizov e2a3a5095a Move update_assignee_cache_counts to the service 2017-05-12 14:12:29 +03:00
Sean McGivern a3607aa439 Merge branch 'issue_27168_2' into 'master'
Preloads head pipeline for each merge request

Closes #27168

See merge request !10064
2017-05-09 15:16:31 +00:00
Fatih Acet 0151325dac Merge request widget redesign 2017-05-09 04:15:34 +00:00
Felipe Artur 4ae411ff40 Preloads head pipeline for each merge request 2017-05-08 11:24:55 -03:00
Valery Sizov 387c4b2c21 Backport of multiple_assignees_feature [ci skip] 2017-05-04 17:11:53 +03:00
Douwe Maan f8fabfcc6f Allow commenting on older versions of the diff and comparisons between diff versions 2017-05-03 14:47:21 -05:00
mhasbini ccac05dd90 Fix 404 when upstream has disabled merge requests 2017-04-27 01:04:07 +03:00
Sean McGivern a0979c05fd Show correct size when MR diff overflows
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.
2017-04-25 16:54:10 +01:00
Sean McGivern 04a3e60e41 Merge branch 'dm-outdated-diff-link' into 'master'
Link to outdated diff in older MR version from outdated diff discussion

Closes #27865

See merge request !10572
2017-04-11 22:14:14 +00:00
Robert Speicher a1a94e739e Remove an unused `cared` scope from Issue and MergeRequest 2017-04-10 18:41:36 -04:00
Douwe Maan 50eae640db Fix specs and make tweaks 2017-04-08 14:37:46 -05:00
Douwe Maan 2c0de7aaaf Cache MR diffs by diff refs 2017-04-08 14:37:46 -05:00
Douwe Maan b202b42cfe Link to outdated diff in older MR version from outdated diff discussion 2017-04-08 14:37:46 -05:00
Luke "Jared" Bennett 8b98ca50b3
Merge branch 'master' into new-resolvable-discussion 2017-04-07 21:00:40 +01:00
Kushal Pandya 18506d4b8b Merge branch 'master' into '18471-restrict-tag-pushes-protected-tags'
# Conflicts:
#   app/assets/javascripts/dispatcher.js
#   app/assets/stylesheets/pages/projects.scss
2017-04-06 09:46:50 +00:00
Douwe Maan c319f21141
Address review comments 2017-04-05 17:44:14 +01:00
Douwe Maan 2058e71e63
Extract commonalities between DiffDiscussion and LegacyDiffDiscussion 2017-04-05 17:44:14 +01:00
Douwe Maan 08bbb9fce6
Add option to start a new discussion on an MR 2017-04-05 17:44:14 +01:00
Douglas Barbosa Alexandre 20486593bd Skip MR metrics when importing projects from GitHub 2017-04-03 15:50:22 -03:00