Commit Graph

184 Commits

Author SHA1 Message Date
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
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
Marin Jankovski 14032d8eb1 Add support for git lfs. 2015-11-16 12:39:13 +01:00
Douwe Maan c5e4b443ff Fix GitAccess. 2015-05-13 09:46:22 +02:00
Douwe Maan 1f72c387c9 Improve Git access error messages. 2015-05-13 09:41:55 +02:00
Dmitriy Zaporozhets f729f60447 Merge branch 'more-rubocop-styles' into 'master'
More rubocop styles

See merge request !449
2015-03-25 15:37:04 +00:00
Dmitriy Zaporozhets 69454e36f7 Style/RedundantReturn enabled 2015-03-24 18:35:57 -07:00
Douwe Maan 4830b2be5e Refactor GitAccess to use instance variables. 2015-03-24 14:11:48 +01:00
Douwe Maan 383c56efa1 Use Gitlab::Git helper methods and constants as much as possible. 2015-03-10 13:39:31 +01:00
Douwe Maan 3d6b042e9e Fix push access check when not signed in. 2015-02-18 21:59:15 +01:00
Dmitriy Zaporozhets 61cc6a9244 Rubocop: indentation fixes Yay!!! 2015-02-02 21:59:28 -08:00
Dmitriy Zaporozhets 7d48205c1a Rubocop: comment indentation 2015-02-02 21:34:16 -08:00
Dmitriy Zaporozhets 953c1fff8f Be more careful with parsing changes from gitlab-shell 2015-01-28 17:00:40 -08:00
Valery Sizov ab7a79bf3b developer can push to protected branches 2015-01-20 17:34:23 -08:00
Marin Jankovski 92eb3974ac Add option to disable/enable developers push to already protected branches. 2014-12-26 11:39:12 +01:00
Marin Jankovski 770b2a5cfb Move protected branch actions into a method. 2014-12-26 09:52:39 +01:00
Marin Jankovski 61b4214e94 Allow regular code push for developers if the protected branch allows it. 2014-12-26 09:35:49 +01:00
Dmitriy Zaporozhets 4491a3d12b
Decline push if repository does not exist
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-05 18:17:51 +02:00
Dmitriy Zaporozhets 835cbc06d8
Reload mr code on force push too
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-02 17:42:56 +02:00
Dmitriy Zaporozhets 06b7907c2a
Fix deploy keys permission check in internal api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-12-01 16:25:10 +02:00
Valery Sizov 53bf52f191 Better message for failed pushes because of git hooks
Conflicts:
	lib/gitlab/git_access.rb
	spec/lib/gitlab/git_access_spec.rb
2014-11-18 13:10:07 +02:00
Ciro Santilli 71ed0ab069 Fix push not allowed to protected branch if
commit starts with 7 zeros.
2014-11-03 20:37:47 +01:00
Dmitriy Zaporozhets 0bf99f6557
Developers can push to wiki repo. Protected branches does not affect wiki repo any more
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-10-07 16:05:24 +03:00
Jacob Vosmaer f12d6278ed Fix ref parsing in Gitlab::GitAccess 2014-09-23 13:18:36 +02:00
Dmitriy Zaporozhets 0306a4e2e4
Rewrite GitAccess for gitlab-shell v2
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-01 19:57:25 +03:00
Dmitriy Zaporozhets d8c7efa626
Dont allow git tag rewrite/removal unless you are master
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-30 16:26:45 +03:00
Dmitriy Zaporozhets 36cac35b24
Dont allow remove of protected branch
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-05-22 15:38:47 +03:00
Jacob Vosmaer 34fd557055 Move user access check to Gitlab::UserAccess 2014-05-15 10:22:59 +02:00
Jacob Vosmaer 797e807249 Use LDAP::Access.open to reuse the LDAP connection 2014-05-14 19:04:00 +02:00
Dmitriy Zaporozhets 5350492842
Fix support for force_push
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-04-03 15:03:45 +03:00
Steven Thonus 8b35b20837 first setup to protect protected branched to force updates 2014-03-25 22:33:14 +01:00
Dmitriy Zaporozhets 7dd18a3ec8
Fix http clone for public project
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-03-21 14:52:30 +02:00
Dmitriy Zaporozhets 19c28822ef Add Gitlab::GitAccess class to resolve auth issues during pull/push
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-03-20 10:16:17 +02:00