Commit Graph

1764 Commits

Author SHA1 Message Date
Lin Jen-Shin c64cd113cc Add ! for verify_record! because it could raise 2016-05-21 09:46:27 -07:00
Lin Jen-Shin 75415663f8 Rename handlers and introduce Handler.for 2016-05-21 09:40:08 -07:00
Lin Jen-Shin ee548b6ed0 Only set @raw for receiver, and handle the rest in execute 2016-05-20 19:03:39 -05:00
Lin Jen-Shin 32eae15f2f It's for Message-ID so it should be message_id 2016-05-20 18:23:04 -05:00
Lin Jen-Shin c2bc15a766 Use the authentication_token for finding the user 2016-05-20 17:38:08 -05:00
Lin Jen-Shin a7c823a573 Give ProjectNotFound when the project is not readable 2016-05-18 17:57:14 -05:00
Lin Jen-Shin c337e748d3 so we use separate classes to handle different tasks 2016-05-18 17:25:45 -05:00
Lin Jen-Shin 3f4a6412dc We should totally cache it 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 8156475ea5 Report better errors. TODO: Enable skipped test 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 30b3443779 Now we would be validating authentication token 2016-05-16 21:27:16 +00:00
Lin Jen-Shin a065c8d5d8 Create a new issue via: incoming+group/project+AUTH_TOKEN@... 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 634c9f403b process_reply -> process_create_note; handle_reply -> process_reply 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 869de96eea bang to indicate that this method could raise an exception 2016-05-16 21:27:16 +00:00
Lin Jen-Shin aac297adba Update style as create_note 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 68b5ded056 No need to check project because:
sent_notification.project would never be nil, and
we also have already checked message_project before
entering process_create_issue.
2016-05-16 21:27:16 +00:00
Lin Jen-Shin 87ff0107c1 Raise one by one instead of if checks 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 347ee6cc91 Alloy empty reply for new issues, but not response 2016-05-16 21:27:16 +00:00
Lin Jen-Shin a61bf17fce Try to give better names 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 0e4c2b6ec4 enable Style/MethodDefParentheses and fix parentheses 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 4f5027042a Add another TODO that we need to verify identity better 2016-05-16 21:27:16 +00:00
Lin Jen-Shin 6cfd028278 Implement #3243 New Issue by email
So we extend Gitlab::Email::Receiver for this new behaviour,
however we might want to split it into another class for better
testing it.

Another issue is that, currently it's using this to parse project
identifier:

    Gitlab::IncomingEmail.key_from_address

Which is using:

    Gitlab.config.incoming_email.address

for the receiver name. This is probably `reply` because it's used
for replying to a specific issue. We might want to introduce another
config for this, or just use `reply` instead of `incoming`.

I'll prefer to introduce a new config for this, or just change
`reply` to `incoming` because it would make sense for replying to
there, too.

The email template used in tests were copied and modified from:
`emails/valid_reply.eml` which I hope is ok.
2016-05-16 21:27:16 +00:00
Rémy Coutable 4f66799738 Merge branch 'wiki-fix-reloaded' into 'master'
Use the relative url prefix for links in Wiki

Retry of gitlab-org/gitlab-ce!4026

@rymai !4050 solved all other problems how it looks like. I [tested](ff01eca7b5/builds) this with ruby22

Fixes #17071 



See merge request !4131
2016-05-16 20:30:42 +00:00
Douwe Maan 5dd013f145 Merge branch 'gh-pull-requests' 2016-05-16 12:12:20 -05:00
Pablo Carranza b9306c2e82 Add cache count metrics to rails cache 2016-05-15 19:47:41 +01:00
Douglas Barbosa Alexandre 290aa75e6f Remove branches that does exist on GitHub after PRs were imported 2016-05-13 17:55:43 -05:00
Douglas Barbosa Alexandre ebaa19c162 Fix validation method for Gitlab::GithubImport::PullRequestFormatter 2016-05-13 17:55:43 -05:00
Douglas Barbosa Alexandre 795a7ca8f1 Extract GitHub branch formatter 2016-05-13 17:55:42 -05:00
Douglas Barbosa Alexandre e001bd5e3d Import PRs where branch names were reused across PRs 2016-05-13 17:55:42 -05:00
Douglas Barbosa Alexandre 7e1f14e215 Preserve commits/diff/comments for PRs that were merged on GitHub 2016-05-13 17:55:42 -05:00
Douglas Barbosa Alexandre 3b50867550 Fix spec for Gitlab::GithubImport::PullRequestFormatter 2016-05-13 16:49:27 -05:00
Douglas Barbosa Alexandre 9b4dc552cb Import pull requests from GitHub where the target branch was removed 2016-05-13 16:49:27 -05:00
Douglas Barbosa Alexandre 8532dc0d77 Import pull requests from GitHub where the source branch was removed 2016-05-13 16:49:27 -05:00
Artem Sidorenko e5c9710147 Use the relative url prefix for links in Wiki 2016-05-13 22:42:07 +02:00
Gabriel Mazetto f5a0ac0fc1 Codestyle: make sure we have space around operators 2016-05-13 04:46:56 -03:00
Robert Speicher 4735a75340 Merge branch 'deprecated-class-methods-cop' into 'master'
Enable the Rubocop DeprecatedClassMethods cop

This reports uses of `File.exists?` and `Dir.exists?`, which were both
deprecated in Ruby and will eventually be removed in favor of `.exist?`.
Also fixes all existing uses of the deprecated methods.

See merge request !4087
2016-05-12 22:41:01 +00:00
Yorick Peterse 945c5b3fe6
Removed tracking of total method execution times
Because method call timings are inclusive (that is, they include the
time of any sub method calls) this would lead to the total method
execution time often being far greater than the total transaction time.
Because this is incredibly confusing it's best to simply _not_ track the
total method execution time, after all it's not that useful to begin
with.

Fixes gitlab-org/gitlab-ce#17239
2016-05-12 15:15:45 +02:00
Robert Speicher d526cda502 Merge branch '17270-only-generate-email-on-push-once-for-all-recipients' into 'master'
Only generate repository push email once

The repository push email can be very expensive to generate, especially
with syntax-highlighted diffs. Instead of generating the email for each
recipient, generate one email object and reset the Message-Id and To
headers for each recipient. (Cloning would also be expensive in the case
of large emails, although probably not as bad as generating from
scratch.)

Closes #17270.

See merge request !4070
2016-05-11 12:45:39 +00:00
Rémy Coutable e77a9a342e Merge branch 'casecmp-cop' into 'master'
Enable Rubocop Casecmp Performance Cop.

Also fixes the errors caused by enabling the cop.

`casecmp` is more performant than `.downcase` and `==`.

See also: https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/cop/performance/casecmp.rb

See merge request !3957
2016-05-11 08:59:44 +00:00
Rémy Coutable de5ae1bf06 Merge branch 'string-replacement-cop' into 'master'
Enable the StringReplacement cop.

Also fix one use of `gsub` that would be faster as `delete`.

Use `tr` instead of `gsub` when you are replacing the same number of characters. Use `delete` instead of `gsub` when you are deleting characters.

See merge request !3960
2016-05-11 08:58:59 +00:00
Sean McGivern 5f27e26bb4 Only generate repository push email once
The repository push email can be very expensive to generate, especially
with syntax-highlighted diffs. Instead of generating the email for each
recipient, generate one email object and reset the Message-Id and To
headers for each recipient. (Cloning would also be expensive in the case
of large emails, although probably not as bad as generating from
scratch.)
2016-05-11 09:16:01 +01:00
Connor Shea 4995302df6
Enable the StringReplacement cop.
Also fix one use of `gsub` that would be faster as `delete`.

Use `tr` instead of `gsub` when you are replacing the same number of
characters. Use `delete` instead of `gsub` when you are deleting
characters.
2016-05-10 18:34:15 -06:00
Connor Shea 377583a361
Enable Rubocop Casecmp Performance Cop.
Also fixes the errors caused by enabling the cop. casecmp is more performant than `.downcase` and `==`.
2016-05-10 18:23:25 -06:00
Rémy Coutable f52a15e022
Revert "Merge branch 'wiki-fix' into 'master' "
This reverts commit 4cc85a58e8, reversing
changes made to 90ae445ba9.

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-05-10 10:57:48 +02:00
Artem Sidorenko 14b36f91d9 Use the proper GitLab URL for links in Wiki 2016-05-09 11:50:23 +02:00
Stan Hu 4be77d0b05 Improve multiple branch push performance by memoizing permission checking
If you attempt to push thousands of branches at once, the 60-second timeout
will occur because GitAccess checking does a lot of work to check if the
user has permission to push to a branch. This changes does two things:

1. Instead of making 1 DB query per branch push, use a memoized list of protected branches to check
2. Memoize what permissions the user has to perform on this project

On a test of 10,000 branch pushes, this prevents gitlab-shell from hitting the 60-second
timeout.

Closes #17225
2016-05-09 01:17:14 -07:00
Connor Shea 9cc0937b3a Enable the Rubocop DeprecatedClassMethods cop
This reports uses of `File.exists?` and `Dir.exists?`, which were both
deprecated in Ruby and will eventually be removed in favor of
`.exist?`. Also fixes all existing uses of the deprecated methods.
2016-05-08 15:33:34 -06:00
Stan Hu 21d89d0286 Update SVG sanitizer to conform to SVG 1.1
Use a custom Loofah scrubber since sanitize 2.x transformers are inadequate
to handle case-sensitive SVG attributes. sanitize parses documents as HTML
instead of XML, which causes all SVG attribute names (e.g. viewBox) to be downcased.

* SVG element list: https://www.w3.org/TR/SVG/eltindex.html
* SVG attribute list: https://www.w3.org/TR/SVG/attindex.html

Closes #14555
2016-05-06 23:20:24 -07:00
Robert Speicher 4fce876542 Merge branch 'fix/import-url-issues' into 'master'
Fix importer bug when throwing exceptions

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

See merge request !3941
2016-05-05 22:27:40 +00:00
Yorick Peterse 003671207d
Fix passing nil to protected_tag?
Previously this method would directly receive the output of tag_name().
This method could either return a String or nil. In the previous setup
this would somehow magically work but because Rugged::TagCollection#[]
doesn't accept nil values it started to fail.

To work around this the elsif in change_access_check() assigns the
result of tag_name() to a local and then _only_ calls protected_tag?()
if the tag name is not nil. The extra parenthesis are put in place to
ensure that things are parsed correctly, without these the code would be
parsed as follows:

    elsif tag_ref = (tag_name(ref) && protected_tag(tag_ref))

During runtime this would basically resolve to:

    elsif tag_ref = (tag_name(ref) && protected_tag(nil))

This is because when you refer to the variable you're assigning _in_ the
assignment Ruby returns nil instead of raising an error.
2016-05-05 19:46:26 +02:00
Yorick Peterse 93ce229665
Use tag_exists? in GitAccess#protected_tag?
This removes the need for retrieving the entire list of tags just to
check if a specific one exists.
2016-05-05 19:46:26 +02:00