Commit Graph

291 Commits

Author SHA1 Message Date
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
Saverio Miroddi e33608d8e4 Made commit cherry-pick message more standard
Follow the `cherry pick -x` format for the first line, and the
interactive rebase format for the commits in the merge, in case
of merge commit
2017-08-15 19:57:40 +02:00
Saverio Miroddi 3d7febc01c Extracted cherry-pick description in ::Commit
This also fixes the inconsistency between non/merge commits in the number of newlines introduced.
2017-08-15 19:35:28 +02:00
Robert Speicher 260c8da060 Whitelist or fix additional `Gitlab/PublicSend` cop violations
An upcoming update to rubocop-gitlab-security added additional
violations.
2017-08-14 12:14:11 -04:00
Saverio Miroddi 1d6ba59702 Add 'from commit' information to cherry-picked commits
Store the original commit in the commit message. In case of
merge commit, the commits added to the start branch are also
listed.
2017-08-10 21:18:22 +02:00
Alejandro Rodríguez e363fbf71a Move `deltas` and `diff_from_parents` logic to Gitlab::Git::Commit
This helps keep the abstraction layers simpler, and also keep the
interface of those methods consistent, in case of implementation
changes.
2017-08-07 23:33:40 -04:00
Alejandro Rodríguez c21ae07e33 Refactor Gitlab::Git::Commit to include a repository 2017-08-07 22:34:34 -04:00
Alexis Reigel eda001565c fetch gpg signature badges by ajax 2017-07-27 15:46:03 +02:00
Alexis Reigel 34810acd6c move signature cache read to Gpg::Commit
as we write the cache in the gpg commit class already the read should
also happen there.

This also removes all logic from the main commit class, which just
proxies the call to the Gpg::Commit now.
2017-07-27 15:42:53 +02:00
Alexis Reigel 8c4b6a32fc bail if the commit has no signature 2017-07-27 15:42:53 +02:00
Alexis Reigel 69e511c4c2 cache the gpg commit signature
we store the result of the gpg commit verification in the db because the
gpg verification is an expensive operation.
2017-07-27 15:42:53 +02:00
Alexis Reigel 2f956fae03 verify gpg commit using tmp keyring and db query 2017-07-27 15:42:53 +02:00
Alexis Reigel d1101ec02e use more descriptive variable names 2017-07-27 15:42:04 +02:00
Alexis Reigel 28bb5e3d53 commit signature with spec 2017-07-27 15:40:40 +02:00
Kevin O'Connor 817d9558fe Prototype key verification 2017-07-27 15:40:40 +02:00
Rémy Coutable f3e682c03f Merge branch 'request-store-wrap' into 'master'
Add RequestCache to cache via RequestStore

See merge request !12920
2017-07-18 12:09:47 +00:00
Lin Jen-Shin 3922b80329 Rename the methods to make it fit with current name 2017-07-18 18:04:20 +08:00
Lin Jen-Shin ffc5b29bd0 Follow feedback on the merge request 2017-07-18 17:48:48 +08:00
Andrew Newdigate a89f18bf2c Renamed Gitaly services 2017-07-18 07:59:36 +00:00
Lin Jen-Shin aada5273fa Use RequestStoreWrap for Commit#author
We also try to use instance variable to cache the result if
RequestStore is not available, so we could keep the same logic,
using the same cache key. Also introduce a way to specify method
specific cache key
2017-07-18 01:18:20 +08: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
Dmitriy Zaporozhets 8ce11fc388 Merge branch '12614-fix-long-message' into 'master'
Fix long urls in the title of commit

Closes #12614

See merge request !10938
2017-06-08 10:32:45 +00:00
Ahmad Sherif 204db05637 Re-enable Gitaly commit_raw_diffs migration 2017-06-07 16:55:45 +02:00
Robert Speicher 993412f9de Merge branch 'fix/use-new-gitaly-commit-diff-rpc' into 'master'
Use the new Gitaly CommitDiff RPC

See merge request !11826
2017-06-02 19:39:02 +00:00
Robert Speicher 3cdac884c7 Merge branch 'rc/enable-PreferredHashMethods-cop' into 'master'
Enable the Style/PreferredHashMethods cop

See merge request !11883
2017-06-02 19:00:28 +00:00
Rémy Coutable 4cfa5ce4a9
Enable the Style/PreferredHashMethods cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 19:11:26 +02:00
Rémy Coutable 857d039145
Lint our factories creation in addition to their build
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-06-02 19:06:50 +02:00
Ahmad Sherif 4d1e987ec3 Use the new Gitaly CommitDiff RPC 2017-06-02 18:33:18 +02:00
Ahmad Sherif 99feed6e00 Add support for deltas_only under Gitaly
Closes gitaly#199
2017-05-13 18:27:06 +02:00
Alexander Randa fdba744986 Fix long urls in the title of commit 2017-05-12 11:45:26 +00:00
Jacob Vosmaer 27fb64d6a3 Remove deltas_only from DiffCollection 2017-05-11 16:01:10 +02:00
Rémy Coutable d40e1f547e Enable the Style/TrailingCommaInLiteral cop
Use the EnforcedStyleForMultiline: no_comma option.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-05-10 18:25:45 +02:00
Jacob Vosmaer 3107f2e460 Use Rails 'delegate' 2017-05-09 14:44:15 +02:00
Jacob Vosmaer f1a14d6857 Don't make Commit#raw_deltas private 2017-05-09 13:48:21 +02:00
Jacob Vosmaer 48254d187f Don't use DiffCollection for deltas 2017-05-09 12:27:17 +02:00
Ahmad Sherif 34cd109797 Re-enable Gitaly commit_raw_diff feature 2017-05-07 23:37:42 +02:00
Lin Jen-Shin 0a29bde4a1 Rename latest_pipeline to last_pipeline
As it might be confusing that it's not the same as
Pipeline#latest

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11038#note_28677090
2017-05-03 01:40:49 +08:00
Lin Jen-Shin e69a7b95df Always show latest pipeline info in commit box 2017-05-03 00:17:53 +08:00
Douwe Maan 7f625f06d3 Pass project to Blob 2017-04-27 12:23:26 -05:00
Alejandro Rodríguez d6cc8feb6c Setup and run a Gitaly server for testing if GitalyClient is enabled 2017-04-11 16:00:44 -03:00
Douwe Maan 08bbb9fce6
Add option to start a new discussion on an MR 2017-04-05 17:44:14 +01:00
Robert Speicher 5409a3c5b7 Merge branch 'feature/use-gitaly-for-commit-show' into 'master'
Use Gitaly for CommitController#show

