Commit Graph

5299 Commits

Author SHA1 Message Date
Robert Speicher dab5e045e0 Merge branch 'fix/remove-legacy-ci-static-model' into 'master'
Remove legacy Ci::StaticModel we do not use anymore

## What does this MR do?

This removes class that according to our code coverage report and
`grep` is a legacy and unused class.

See merge request !5710
2016-08-08 23:36:04 +00:00
Douwe Maan 37005ed8bd Merge branch 'zj-enable-deploy-keys-api' into 'master'
Enable/Disable Deploy keys for a project

Closes #20123 

## Does this MR meet the acceptance criteria?

- [X] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [X] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [X] API support added
- Tests
  - [X] Added for this feature/bug
  - [X] All builds are passing

See merge request !5647
2016-08-08 19:37:34 +00:00
Robert Speicher 86c081f71f Merge branch 'git-http-push-check' into 'master'
Stop 'git push' over HTTP early

Before this change we always let users push Git data over HTTP before
deciding whether to accept to push. This was different from pushing
over SSH where we terminate a 'git push' early if we already know the
user is not allowed to push.

This change let Git over HTTP follow the same behavior as Git over
SSH. We also distinguish between HTTP 404 and 403 responses when
denying Git requests, depending on whether the user is allowed to know
the project exists.


See merge request !5639
2016-08-08 19:23:31 +00:00
Z.J. van de Weg 7e47a82899 Namespace EnableDeployKeyService under Projects 2016-08-08 20:59:51 +02:00
Douwe Maan a77394a7e5 Merge branch 'rubocop/EmptyLinesAroundModuleBody' into 'master'
Enable Style/EmptyLinesAround Module/Class Body cop

## What does this MR do?
Enable a new rubocop cops as discussed here: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1877/diffs#note_13021078

## Are there points in the code the reviewer needs to double check?
May be a good idea to send a message to people to prevent `master` red because of the new cop.

## Why was this MR needed?
We want to improve code style and not waste endbosses time checking style manually

## What are the relevant issue numbers?

## Screenshots (if relevant)

## Does this MR meet the acceptance criteria?

- [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [ ] Added for this feature/bug
  - [ ] All builds are passing
- [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5692
2016-08-08 17:50:22 +00:00
Douwe Maan 15b1bf845b Merge branch 'revert-host-header-overwrite' into 'master'
Revert "Defend against 'Host' header injection"

We reverted this in omnibus but forgot to do it in the source NGINX template.

See merge request !5706
2016-08-08 17:47:05 +00:00
Douwe Maan d668b145a1 Merge branch 'rubocop/SpaceAroundEqualsInParameterDefault' into 'master'
Enable Style/SpaceAroundEqualsInParameterDefault cop

## What does this MR do?
Enable a new rubocop cops as discussed here: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/1877#note_13529646

## Are there points in the code the reviewer needs to double check?
May be a good idea to send a message to people to prevent master red because of the new cop.

## Why was this MR needed?
We want to improve code style and not waste endbosses time checking style manually

## What are the relevant issue numbers?

## Screenshots (if relevant)

## Does this MR meet the acceptance criteria?

- [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [ ] Added for this feature/bug
  - [ ] All builds are passing
- [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5693
2016-08-08 17:46:45 +00:00
Douwe Maan 8bce4a3fde Merge branch 'decode-log-postreceive-args' into 'master'
Log base64-decoded PostReceive arguments

The change to base64-encoding the third argument to PostReceive in
gitlab-shell made our Sidekiq ArgumentsLogger a little less useful.
This change adds decoded data to the log statement.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/20381


See merge request !5547
2016-08-08 17:39:48 +00:00
Rémy Coutable 59ce1af53b Merge branch 'fix/import-pending-user' into 'master'
Support pending invitation project members importing projects

Adds support for pending invitation project members on Import/Export - previously the import would fail.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/19973

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5683
2016-08-08 16:38:50 +00:00
James Lopez f04e9dad47 Support pending invitation project members importing projects 2016-08-08 17:25:17 +02:00
Dmitriy Zaporozhets 2836b47370 Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce 2016-08-08 18:15:41 +03:00
Grzegorz Bizon 74d12b6b47 Remove legacy Ci::StaticModel we do not use anymore 2016-08-08 14:22:26 +02:00
Jacob Vosmaer 427c9f0b5b Revert "Defend against 'Host' header injection"
This reverts commit 47b5b44139.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/17877#note_13488047
2016-08-08 13:02:44 +02:00
Gabriel Mazetto c9aa19881c Enable Style/SpaceAroundEqualsInParameterDefault cop 2016-08-06 04:03:01 +02:00
Gabriel Mazetto 5f6223cf9f Enable Style/EmptyLinesAroundClassBody cop 2016-08-06 03:52:24 +02:00
Gabriel Mazetto 2aa2f52191 Enable Style/EmptyLinesAroundModuleBody cop 2016-08-06 03:44:39 +02:00
Jacob Vosmaer c74005e75c Log base64-decoded PostReceive arguments
The change to base64-encoding the third argument to PostReceive in
gitlab-shell made our Sidekiq ArgumentsLogger a little less useful.
This change adds a log statement for the decoded data.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/20381
2016-08-05 15:00:12 +02:00
Z.J. van de Weg 554e18ab02 Create service for enabling deploy keys 2016-08-05 11:38:17 +02:00
Douwe Maan 71dec8b1b6 Merge branch '14898-protected-branches-developer-can-not-push-without-permission' into 'master'
Developer cannot push to protected branch when project is empty or he has not been granted permission to do so

This MR was created following !1979 and !1978

Closes #14898

See merge request !1980
2016-08-05 00:50:32 +00:00
winniehell b791dcc05b Ignore URLs starting with // (!5677) 2016-08-05 01:30:59 +02:00
tiagonbotelho 482d7802cc changes default_branch_protection to allow devs_can_merge protection option aswell 2016-08-04 21:15:26 +01:00
Z.J. van de Weg 460065b743 Move deploy_key tests to deploy_key_spec.rb
Also, fix the failing test in the process
2016-08-04 16:55:20 +02:00
Rémy Coutable 42373550b0 Merge branch 'master' of https://dev.gitlab.org/gitlab/gitlabhq 2016-08-04 16:41:20 +02:00
Rémy Coutable db69111a63 Merge branch '20512-fix-rename-add-users-into-project-to-add-users-to-project-and-projects-ids-to-project-ids' into 'master'
Fix Rename `add_users_into_project` and `projects_ids`

## What does this MR do?
Only modifies the name of a method that leaves more semantic and expressive and the name of the keywords arguments to the rails convention.

## Are there points in the code the reviewer needs to double check?
Only if it has been changed at every point that is calling this method and that passing arguments.

## Why was this MR needed?
To make the code more expressive.

## What are the relevant issue numbers?
Closes #20512.

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5659
2016-08-04 13:34:05 +00:00
Rémy Coutable d3c1e93d55 Merge branch '20527-fork-commits-have-impact-on-original-project' into 'master'
Don’t close issues on original project

Closes #20527 -> https://gitlab.com/gitlab-org/gitlab-ce/issues/20527

See merge request !1981
2016-08-04 13:06:38 +00:00
Rémy Coutable b2d142c4a0 Merge branch 'fix/ha-mode-import-issue' into 'master'
Fix Import/Export not working in HA mode

Use a shared path instead of `Tempfile` default `/tmp` so the import file is accessible by any GitLab instance.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/20506

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5618
2016-08-04 12:21:53 +00:00
Herminio Torres f15ed5f0a5
Fix Rename `add_users_into_project` and `projects_ids`
We never add things `into` projects, we just add them `to` projects. So how about we rename this to `add_users_to_project`.

Rename `projects_ids` to `project_ids` by following the convention of rails.
2016-08-04 08:55:50 -03:00
James Lopez 6a0bbb5aa5 using shared path for project import uploads and refactored gitlab remove export worker 2016-08-04 12:51:55 +02:00
Paco Guzman fa54a8e984 Don’t close issues on original project from a fork
Signed-off-by: Paco Guzman <pacoguzmanp@gmail.com>
2016-08-04 12:38:08 +02:00
Rémy Coutable 6ffafc7946 Merge branch 'syntax-highlight-filter-performance' into 'master'
Improve performance of SyntaxHighlightFilter

## What does this MR do?

This MR improves the performance of `Banzai::Filter::SyntaxHighlightFilter`. See e9bacc6575d0002c6cab620075dea3dc7f93f100 for more information.

## Are there points in the code the reviewer needs to double check?

Styling mostly.

## Why was this MR needed?

Syntax highlighting is rather slow.

## What are the relevant issue numbers?

#18592 

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- [x] ~~API support added~~
- Tests
  - [x] ~~Added for this feature/bug~~
  - [ ] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5643
2016-08-04 10:13:39 +00:00
Rémy Coutable ae83801cd5 Merge branch 'fix/import-error' into 'master'
Fix Import/Export error checking versions

Fixes small bug preventing the correct error message about Import/Export version being displayed.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/20536

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5638
2016-08-04 10:09:18 +00:00
Rémy Coutable 5ffb07189c Merge branch 'autolink-filter-text-parse' into 'master'
Improve AutolinkFilter#text_parse performance

## What does this MR do?

This MR improves the performance of `AutolinkFilter#text_parse` by using XPath queries for filtering out most text nodes.

## Are there points in the code the reviewer needs to double check?

Mostly the styling of things.

## Why was this MR needed?

Parsing text nodes is slow, mostly because most of this happens in Ruby.

## What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/18593

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- [x] ~~API support added~~
- Tests
  - [x] ~~Added for this feature/bug~~
  - [ ] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !5629
2016-08-04 10:07:56 +00:00
Robert Speicher f7c360cad6 Merge branch 'update-gitlab-shell-in-tests' into 'master'
Update the gitlab-shell version in the tmp/tests directory to the right version

Previously the gitlab-shell version would never be updated if the directory existed via the `gitlab🐚install` Rake task. This could lead to incompatibility issues or random errors.

See merge request !5646
2016-08-03 19:17:36 +00:00
Z.J. van de Weg 2b6bd6a33f Use Grape DSL for deploy keys endpoints
Also a minor clean up of the post endpoint
2016-08-03 21:04:14 +02:00
Stan Hu 8a62f4e7d4 Update the gitlab-shell version in the tmp/tests directory to the right version
Previously the gitlab-shell version would never be updated if the directory
existed via the `gitlab🐚install` Rake task. This could lead to
incompatibility issues or random errors.
2016-08-03 11:39:19 -07:00
Douwe Maan c008a1a967 Make Compare#diffs diff_options a regular argument 2016-08-03 09:32:01 -07:00
Yorick Peterse 038d6febed
Improve performance of SyntaxHighlightFilter
By using Rouge::Lexer.find instead of find_fancy() and memoizing the
HTML formatter we can speed up the highlighting process by between 1.7
and 1.8 times (at least when measured using synthetic benchmarks). To
measure this I used the following benchmark:

    require 'benchmark/ips'

    input = ''

    Dir['./app/controllers/**/*.rb'].each do |controller|
      input << <<-EOF
      <pre><code class="ruby">#{File.read(controller).strip}</code></pre>

      EOF
    end

    document = Nokogiri::HTML.fragment(input)
    filter = Banzai::Filter::SyntaxHighlightFilter.new(document)

    puts "Input size: #{(input.bytesize.to_f / 1024).round(2)} KB"

    Benchmark.ips do |bench|
      bench.report 'call' do
        filter.call
      end
    end

This benchmark produces 250 KB of input. Before these changes the timing
output would be as follows:

    Calculating -------------------------------------
                    call     1.000  i/100ms
    -------------------------------------------------
                    call     22.439  (±35.7%) i/s -     93.000

After these changes the output instead is as follows:

Calculating -------------------------------------
                call     1.000  i/100ms
-------------------------------------------------
                call     41.283  (±38.8%) i/s -    148.000

Note that due to the fairly high standard deviation and this being a
synthetic benchmark it's entirely possible the real-world improvements
are smaller.
2016-08-03 16:58:20 +02:00
Z.J. van de Weg da3d3ba89c Endpoints to enable and disable deploy keys
Resolves #20123
2016-08-03 16:00:22 +02:00
Jacob Vosmaer b8f754dd0a Stop 'git push' over HTTP early
Before this change we always let users push Git data over HTTP before
deciding whether to accept to push. This was different from pushing
over SSH where we terminate a 'git push' early if we already know the
user is not allowed to push.

This change let Git over HTTP follow the same behavior as Git over
SSH. We also distinguish between HTTP 404 and 403 responses when
denying Git requests, depending on whether the user is allowed to know
the project exists.
2016-08-03 14:54:12 +02:00
James Lopez f87eb25020 Fix Import/Export error checking versions 2016-08-03 13:00:34 +02:00
Yorick Peterse dd35c3ddf6
Improve AutolinkFilter#text_parse performance
By using clever XPath queries we can quite significantly improve the
performance of this method. The actual improvement depends a bit on the
amount of links used but in my tests the new implementation is usually
around 8 times faster than the old one. This was measured using the
following benchmark:

    require 'benchmark/ips'

    text = '<p>' + Note.select("string_agg(note, '') AS note").limit(50).take[:note] + '</p>'
    document = Nokogiri::HTML.fragment(text)
    filter = Banzai::Filter::AutolinkFilter.new(document, autolink: true)

    puts "Input size: #{(text.bytesize.to_f / 1024 / 1024).round(2)} MB"

    filter.rinku_parse

    Benchmark.ips(time: 15) do |bench|
      bench.report 'text_parse' do
        filter.text_parse
      end

      bench.report 'text_parse_fast' do
        filter.text_parse_fast
      end

      bench.compare!
    end

Here the "text_parse_fast" method is the new implementation and
"text_parse" the old one. The input size was around 180 MB. Running this
benchmark outputs the following:

    Input size: 181.16 MB
    Calculating -------------------------------------
              text_parse     1.000  i/100ms
         text_parse_fast     9.000  i/100ms
    -------------------------------------------------
              text_parse     13.021  (±15.4%) i/s -    188.000
         text_parse_fast    112.741  (± 3.5%) i/s -      1.692k

    Comparison:
         text_parse_fast:      112.7 i/s
              text_parse:       13.0 i/s - 8.66x slower

Again the production timings may (and most likely will) vary depending
on the input being processed.
2016-08-03 11:38:46 +02:00
Paco Guzman c86c1905b5 switch from diff_file_collection to diffs
So we have raw_diffs too
2016-08-03 07:00:20 +02:00
Paco Guzman 1d0c7b7492 Introduce Compare model in the codebase.
This object will manage Gitlab::Git::Compare instances
2016-08-03 07:00:20 +02:00
Paco Guzman 8f359ea917 Move to Gitlab::Diff::FileCollection
Instead calling diff_collection.count use diff_collection.size which is cache on the diff_collection
2016-08-03 07:00:20 +02:00
Paco Guzman cd7c2cb6dd Cache highlighted diff lines for merge requests
Introducing the concept of SafeDiffs which relates 
diffs with UI highlighting.
2016-08-03 07:00:19 +02:00
Yorick Peterse a8851a3c9f Merge branch 'fix-downtime-check-compare-with-branch' into 'master'
Always compare with FETCH_HEAD in downtime_check

See merge request !5619
2016-08-02 10:36:30 +00:00
James Lopez f611b7b357 fix TODO comment [ci skip] 2016-08-02 12:05:05 +02:00
Yorick Peterse ab0aedef5b
Always compare with FETCH_HEAD in downtime_check
This ensures this CI step works properly even when doing a shallow
clone.
2016-08-02 11:57:14 +02:00
winniehell 40da543f2f Add support for relative links starting with ./ or / to RelativeLinkFilter (!5586) 2016-08-02 03:52:24 +02:00
Ahmad Sherif 0720b9ce00 Catch what warden might throw when profiling requests to re-throw it
Closes #20488
2016-08-01 22:10:04 +02:00