Commit Graph

75 Commits

Author SHA1 Message Date
Patrick Bajao 438485ef88 Allow users to create protected branches via CLI
This is for fixing a regression introduced by:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24969

This fix will allow users who are allowed to push to protected
branches to create protected branches via CLI as well, just
like before. The checks for protected branch creation won't
need to run.
2019-03-21 19:53:04 +08:00
Patrick Bajao 461e397969 Move empty_repo check on its own 2019-03-07 16:57:01 +08:00
Patrick Bajao 333097d765 Allow protected branch creation for empty project 2019-03-07 12:47:31 +08:00
Patrick Bajao e371520f46 Allow protected branch creation via web and API
This commit includes changes to add `UserAccess#can_create_branch?`
which will check whether the user is allowed to create a branch even
if it matches a protected branch.

This is used in `Gitlab::Checks::BranchCheck` when the branch name
matches a protected branch.

A `push_to_create_protected_branch` ability in `ProjectPolicy` has been
added to allow Developers and above to create protected branches.
2019-03-06 12:20:27 +00:00
Douwe Maan 48ca2dc6e1
Remove oldrev and newrev nil-checks that are now unnecessary 2019-01-02 15:31:33 +01:00
Douwe Maan 3a0ae96c0e
Don't run single change checks when changes are unknown
When the `changes` passed to `GitAccess` are the literal string `_any`,
which indicates that this is a pre-authorization check, we now check
whether the user can push to any branch in the project in question,
instead of running the per-change check with `oldrev` `_any`, `newrev`
`nil`, and `ref` `nil`.
2019-01-02 15:31:32 +01:00
Douwe Maan 551e84c2cb
Skip change access check for deploy keys 2019-01-02 15:31:32 +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
Douwe Maan 1e4b6cd8e6
Remove now-unnecessary checks 2018-12-11 17:39:38 +01:00
Stan Hu eb335bbcfe
Fix DiffCheck failing due to invalid string argument
Hot patch for #55137
2018-12-11 17:39:32 +01:00
Francisco Javier López 6ed50b62e7 CE port Refactor Gitlab::Checks::ChangeAccess class 2018-12-04 11:55:49 +00:00
Francisco Javier López 3797cfbd39
Fix bug in CommitCheck 2018-11-14 09:55:57 +01:00
Tiago Botelho 41fe3fdfc3
Reverts commits_check message 2018-10-26 09:50:44 +01:00
Tiago Botelho e0225aea1b
Iterating through commit list times out
Validating each commit on ChangeAccess times out if
it already took too long to complete.

Improves the TimedLogger specs to not make use of a stubbed
class anymore
2018-10-25 10:52:03 +01:00
Tiago Botelho cb5f4d0cad
Refactors TimedLogger to be more OOP compliant
Adds a #full_message method so that external classes
do not have access to the state of the logger.

Adds a #append_message to always append to the array in-place
2018-10-25 10:10:46 +01:00
Tiago Botelho 084a8b6101
Adds tracing messages for slow git pushes
Whenever a git push takes more than 50 seconds the user
will receive a trace from each check performed along with
their timings
2018-10-25 10:10:45 +01:00
gfyoung e166e5747c Enable some frozen string in lib/gitlab
Enable frozen string for the following files:

* lib/gitlab/auth/**/*.rb
* lib/gitlab/badge/**/*.rb
* lib/gitlab/bare_repository_import/**/*.rb
* lib/gitlab/bitbucket_import/**/*.rb
* lib/gitlab/bitbucket_server_import/**/*.rb
* lib/gitlab/cache/**/*.rb
* lib/gitlab/checks/**/*.rb

Partially addresses #47424.
2018-10-13 02:31:31 -07:00
Yorick Peterse 2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Rubén Dávila 5c748a0bd9 Backport some changes from gitlab-org/gitlab-ee!6767 2018-08-07 06:13:48 -05:00
Tiago Botelho 65e5cf0ace Improves remote message when a developer is unable to push in an empty repository 2018-07-18 09:25:00 +01:00
Zeger-Jan van de Weg c2cdefd441
Force push is handled by Gitaly now
Closes gitlab-org/gitaly#348
2018-06-19 15:35:17 +02:00
Stan Hu 4f9068dfc0 Eliminate N+1 queries in LFS file locks checks during a push
This significantly improves performance when a user pushes many references.

project.path_locks.any? doesn't cache the output and runs `SELECT 1 AS one
FROM "path_locks" WHERE project_id = N` each time. When there are thousands
of refs being pushed, this can time out the unicorn worker.

CE port for https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/6159.
2018-06-18 16:42:20 -07:00
Mark Chao a6c15c5b97 change wording 2018-06-06 21:01:44 +09:00
Bob Van Landuyt 48b17e991a Add helper for accessing lfs_objects for project
This makes accessing LFS Objects for a project easier

  project.lfs_storage_project.lfs_objects`

