Commit Graph

258 Commits

Author SHA1 Message Date
Stan Hu 89fa253864 Speed up merge request loads by disabling BatchLoader replace_methods
In production, we've seen the rendering times of the merge request
widget increase as a result of loading commit data. BatchLoader attempts
to call replace_methods on the lazy object, but this has a significant
performance penalty for modules that have many methods. Disabling this
mode (https://github.com/exAspArk/batch-loader/pull/45) appears to cut
load times by about 50% for MergeRequestsController#show.

Relates to https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/6941
2019-06-13 13:56:54 -07:00
Patrick Bajao 2eecfd8f9d Use Redis for CacheMarkDownField on non AR models
This allows using `CacheMarkdownField` for models that are not backed
by ActiveRecord.

When the including class inherits `ActiveRecord::Base` we include
`Gitlab::MarkdownCache::ActiveRecord::Extension`. This will cause the
markdown fields to be rendered and the generated HTML stored in a
`<field>_html` attribute on the record. We also store the version
used for generating the markdown.

All other classes that include this model will include the
`Gitlab::MarkdownCache::Redis::Extension`. This add the `<field>_html`
attributes to that model and will generate the html in them. The
generated HTML will be cached in redis under the key
`markdown_cache:<class>:<id>`. The class this included in must
therefore respond to `id`.
2019-06-05 13:19:59 +08:00
Luke Duncalfe 2b7dd017af Allow custom squash commit messages 2019-02-06 12:33:11 +00:00
Kamil Trzciński d4c7214799
[master] Pipelines section is available to unauthorized users 2019-01-31 16:52:50 +01:00
Francisco Javier López e9b5b10a45 Skip per-commit validations which have already passed on another change/branch 2018-12-28 10:44:25 +00:00
Stan Hu 7d18c4d236 Truncate merge request titles with periods instead of ellipsis
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/54862
2018-12-06 21:51:51 -08:00
Francisco Javier López a6778fc647 Rename project's pipelines relation 2018-12-05 14:39:15 +00:00
Nick Thomas 59c4fb4ecb
Match users better by their private commit email
Private commit emails were introduced in !22560, but some parts of
GitLab were not updated to take account of them. This commit adds
support in places that were missed.
2018-11-19 12:45:07 +00:00
Tiago Botelho c239452b47
User can keep their commit email private
The private commit email is automatically generated in the format:
id-username@noreply.HOSTNAME

GitLab instance admins are able to change the HOSTNAME portion,
that defaults to Gitlab's hostname, to whatever they prefer.
2018-11-07 12:24:14 +00:00
Paul Slaughter becb86ea4e Add pipeline status to diffs/commit_item
**Notes:**
- Also exposes commit.pipeline_status_path in diffs.json
2018-10-03 13:18:21 -05:00
Nick Thomas eea1b88547
Properly fix an introduced N+1 SQL issue loading commit authors 2018-09-06 16:04:21 +01:00
Nick Thomas d9833890cc
Bulk-render commit titles in the tree view to improve performance 2018-09-06 12:28:56 +01:00
Sean McGivern 5759bfe029 Make it clearer when Commit#description returns no_commit_message 2018-08-21 11:41:25 +01:00
yisiliang f5e6c44741 use #blank? instead #nil? 2018-08-21 10:41:47 +01:00
yisiliang b84fed0f9e to avoid “NoMethodError (undefined method `split' for nil:NilClass)” while safe_message is nil. 2018-08-21 10:41:47 +01:00
Peter Leitzen 2022243a22 Create empty Commits::UpdateService and wire it up 2018-08-10 16:45:11 +02:00
gfyoung 50abbd3e53 Enable frozen string in app/models/*.rb
Partially addresses #47424.
2018-07-26 16:55:41 -07:00
Yorick Peterse 19428e8008
Preload pipeline data for project pipelines
When displaying the pipelines of a project we now preload the following
data:

1. Authors of the commits that belong to these pipelines
2. The number of warnings per pipeline, which is used by
   Ci::Pipeline#has_warnings?

== Commit Authors

Previously this data was queried for every Commit separately, leading to
20 SQL queries being executed in the worst case. With an average of 3 to
5 milliseconds per SQL query this could result in 100 milliseconds being
spent in _just_ getting Commit authors.

To preload this data Commit#author now uses BatchLoader (through
Commit#lazy_author), and a separate module
Gitlab::Ci::Pipeline::Preloader is used to ensure all authors are loaded
before they are used.

== Number of warnings

This changes Ci::Pipeline#has_warnings? so it supports preloading of the
number of warnings per pipeline. This removes the need for executing a
COUNT(*) query for every pipeline just to see if it has any warnings or
not.
2018-05-17 13:53:00 +02:00
Rémy Coutable da50984bde Merge branch 'blackst0ne-rails5-add-touch-later-to-commit-model' into 'master'
[Rails5] Add `touch_later` to `Commit` model

See merge request gitlab-org/gitlab-ce!18642
2018-05-02 08:03:10 +00:00
Jan Provaznik 7a76caa5a8 Merge request and commit discussions API 2018-05-01 12:39:44 +00:00
blackst0ne 68c75bc0f9 [Rails5] Add `touch_later` to `Commit` model
This commit fixes errors like:

```
1) API::Todos GET /todos when unauthenticated returns authentication error
    Failure/Error: @raw.__send__(method, *args, &block) # rubocop:disable GitlabSecurity/PublicSend

    NoMethodError:
      undefined method `touch_later' for #<Gitlab::Git::Commit:0x00005573f5196270>
    # ./app/models/commit.rb:259:in `method_missing'
    # ./spec/requests/api/todos_spec.rb:12:in `block (2 levels) in <top (required)>'
```
2018-04-29 17:23:59 +11:00
Stan Hu 775211bc70 Fix N+1 queries when loading participants for a commit note
We saw about 10,000 SQL queries for some commits in the NewNoteWorker,
which stalled the Sidekiq queue for other new notes. The notification
service took up to 8 minutes to process the commits. Avoiding this
N+1 query brings the time down significantly.

Closes #45526
2018-04-18 22:04:22 -07:00
Oswaldo Ferreira 4dd1f906fd Add support for patch link extension for commit links on GFM 2018-04-06 12:53:14 -03:00
Omar Mekky a069aa494a Add banzai filter to detect commit message trailers and properly link the users 2018-04-04 15:04:03 +00:00
YarNayar 99b01e2359 Send notification emails when push to a merge request
Closes #23460
2018-03-26 13:24:52 +01:00
Zeger-Jan van de Weg 1e08d00032
Lazy fetch parent commits for a commit 2018-03-06 14:32:53 +01:00
Ahmad Sherif 03f3350f3f Fetch commit signatures from Gitaly in batches
Closes gitaly#1046
2018-03-01 18:31:31 +01:00
Micaël Bergeron eef63813ea stop ProcessCommitWorker from processing MR merge commit
When a merge request is merged, it creates a commit with the
description of the MR, which may contain references and issue
closing references. As this will be handled in the PostMergeService
anyways, let's ignore merge commit generated from a MR.
2018-02-16 13:51:19 -05:00
Jarka Kadlecová b0b4ae1875 API - Include project in commits&blobs search results 2018-02-14 09:00:26 +01:00
Ahmad Sherif f32f04a50f Migrate Commit#uri_type to Gitaly
Closes gitaly#915
2018-01-15 14:16:22 +01:00
Hiroyuki Sato a7d26f00c3 Display related merge requests in commit detail page 2018-01-12 20:38:36 +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
Jacob Vosmaer ac2cb65ab3 Remove the Commit#tree method 2018-01-04 18:00:28 +01:00
Zeger-Jan van de Weg c6edae3887
Load commit in batches for pipelines#index
Uses `list_commits_by_oid` on the CommitService, to request the needed
commits for pipelines. These commits are needed to display the user that
created the commit and the commit title.

This includes fixes for tests failing that depended on the commit
being `nil`. However, now these are batch loaded, this doesn't happen
anymore and the commits are an instance of BatchLoader.
2017-12-19 10:05:40 +01:00
Jacopo 55f322085d Adds ordering to projects contributors in API
Allows ordering in GET api/v4/projects/:project_id/repository/contributors
through `order_by` and `sort` params.
The available `order_by` options are: name|email|commits.
The available `sort` options are: asc|desc.
2017-12-13 18:02:20 +01:00
micael.bergeron cb6f51ec9b add support for the commit reference filter 2017-12-07 09:01:37 -05:00
Jarka Kadlecova e826c5d091 Fix link text from group context 2017-11-23 12:59:14 +01:00
Zeger-Jan van de Weg f9565e3039
Batchload blobs for diff generation
After installing a new gem, batch-loader, a construct can be used to
queue data to be fetched in bulk. The gem was also introduced in both
gitlab-org/gitlab-ce!14680 and gitlab-org/gitlab-ce!14846, but those mrs
are not merged yet.

For the generation of diffs, both the old blob and the new blob need to
be loaded. This for every file in the diff, too. Now we collect all
these so we do 1 fetch. Three `.allow_n_plus_1_calls` have been removed,
which I expect to be valid, but this needs to be confirmed by a full CI
run.

Possibly closes:
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37445
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37599
- https://gitlab.com/gitlab-org/gitlab-ce/issues/37431
2017-11-21 13:53:26 +01:00
Yorick Peterse ab16a6fb34
Optimise getting the pipeline status of commits
This adds an optimised way of getting the latest pipeline status for a
list of Commit objects (or just a single one).
2017-11-16 16:01:14 +01:00
Douwe Maan 19a30595d9 Remove unnecessary comments 2017-09-25 10:23:43 +02:00
Douwe Maan b9857d8b66 Properly compare diff refs and diff positions when shas are truncated 2017-09-25 10:22:28 +02:00
Tiago Botelho 6d8e102c74 Adds cacheless render to Banzai object render 2017-09-06 15:35:35 +01:00
Alexis Reigel 508ff17b34 pass whole commit to Gitlab::Gpg::Commit again
we need the commit object for the updated verification that also checks
the committer's email to match the gpg key and user's emails.
2017-09-05 12:18:31 +02:00
Sean McGivern 096850a49a Merge branch 'sm-cherry-pick-list-commits-in-message' into 'master'
Add 'from commit' information to cherry-picked commits

See merge request !13475
2017-09-01 10:24:29 +00:00
Saverio Miroddi 83417865d0 Change a variable name in Commit#cherry_pick_description 2017-08-21 20:50:48 +02:00
Saverio Miroddi 9ec358af7b Reverse order of commits in MR cherry-pick message
Also improved the UT for better documenting this change.
2017-08-21 20:47:18 +02:00
Saverio Miroddi c0f921606c Correct the cherry-pick message for merge commits
The list of commits must be generated from the merge request,
not from a diff of the branches.
2017-08-17 22:38:47 +02:00
Robert Speicher ec34b2d051 Merge branch 'dm-gpg-signature-performance' into 'master'
Only create commit GPG signature when necessary

See merge request !13561
2017-08-16 18:34:55 +00:00
Douwe Maan ba7251fefd Only create commit GPG signature when necessary 2017-08-16 18:57:50 +02:00
Saverio Miroddi 85aeb88438 Add support for start project to commit cherry-pick description 2017-08-15 21:17:52 +02:00