Commit Graph

740 Commits

Author SHA1 Message Date
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
James Edwards-Jones bf3cc824e4 Moved Project#protected_branch? to ProtectedBranch, similar for tags 2017-04-03 19:19:54 +01:00
Yorick Peterse 8cc4a39be8 Merge branch '22145-slow-search' into 'master'
Simplify projects, merge requests search queries

See merge request !10053
2017-03-24 12:27:54 +00:00
mhasbini df0603cf0e simplify projects, mrs search queries 2017-03-22 12:57:20 +02:00
Sean McGivern 1974691bfe Revert "Merge branch '29534-todos-performance' into 'master'"
This reverts merge request !10076
2017-03-21 15:25:00 +00:00
Jarka Kadlecova bf41a2e752 Todos performance: Include associations in Finder 2017-03-20 12:45:43 +01:00
Ruben Davila dd53a9c013 Include time tracking attributes in webhooks payload 2017-03-14 11:56:15 -05:00
Eric Eastwood 605fff9123 Default to subtle MR mege button until CI status is available
See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9245
2017-03-02 02:49:03 -06:00
James Lopez a0101ebf84 Update occurrences of MWBS to MWPS
Rename column in the database
 Rename fields related to import/export feature
 Rename API endpoints
 Rename documentation links
 Rename the rest of occurrences in the code
 Replace the images that contain the words "build succeeds" and docs referencing to them
 Make sure pipeline is green and nothing is missing.

updated doc images

renamed only_allow_merge_if_build_succeeds in projects and fixed references

more updates

fix some spec failures

fix rubocop offences

fix v3 api spec

fix MR  specs

fixed issues with partials

fix MR spec

fix alignment

add missing v3 to v4 doc

wip - refactor v3 endpoints

fix specs

fix a few typos

fix project specs

copy entities fully to V3

fix  entity error

more fixes

fix failing specs

fixed missing entities in V3 API

remove comment

updated code based on feedback

typo

fix spec
2017-03-01 12:02:02 +01:00
Sean McGivern 2da8bc3de9 Only create unmergeable todos once
Previously, we created an unmergeable todo when a merge request:

1. Had merge when pipeline succeeds set.
2. Became unmergeable.

However, when merge when pipeline succeeds fails due to unmergeability,
the flag isn't actually removed. And a merge request can become
unmergeable multiple times, as every time the target branch is updated
we need to re-check the mergeable status. This means that if the todo
was marked done, and the MR was checked again, a new todo would be
created for the same event.

Instead of checking this, we should create the todo from the service
responsible for merging when the pipeline succeeds. That way the todo is
guaranteed to only be created when we care about it.
2017-02-24 17:18:12 +00:00
Robert Speicher 170fef0bd3 Merge branch 'dm-meer-blauw-op-straat' into 'master'
Enable (and disable) more RuboCops

See merge request !9432
2017-02-23 17:19:28 +00:00
Douwe Maan 56de781a2c Revert "Enable Style/DotPosition"
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
2017-02-23 09:33:19 -06:00
Douwe Maan 1fe7501b49 Revert "Prefer leading style for Style/DotPosition"
This reverts commit cb10b725c8929b8b4460f89c9d96c773af39ba6b.
2017-02-23 09:33:05 -06:00
Douwe Maan 206953a430 Prefer leading style for Style/DotPosition 2017-02-23 09:32:22 -06:00
Douwe Maan 030baf70d2 Enable Performance/RedundantMerge 2017-02-23 09:31:57 -06:00
Douwe Maan 3dadf306dd Enable Style/DotPosition 2017-02-23 09:31:56 -06:00
Sean McGivern 5a2c688117 Fix MR changes tab size count
This was wrong when there were over 100 files in the diff, because we
did not use the same diff options as subclasses of
`Gitlab::Diff::FileCollection::Base` when getting the raw diffs. (The
reason we don't use those classes directly is because they may perform
highlighting, which isn't needed for just counting the diffs.)
2017-02-23 12:03:08 +00:00
Dmitriy Zaporozhets 6676b4f0dd
Use Namespace#full_path instead of Namespace#path
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-02-14 18:38:20 +02:00
Jan Christophersen 217937e569 Show mentioned/issues being closed from a Merge Requests title 2017-02-13 16:47:47 +01:00
Sean McGivern 40704daad8 Merge branch 'restore-issues_mentioned_but_not_closing' into 'master'
pass in current_user in MergeRequest and MergeRequestsHelper

See merge request !8624
2017-02-08 12:35:04 +00:00
Douwe Maan 9d7c5e7584 Address feedback 2017-02-06 18:06:46 -06:00
Douwe Maan c8b63a28af Improve performance of finding last deployed environment 2017-02-06 16:12:24 -06:00
Douwe Maan 27f2ca9418 Add 'View on [env]' link to blobs and individual files in diffs 2017-02-06 16:12:23 -06:00
Dongqing Hu bbbef273f7 Remove MergeRequest#closes_issue?; Remove the default parameter value for #cache_merge_request_closes_issues! and #issues_mentioned_but_not_closing 2017-01-31 22:42:54 +08:00
Oswaldo Ferreira 0e14a2f21d Add commment to Issue, Project and MergeRequest #to_reference 2017-01-27 20:20:18 -02:00
Oswaldo Ferreira 660a755cad Change argument name assuming its always a Project 2017-01-27 20:20:18 -02:00
Sean McGivern 448321a46e Merge branch 'fix_broken_diff_discussions' into 'master'
Make diff discussions more reliable

Closes #23646

See merge request !8378
2017-01-25 09:54:34 +00:00
Sean McGivern d3f26be6f0 Merge branch '23524-notify-automerge-user-of-failed-build' into 'master'
Notify the user who set auto-merge when merge is not possible

Closes #23524

See merge request !8056
2017-01-19 11:05:38 +00:00
Dongqing Hu d0db72983e use the current_user parameter in MergeRequest#issues_mentioned_but_not_closing 2017-01-18 17:06:19 +08:00
twonegatives 85e0b99471 Notify the user who set auto-merge when merge conflict occurs 2017-01-14 12:22:30 +03:00
Jarka Kadlecova 7ab3dd4b30 support `/merge` slash comand for MRs 2017-01-11 08:48:07 -05:00
Mike Greiling ba5ba96f2b prevent 500 error when selecting changes tab for non-existent branch 2017-01-03 13:08:52 -06:00
James Lopez 112f470572 Fix cross-project references copy to include the project reference
Also added relevant specs and refactored to_references in a bunch of places to be more consistent.
2017-01-03 13:01:46 +01:00
Valery Sizov 95047f1dc7 Make diff discussion more reliable 2016-12-30 17:42:27 +02:00
Gabriel Gizotti 38dd9b545c use MergeRequest#closes_issues instead of rewriting code to retrieve closing issues on MergeRequest#issues_mentioned_but_not_closing 2016-12-28 23:22:31 +10:00
Sean McGivern ed6900caf1 Use raw_diffs to calculate MR files changed
We don't need to create the intermediate FileCollection object with its
associated highlighting in order to count how many files changed. Both
the compare object and the MR diff object have a raw_diffs method that
is perfectly fine for this case.
2016-12-26 14:27:20 +00:00
Rémy Coutable 8c8c4f8c5a Merge branch 'fix/import-export-mr-error' into 'master'
Fix import/export merge requests error

When MWBS is set and the MR exported/imported an error gets thrown. We should ignore this so it can succeed as the merge user may no longer exist in the target instance.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/24009 and https://gitlab.com/gitlab-com/support-forum/issues/1345

See merge request !8134
2016-12-19 18:03:06 +00:00
James Lopez 0631c7bcdc Fix MR issue to do with merge user 2016-12-19 16:52:38 +01:00
Gabriel Gizotti 3e3d6b53dc Change closes issues reference text on MergeRequest#merge_commit_message to match existing text generated by the system 2016-12-16 19:15:07 +10:00
Gabriel Gizotti 7d7ae494d4 add guard clause to MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 603ef5d49e Show either description or closes issues references on MergeRequest#merge_commit_message so closes issues references are not duplicated 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 4181528569 Better `Closes issues` text for MergeRequest#merge_commit_message 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 58609f842e backend completely drives creation of merge commit message 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 512c870ed4 Remove unnecessary code from MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti b4764a8dd2 shorter lines on MergeRequest#merge_commit_message 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 0e76daf3da only look for issues mentioned on description on MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti 1a8f43ff3e introduce MergeRequest#issues_mentioned_but_not_closing 2016-12-16 19:13:17 +10:00
Gabriel Gizotti e52e3ab508 Remove whole description from #merge_commit_message and add add closed issues 2016-12-16 19:13:17 +10:00
Douwe Maan 12db4cc0e7 Merge branch 'jej-note-search-uses-finder' into 'security'
Fix missing Note access checks in by moving Note#search to updated NoteFinder

Split from !2024 to partially solve https://gitlab.com/gitlab-org/gitlab-ce/issues/23867

## Which fixes are in this MR?

⚠️ - Potentially untested  
💣 - No test coverage  
🚥 - Test coverage of some sort exists (a test failed when error raised)  
🚦 - Test coverage of return value (a test failed when nil used)  
 - Permissions check tested

### Note lookup without access check

- [x]  app/finders/notes_finder.rb:13 :download_code check
- [x]  app/finders/notes_finder.rb:19 `SnippetsFinder`
- [x]  app/models/note.rb:121 [`Issue#visible_to_user`]
- [x]  lib/gitlab/project_search_results.rb:113
  - This is the only use of `app/models/note.rb:121` above, but importantly has no access checks at all. This means it leaks MR comments and snippets when those features are `team-only` in addition to the issue comments which would be fixed by `app/models/note.rb:121`.
  - It is only called from SearchController where `can?(current_user, :download_code, @project)` is checked, so commit comments are not leaked.

### Previous discussions
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b915c5267a63628b0bafd23d37792ae73ceae272_13_13 `: download_code` check on commit
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#b915c5267a63628b0bafd23d37792ae73ceae272_19_19 `SnippetsFinder` should be used
  - `SnippetsFinder` should check if the snippets feature is enabled -> https://gitlab.com/gitlab-org/gitlab-ce/issues/25223

###  Acceptance criteria met?
- [x] Tests added for new code
- [x] TODO comments removed
- [x] Squashed and removed skipped tests
- [x] Changelog entry
- [ ] State Gitlab versions affected and issue severity in description
- [ ] Create technical debt issue for NotesFinder.
  - Either split into `NotesFinder::ForTarget` and `NotesFinder::Search` or consider object per notable type such as `NotesFinder::OnIssue`. For the first option could create `NotesFinder::Base` which is either inherited from or which can be included in the other two.
  - Avoid case statement anti-pattern in this finder with use of `NotesFinder::OnCommit` etc. Consider something on the finder for this? `Model.finder(user, project)`
  - Move `inc_author` to the controller, and implement `related_notes` to replace `non_diff_notes`/`mr_and_commit_notes`

See merge request !2035
2016-12-15 11:40:12 -03:00
Adam Niedzielski 9190cea215 Do not reload diff for merge request made from fork when target branch in fork is updated
The target branch of a merge request has to be a branch in the project
for which the merge request is submitted. When a branch changes in a fork,
it does not make sense to reload diffs of merge requests in the upstream
project that use the same branch name as the target branch.
Please note that it does make sense to reload diffs when the source branch
changes.
2016-12-09 12:10:26 +01:00
Douwe Maan f23b1cb453 Merge branch 'jej-23867-use-mr-finder-instead-of-access-check' into 'security'
Replace MR access checks with use of MergeRequestsFinder

Split from !2024 to partially solve https://gitlab.com/gitlab-org/gitlab-ce/issues/23867

⚠️ - Potentially untested
💣 - No test coverage
🚥 - Test coverage of some sort exists (a test failed when error raised)
🚦 - Test coverage of return value (a test failed when nil used)
 - Permissions check tested

- [x] 💣  app/finders/notes_finder.rb:17
- [x] ⚠️  app/views/layouts/nav/_project.html.haml:80 [`.count`]
- [x] 💣  app/controllers/concerns/creates_commit.rb:84
- [x] 🚥  app/controllers/projects/commits_controller.rb:24
- [x] 🚥  app/controllers/projects/compare_controller.rb:56
- [x] 🚦  app/controllers/projects/discussions_controller.rb:29
- [x]   app/controllers/projects/todos_controller.rb:27
- [x] 🚦  app/models/commit.rb:268
- [x]  lib/gitlab/search_results.rb:71

- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#d1c10892daedb4d4dd3d4b12b6d071091eea83df_267_266 Memoize ` merged_merge_request(current_user)`
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#d1c10892daedb4d4dd3d4b12b6d071091eea83df_248_247 Expected side effect for `merged_merge_request!`, consider `skip_authorization: true`.
- [x] https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2024/diffs#d1c10892daedb4d4dd3d4b12b6d071091eea83df_269_269 Scary use  of unchecked `merged_merge_request?`

See merge request !2033
2016-12-08 21:42:07 -03:00
Sean McGivern d9ef41cf4d Merge branch '23589-open-issue-for-mr' into 'master'
Create an issue for all unresolved discussions in an MR

See merge request !7180
2016-12-06 14:04:14 +00:00
Bob Van Landuyt 1123057ab7 Feature: delegate all open discussions to Issue
When a merge request can only be merged when all discussions are
resolved. This feature allows to easily delegate those discussions to a
new issue, while marking them as resolved in the merge request.

The user is presented with a new issue, prepared with mentions of all
unresolved discussions, including the first unresolved note of the
discussion, time and link to the note.

When the issue is created, the discussions in the merge request will get
a system note directing the user to the newly created issue.
2016-12-05 20:55:45 +01:00
Oswaldo Ferreira f272ee6eba Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
Adam Niedzielski cb6f8cdfc2 Replace references to MergeRequestDiff#commits with st_commits
when we care only about the number of commits

We do not have to instantiate all objects in this case.
2016-12-01 12:17:30 +01:00
Grzegorz Bizon a49e9949c6 Rename `MergeRequest#pipeline` to `head_pipeline` 2016-11-29 14:12:49 +01:00
Adam Niedzielski d9a2093e7e Prevent error when submitting a merge request and pipeline is not defined 2016-11-28 12:03:59 +01:00
Douwe Maan d8f7523368 Merge branch 'events-cache-invalidation' into 'master'
Remove caching of events data

This MR removes the caching of events data as this was deemed unnecessary while increasing load on the database. See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6578#note_18864037 and 5371da341e for more information.

See merge request !6578
2016-11-28 03:34:12 +00:00
Yorick Peterse 5371da341e
Remove event caching code
Flushing the events cache worked by updating a recent number of rows in
the "events" table. This has the result that on PostgreSQL a lot of dead
tuples are produced on a regular basis. This in turn means that
PostgreSQL will spend considerable amounts of time vacuuming this table.
This in turn can lead to an increase of database load.

For GitLab.com we measured the impact of not using events caching and
found no measurable increase in response timings. Meanwhile not flushing
the events cache lead to the "events" table having no more dead tuples
as now rows are only inserted into this table.

As a result of this we are hereby removing events caching as it does not
appear to help and only increases database load.

For more information see the following comment:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6578#note_18864037
2016-11-23 14:17:07 +01:00
Douwe Maan f2a0c6f6bf Correctly determine mergeability of MR with no discussions 2016-11-23 20:02:14 +08:00
Rémy Coutable 1a5eedf3fe
Fix a wrong "The build for this merge request failed" message
Also allow merge request to be merged with skipped pipeline and the
"only allow merge when pipeline is green" feature enabled

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-21 14:22:28 +01:00
Grzegorz Bizon 5328e3b127 Make commit an optional arg for environments search 2016-11-09 14:46:36 +01:00
Rodolfo Santos 1db9f826c1 Add setting to only allow merge requests to be merged when all discussions are resolved
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-04 14:58:40 +01:00
Rémy Coutable 46689162a3 Ensure merge request's "remove branch" accessors return booleans
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-03 18:29:00 +01:00
Guilherme Salazar 32913b74b8 add "x of y tasks completed" on issuable
fix issues pointed out in !6527

add task completion status feature to CHANGELOG
2016-10-28 14:01:36 -02:00
David Wagner 03b6108f6f Remove redundant class_name and foreign_key overrides
They were Rails' default and are unnecessarily overridden.

Signed-off-by: David Wagner <david@marvid.fr>
2016-10-24 22:29:48 +02:00
Nick Thomas 61536ed2cf Rename forked_source_project_missing? to source_project_missing? 2016-10-20 12:24:27 +01:00
Nick Thomas 374071321d Fix the merge request view when source projects or branches are removed 2016-10-20 12:24:27 +01:00
Nick Thomas e6f515ecbe Revert "Add #closed_without_source_project?"
This reverts commit 31c37c6c38.

See #23341
2016-10-20 01:31:54 +01:00
Douglas Barbosa Alexandre fc2c64fcdf Add self.project_foreign_key on both Issue and MergeRequest 2016-10-19 14:58:28 -02:00
Grzegorz Bizon 72d84e4851 Improve code that creates a list of commits for MR 2016-10-18 08:32:17 -05:00
Grzegorz Bizon ab8ef17fb2 Extend merge request tests for all commits method 2016-10-18 08:32:17 -05:00
Grzegorz Bizon d5b1d0ea50 Use temporary compare commits when MR not persisted 2016-10-18 08:32:17 -05:00
Sean McGivern 86dcb79be3 Merge branch 'master' into merge-conflicts-editor-2 2016-10-17 10:56:55 +01:00
Z.J. van de Weg fa58068b28 Refactor ci_status on MergeRequestController 2016-10-14 11:07:01 +02:00
Z.J. van de Weg 8a1064d762 Fix indenting error in HAML 2016-10-14 11:07:00 +02:00
Z.J. van de Weg 6a4f710083 Show what time ago a MR was deployed 2016-10-14 11:07:00 +02:00
Sean McGivern 3f71c43e88 Allow setting content for resolutions
When reading conflicts:

1. Add a `type` field. `text` works as before, and has `sections`;
   `text-editor` is a file with ambiguous conflict markers that can only
   be resolved in an editor.
2. Add a `content_path` field pointing to a JSON representation of the
   file's content for a single file.
3. Hitting `content_path` returns a similar datastructure to the `file`,
   but without the `content_path` and `sections` fields, and with a
   `content` field containing the full contents of the file (with
   conflict markers).

When writing conflicts:

1. Instead of `sections` being at the top level, they are now in a
   `files` array. This matches the read format better.
2. The `files` array contains file hashes, each of which must contain:
   a. `new_path`
   b. `old_path`
   c. EITHER `sections` (which works as before) or `content` (with the
      full content of the resolved file).
2016-10-13 14:16:34 -05:00
Paco Guzman ca3c0c6cd9 MergeRequest new form load diff asynchronously 2016-10-06 11:19:14 +02:00
Felipe Artur 45bfadbcbf Fix bug when trying to cache closed issues from external issue trackers 2016-10-03 19:58:49 -03:00
Thomas Balthazar ddbe676dc3 Add a /wip slash command
It toggles the 'WIP' prefix in the MR title.
2016-10-03 09:36:21 +02:00
Robert Speicher b007bd8101 Improve how MergeCommit#merge_commit_message builds the message
Now a merge request with a blank description will no longer produce a
merge commit message like this:

```
Merge branch 'foo' into 'master'

Bring the wonders of foo into the world

See merge request !7283
```

What an improvement! 🎉
2016-09-27 14:04:41 +02:00
Rémy Coutable 529b17d11c Merge branch 'show-all-pipelines-from-all-diffs' into 'master'
Show all pipelines from all merge_request_diffs

This way we could also show pipelines from commits which
were discarded due to a force push.

Closes #21889

See merge request !6414
2016-09-21 13:15:41 +00:00
Kamil Trzcinski 955b9347a4 Add tests to verify the correctness of returned environments 2016-09-21 12:08:11 +02:00
Kamil Trzcinski d891051cd2 Limit number of shown environments for Merge Requests
- For target project show only environments for target branch or with tags
- For source project show only environments for source branch
2016-09-21 10:23:16 +02:00
Timothy Andrew 68e1b5bbc0 Use the `IssuableBaseService` lifecycle hooks to cache `MergeRequestsClosingIssues`
- Instead of overriding `create` and `update` in `MergeRequests::BaseService`
- Get all merge request service specs passing
2016-09-21 01:22:20 +05:30
Timothy Andrew 918e589c2b Implement a second round of review comments from @DouweM.
- Don't use `TableReferences` - using `.arel_table` is shorter!
- Move some database-related code to `Gitlab::Database`
- Remove the `MergeRequest#issues_closed` and
  `Issue#closed_by_merge_requests`  associations. They were either
  shadowing or were too similar to existing methods. They are not being
  used anywhere, so it's better to remove them to reduce confusion.
- Use Rails 3-style validations
- Index for `MergeRequest::Metrics#first_deployed_to_production_at`
- Only include `CycleAnalyticsHelpers::TestGeneration` for specs that
  need it.
- Other minor refactorings.
2016-09-21 00:47:37 +05:30
Timothy Andrew 71d4bf721b Implement (some) comments from @DouweM's review.
- Move things common to `Issue` and `MergeRequest` into `Issuable`
- Move more database-specific functions into `Gitlab::Database`
- Indentation changes and other minor refactorings.
2016-09-20 18:13:11 +05:30
Lin Jen-Shin 3ae99b2c9f If merge request wasn't persisted yet, we show only 1 pipeline:
However, if MergeRequest#all_commits_sha would want to handle
non-persisted merge request, by judging its name, it should not
just give 1 SHA, but all of them.

But we don't really care all_commits_sha for non-persisted merge
request anyway. So I think we should just ignore that case.

Better to not implementing something than implementing it in a
wrong and confusing way.
2016-09-20 20:29:07 +08:00
Timothy Andrew e109166db2 Fix spec failures. 2016-09-20 16:53:12 +05:30
Lin Jen-Shin f2eb10c9bc slightly tweak about the comment, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6414#note_15750250
2016-09-20 19:18:48 +08:00
Timothy Andrew 8957293d9b Implement review comments from @yorickpeterse
1. Change multiple updates to a single `update_all`

2. Use cascading deletes

3. Extract an average function for the database median.

4. Move database median to `lib/gitlab/database`

5. Use `delete_all` instead of `destroy_all`

6. Minor refactoring
2016-09-20 16:05:25 +05:30
Lin Jen-Shin 307be4b521 Introduce MergeRequest#all_commits_sha, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6414#note_15746083
2016-09-20 17:36:21 +08:00
Timothy Andrew fa890604aa Merge remote-tracking branch 'origin/master' into 21170-cycle-analytics 2016-09-20 14:48:13 +05:30
Lin Jen-Shin e0f596c99d Show all pipelines from all merge_request_diffs:
This way we could also show pipelines from commits which
were discarded due to a force push.
2016-09-19 23:51:27 +08:00
Timothy Andrew 8f6208513a Test all cycle analytics pre-calculation code.
All the code that pre-calculates metrics for use in the cycle analytics
page.

- Ci::Pipeline -> build start/finish
- Ci::Pipeline#merge_requests
- Issue -> record default metrics after save
- MergeRequest -> record default metrics after save
- Deployment -> Update "first_deployed_to_production_at" for MR metrics
- Git Push -> Update "first commit mention" for issue metrics
- Merge request create/update/refresh -> Update "merge requests closing issues"
2016-09-19 13:12:06 +05:30
Rémy Coutable 73269b587c
MergeRequest#environments now returns an empty array when diff_head_commit is nil
Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-09-16 10:16:21 +02:00
Timothy Andrew ba25e2f1ac Improve performance of the cycle analytics page.
1. These changes bring down page load time for 100 issues from more than
   a minute to about 1.5 seconds.

2. This entire commit is composed of these types of performance
   enhancements:

     - Cache relevant data in `IssueMetrics` wherever possible.
     - Cache relevant data in `MergeRequestMetrics` wherever possible.
     - Preload metrics

3. Given these improvements, we now only need to make 4 SQL calls:

    - Load all issues
    - Load all merge requests
    - Load all metrics for the issues
    - Load all metrics for the merge requests

4. A list of all the data points that are now being pre-calculated:

    a. The first time an issue is mentioned in a commit

      - In `GitPushService`, find all issues mentioned by the given commit
        using `ReferenceExtractor`. Set the `first_mentioned_in_commit_at`
        flag for each of them.

      - There seems to be a (pre-existing) bug here - files (and
        therefore commits) created using the Web CI don't have
        cross-references created, and issues are not closed even when
        the commit title is "Fixes #xx".

    b. The first time a merge request is deployed to production

      When a `Deployment` is created, find all merge requests that
      were merged in before the deployment, and set the
      `first_deployed_to_production_at` flag for each of them.

    c. The start / end time for a merge request pipeline

      Hook into the `Pipeline` state machine. When the `status` moves to
      `running`, find the merge requests whose tip commit matches the
      pipeline, and record the `latest_build_started_at` time for each
      of them. When the `status` moves to `success`, record the
      `latest_build_finished_at` time.

    d. The merge requests that close an issue

      - This was a big cause of the performance problems we were having
        with Cycle Analytics. We need to use `ReferenceExtractor` to make
        this calculation, which is slow when we have to run it on a large
        number of merge requests.

      - When a merge request is created, updated, or refreshed, find the
        issues it closes, and create an instance of
        `MergeRequestsClosingIssues`, which acts as a join model between
        merge requests and issues.

      - If a `MergeRequestsClosingIssues` instance links a merge request
        and an issue, that issue closes that merge request.

5. The `Queries` module was changed into a class, so we can cache the
   results of `issues` and `merge_requests_closing_issues` across
   various cycle analytics stages.

6. The code added in this commit is untested. Tests will be added in the
   next commit.
2016-09-15 14:53:02 +05:30
Katarzyna Kobierska 66e92895e3 Change method name to #reopenable? 2016-09-13 14:40:05 +02:00
Katarzyna Kobierska 34c146a17d Add #can_reopen? and tests 2016-09-13 14:40:05 +02:00
Katarzyna Kobierska 554baec9e8 Add method 2016-09-13 14:40:05 +02:00