See merge request !9629
2017-03-17 17:41:44 +00:00
Filipa Lacerda ec970763e9 Adds pipeline mini-graph to system information box in Commit View 2017-03-16 00:44:31 +00:00
Ahmad Sherif c0a4f527db Use Gitaly for CommitController#show 2017-03-15 12:52:11 +02:00
Douwe Maan bdbc7d967a Revert "Enable Style/BarePercentLiterals"
This reverts commit 96bef54154e669f9a3e92c3a4bc76c0be3a52e48.
2017-02-23 09:32:42 -06:00
Douwe Maan f74ca33a32 Enable Style/ClassCheck 2017-02-23 09:32:22 -06:00
Douwe Maan 5c7f9d69e3 Fix code for cops 2017-02-23 09:31:57 -06:00
Douwe Maan 8a4d68c53e Enable Style/ConditionalAssignment 2017-02-23 09:31:57 -06:00
Douwe Maan 7ea641b6d0 Enable Style/ColonMethodCall 2017-02-23 09:31:57 -06:00
Douwe Maan baafd8de26 Enable Style/BarePercentLiterals 2017-02-23 09:31:57 -06:00
Douwe Maan b7d8df503c Enable Style/MutableConstant 2017-02-23 09:31:56 -06:00
Oswaldo Ferreira 441501e4bf Present TODO's list without grouping by project 2017-01-27 20:20:18 -02:00
YarNayar dd3ddcd72b Allows to search within project by commit's hash
Was proposed in #24833
2017-01-24 14:56:00 +03:00
jurre e59623e738
Mark MR as WIP when pushing WIP commits 2017-01-19 12:30:34 +01:00
P.S.V.R 632d22acf7
Mark Commit persisted
Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-01-16 23:28:44 -05: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
Lin Jen-Shin 7cced60069 Introduce latest_status and add a few tests
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7333#note_20003268
2016-12-14 23:37:49 +08:00
Lin Jen-Shin 367024f170 Merge remote-tracking branch 'upstream/master' into show-commit-status-from-latest-pipeline
* upstream/master: (557 commits)
  Fix wrong error message expectation in API::Commits spec
  Move admin settings spinach feature to rspec
  Encode when migrating ProcessCommitWorker jobs
  Prevent overflow with vertical scroll when we have space to show content
  Make rubocop happy
  API: Ability to cherry-pick a commit
  Be smarter when finding a sudoed user in API::Helpers
  Backport hooks on group policies for the EE-specific implementation
  API: Ability to get group's project in simple representation
  Add AddLowerPathIndexToRoutes to setup_postgresql.rake
  For single line git commit messages, the close quote should be on the same line as the open quote
  added border-radius and padding to labels
  Allow all alphanumeric characters in file names (!8002)
  Add failing test for #20190
  Don't allow blank MR titles in API
  Replace static fixture for awards_handler_spec (!7661)
  Crontab typo '* */6' -> '0 */6' (4x/day not 1x-per-min-for-1h 4x/day)
  Fix test
  Tweak style and add back wording
  Clean up commit copy to clipboard and make consistent
  ...
2016-12-14 19:24:31 +08: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
Oswaldo Ferreira f272ee6eba Add shorthand support to gitlab markdown references 2016-12-02 19:18:17 -02:00
Yorick Peterse 6b4d33566f
Pass commit data to ProcessCommitWorker
By passing commit data to this worker we remove the need for querying
the Git repository for every job. This in turn reduces the time spent
processing each job.

The migration included migrates jobs from the old format to the new
format. For this to work properly it requires downtime as otherwise
workers may start producing errors until they're using a newer version
of the worker code.
2016-12-01 13:36:06 +01:00
Lin Jen-Shin 6192ea53fa Rename latest_for to latest, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7333/diffs#note_18819292
2016-11-24 16:50:37 +08:00
Lin Jen-Shin 721f2d3788 Still use compound pipeline status, but group by
ref and sha so that it would show latest pipeline
if ref and sha are both specified, otherwise still
the same as before.
2016-11-21 22:19:16 +08:00
Lin Jen-Shin 18a71c4760 Show commit status from latest pipeline
Rather than compound status from all pipelines.

Closes #20560
2016-11-08 00:04:18 +08:00
Lin Jen-Shin 0902ba524f Initialize @statuses in status rather than constructor
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17742312
2016-11-03 23:43:17 +08:00
Lin Jen-Shin 1ae557c106 Merge status_for and status, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17742297
2016-11-03 23:39:37 +08:00
Lin Jen-Shin f4b9de38ed It's not used as a public API right now, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17522443
2016-10-28 03:12:12 +08:00
Lin Jen-Shin b4ef158a63 Still show status from pipelines, see:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17397201
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17397461
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6801#note_17468470
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17482654
2016-10-27 00:58:40 +08:00