becomes

  project.all_lfs_objects

This will make the refactor in
https://gitlab.com/gitlab-org/gitlab-ce/issues/39769 easier to deal
with.
2018-04-05 10:21:51 +02:00
Bob Van Landuyt ce69419a60 Remove permanent redirects
Removes permanent redirects, this means that redirects will only be
possible as long as the old route isn't taken by a new project/group.
2018-03-28 14:12:08 +02:00
Bob Van Landuyt 9aabd8fd5e Limit queries to a user-branch combination
The query becomes a lot simpler if we can check the branch name as
well instead of having to load all branch names.
2018-03-07 16:59:17 +01:00
Bob Van Landuyt e74879280f Allow maintainers to edit directly in a fork 2018-03-07 16:55:34 +01:00
Sean McGivern fb2a76ac48 Merge branch 'jej/avoid-slow-file-lock-checks' into 'master'
Avoid slow File Lock checks when not used

Closes #43339

See merge request gitlab-org/gitlab-ce!17140
2018-02-19 15:50:54 +00:00
James Edwards-Jones d4dfa342c1 Avoid slow File Lock checks when not used
Also avoid double commit lookup during file lock check by reusing
memoized commits.
2018-02-19 10:01:25 +00:00
James Edwards-Jones c88fe70f90 Only check LFS integrity for first branch in push 2018-02-15 01:57:55 +00:00
Rubén Dávila bed9483211 Backport of LFS File Locking API 2018-02-07 09:04:00 -05:00
Douwe Maan c51eb79bbe Merge branch 'master' into '26388-push-to-create-a-new-project'
# Conflicts:
#   lib/gitlab/path_regex.rb
2018-02-06 19:14:43 +00:00
Tiago Botelho 1e56b3f476 Moves project creationg to git access check for git push 2018-02-06 16:52:29 +00:00
Tiago Botelho dc229c076c Abstracts ProjectMoved and ProjectCreated into a BaseProject 2018-02-06 13:35:35 +00:00
Tiago Botelho e42a548f1d Move new project on push logic to a service 2018-02-06 13:35:35 +00:00
Tiago Botelho bc78ae6985 Add specs 2018-02-06 13:35:35 +00:00
Tiago Botelho 32b2ff2601 Adds remote messsage when project is created in a push over SSH or HTTP 2018-02-06 13:35:35 +00:00
Alejandro Rodríguez 98affa75ed Refactor Gitlab::Git code related to LFS changes for Gitaly migration
We stop relying on Gitlab::Git::Env for the RevList class, and use
Gitlab::Git::Repository#run_git methods inteaad. The refactor also fixes
another issue, since we now top using "path_to_repo" (which is a
Repository model method).
2018-02-02 16:27:01 -03:00
Douwe Maan 4ca358891d Backport changes to Gitlab::Checks::ChangeAccess from EE 2018-01-23 17:12:44 +01:00
Stan Hu b6c711fd38 Disable redirect messages for anonymous clones 2017-12-25 05:33:32 -08:00
Stan Hu a83c41f6c6 Fix Error 500s with anonymous clones for a project that has moved
Closes #41457
2017-12-25 05:28:51 -08:00
Mayra Cabrera 562fb460b8 Allow git pull/push on project redirects 2017-12-08 17:42:43 +00:00
James Edwards-Jones ebd5174472 Handle forks in Gitlab::Checks::LfsIntegrity 2017-11-09 13:44:20 +00:00
James Edwards-Jones a7b7a2253c Prevent git push when LFS objects are missing 2017-11-06 14:33:10 +00:00
Maxim Rydkin 10ae0d8316 replace `is_ancestor` with `ancestor?` 2017-08-29 11:14:42 +03:00
Ahmad Sherif daa0137b41 Migrate force push check to Gitaly 2017-08-11 19:42:17 +02:00
Michael Kozono 0e3cfc75a3 Remove GitAccessStatus (no longer needed) 2017-06-05 05:32:26 -07:00
Michael Kozono 23d37382da Refactor to let GitAccess errors bubble up
No external behavior change.

This allows `GitHttpController` to set the HTTP status based on the type of error. Alternatively, we could have added an attribute to GitAccessStatus, but this pattern seemed appropriate.
2017-06-05 05:32:26 -07:00
Michael Kozono ff8a053d5d Fix Git over HTTP spec
* The spec has 7 failures at this point
* Specify rendered error messages
* Render the GitAccess message rather than “Access denied”
* Render the Not Found message provided by GitAccess, instead of a custom one
* Expect GitAccess to check the config for whether Git-over-HTTP pull or push is disabled, rather than doing it in the controller
* Add more thorough testing for authentication
* Dried up a lot of tests
* Fixed some broken tests
2017-06-05 05:32:26 -07:00
Sam Rose 1ebd9dad8e Add confirm delete protected branch modal 2017-05-08 07:41:58 +00:00