Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e44821cd
Commit
e44821cd
authored
Oct 05, 2017
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More readonly to read_only renames
parent
6f3055fa
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
18 additions
and
18 deletions
+18
-18
config/application.rb
config/application.rb
+2
-2
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+4
-4
lib/gitlab/middleware/read_only.rb
lib/gitlab/middleware/read_only.rb
+2
-2
spec/ee/spec/models/ee/user_spec.rb
spec/ee/spec/models/ee/user_spec.rb
+2
-2
spec/factories/projects.rb
spec/factories/projects.rb
+1
-1
spec/lib/banzai/renderer_spec.rb
spec/lib/banzai/renderer_spec.rb
+1
-1
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+1
-1
spec/lib/gitlab/middleware/read_only_spec.rb
spec/lib/gitlab/middleware/read_only_spec.rb
+2
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-2
spec/services/projects/hashed_storage_migration_service_spec.rb
...ervices/projects/hashed_storage_migration_service_spec.rb
+1
-1
No files found.
config/application.rb
View file @
e44821cd
...
...
@@ -174,8 +174,8 @@ module Gitlab
ENV
[
'GITLAB_PATH_OUTSIDE_HOOK'
]
=
ENV
[
'PATH'
]
ENV
[
'GIT_TERMINAL_PROMPT'
]
=
'0'
# Gitlab Readonly middleware support
config
.
middleware
.
insert_after
ActionDispatch
::
Flash
,
'Gitlab::Middleware::Read
o
nly'
# Gitlab Read
-
only middleware support
config
.
middleware
.
insert_after
ActionDispatch
::
Flash
,
'Gitlab::Middleware::Read
O
nly'
config
.
generators
do
|
g
|
g
.
factory_girl
false
...
...
lib/gitlab/git_access.rb
View file @
e44821cd
...
...
@@ -19,8 +19,8 @@ module Gitlab
command_not_allowed:
"The command you're trying to execute is not allowed."
,
upload_pack_disabled_over_http:
'Pulling over HTTP is not allowed.'
,
receive_pack_disabled_over_http:
'Pushing over HTTP is not allowed.'
,
readonly:
'The repository is temporarily read-only. Please try again later.'
,
cannot_push_to_readonly:
"You can't push code to a read-only GitLab instance."
read
_
only:
'The repository is temporarily read-only. Please try again later.'
,
cannot_push_to_read
_
only:
"You can't push code to a read-only GitLab instance."
}.
freeze
DOWNLOAD_COMMANDS
=
%w{ git-upload-pack git-upload-archive }
.
freeze
...
...
@@ -173,11 +173,11 @@ module Gitlab
# TODO: please clean this up
def
check_push_access!
(
changes
)
if
project
.
repository_read_only?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:readonly
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:read
_
only
]
end
if
Gitlab
::
Database
.
read_only?
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:cannot_push_to_readonly
]
raise
UnauthorizedError
,
ERROR_MESSAGES
[
:cannot_push_to_read
_
only
]
end
if
deploy_key
...
...
lib/gitlab/middleware/readonly.rb
→
lib/gitlab/middleware/read
_
only.rb
View file @
e44821cd
module
Gitlab
module
Middleware
class
Read
o
nly
class
Read
O
nly
DISALLOWED_METHODS
=
%w(POST PATCH PUT DELETE)
.
freeze
APPLICATION_JSON
=
'application/json'
.
freeze
API_VERSIONS
=
(
3
..
4
)
...
...
@@ -14,7 +14,7 @@ module Gitlab
@env
=
env
if
disallowed_request?
&&
Gitlab
::
Database
.
read_only?
Rails
.
logger
.
debug
(
'GitLab Read
only: preventing possible non read
only operation'
)
Rails
.
logger
.
debug
(
'GitLab Read
Only: preventing possible non read-
only operation'
)
error_message
=
'You cannot do writing operations on a read-only GitLab instance'
if
json_request?
...
...
spec/ee/spec/models/ee/user_spec.rb
View file @
e44821cd
...
...
@@ -83,7 +83,7 @@ describe EE::User do
expect
(
subject
.
reload
.
remember_created_at
).
to
be_nil
end
it
'does not clear remember_created_at when in a GitLab readonly instance'
do
it
'does not clear remember_created_at when in a GitLab read
-
only instance'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
)
{
true
}
expect
{
subject
.
forget_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
...
...
@@ -99,7 +99,7 @@ describe EE::User do
expect
(
subject
.
reload
.
remember_created_at
).
not_to
be_nil
end
it
'does not update remember_created_at when in a Geo readonly instance'
do
it
'does not update remember_created_at when in a Geo read
-
only instance'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
)
{
true
}
expect
{
subject
.
remember_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
...
...
spec/factories/projects.rb
View file @
e44821cd
...
...
@@ -174,7 +174,7 @@ FactoryGirl.define do
end
end
trait
:readonly
do
trait
:read
_
only
do
repository_read_only
true
end
...
...
spec/lib/banzai/renderer_spec.rb
View file @
e44821cd
...
...
@@ -36,7 +36,7 @@ describe Banzai::Renderer do
is_expected
.
to
eq
(
'field_html'
)
end
it
"skips database caching on a GitLab readonly instance"
do
it
"skips database caching on a GitLab read
-
only instance"
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
).
and_return
(
true
)
expect
(
object
).
to
receive
(
:refresh_markdown_cache!
)
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
e44821cd
...
...
@@ -943,7 +943,7 @@ describe Gitlab::GitAccess do
end
context
'when the repository is read only'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:readonly
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:read
_
only
)
}
it
'denies push access'
do
project
.
add_master
(
user
)
...
...
spec/lib/gitlab/middleware/readonly_spec.rb
→
spec/lib/gitlab/middleware/read
_
only_spec.rb
View file @
e44821cd
require
'spec_helper'
describe
Gitlab
::
Middleware
::
Read
o
nly
do
describe
Gitlab
::
Middleware
::
Read
O
nly
do
include
Rack
::
Test
::
Methods
RSpec
::
Matchers
.
define
:be_a_redirect
do
...
...
@@ -38,7 +38,7 @@ describe Gitlab::Middleware::Readonly do
let
(
:request
)
{
Rack
::
MockRequest
.
new
(
rack_stack
)
}
context
'normal requests to a readonly Gitlab instance'
do
context
'normal requests to a read
-
only Gitlab instance'
do
let
(
:fake_app
)
{
lambda
{
|
env
|
[
200
,
{
'Content-Type'
=>
'text/plain'
},
[
'OK'
]]
}
}
before
do
...
...
spec/models/project_spec.rb
View file @
e44821cd
...
...
@@ -2928,7 +2928,7 @@ describe Project do
expect
(
project
.
migrate_to_hashed_storage!
).
to
be_truthy
end
it
'flags as readonly'
do
it
'flags as read
-
only'
do
expect
{
project
.
migrate_to_hashed_storage!
}.
to
change
{
project
.
repository_read_only
}.
to
(
true
)
end
...
...
@@ -3055,7 +3055,7 @@ describe Project do
expect
(
project
.
migrate_to_hashed_storage!
).
to
be_nil
end
it
'does not flag as readonly'
do
it
'does not flag as read
-
only'
do
expect
{
project
.
migrate_to_hashed_storage!
}.
not_to
change
{
project
.
repository_read_only
}
end
end
...
...
spec/services/projects/hashed_storage_migration_service_spec.rb
View file @
e44821cd
...
...
@@ -20,7 +20,7 @@ describe Projects::HashedStorageMigrationService do
expect
(
gitlab_shell
.
exists?
(
project
.
repository_storage_path
,
"
#{
hashed_storage
.
disk_path
}
.wiki.git"
)).
to
be_truthy
end
it
'updates project to be hashed and not readonly'
do
it
'updates project to be hashed and not read
-
only'
do
service
.
execute
expect
(
project
.
hashed_storage?
).
to
be_truthy
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment