BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
fd621429
Commit
fd621429
authored
Sep 01, 2016
by
Patricio Cano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added group-specific setting for LFS.
Groups can enable/disable LFS, but this setting can be overridden at the project level. Admin only
parent
f8bd9625
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
173 additions
and
12 deletions
+173
-12
groups_controller.rb
app/controllers/admin/groups_controller.rb
+9
-1
groups_controller.rb
app/controllers/groups_controller.rb
+11
-1
groups_helper.rb
app/helpers/groups_helper.rb
+5
-0
projects_helper.rb
app/helpers/projects_helper.rb
+2
-2
group.rb
app/models/group.rb
+7
-0
namespace.rb
app/models/namespace.rb
+5
-0
project.rb
app/models/project.rb
+6
-3
_form.html.haml
app/views/admin/groups/_form.html.haml
+2
-0
show.html.haml
app/views/admin/groups/show.html.haml
+7
-0
show.html.haml
app/views/admin/projects/show.html.haml
+1
-1
edit.html.haml
app/views/groups/edit.html.haml
+2
-0
_visibility_level.html.haml
app/views/shared/_visibility_level.html.haml
+1
-1
_group_lfs_settings.html.haml
app/views/shared/groups/_group_lfs_settings.html.haml
+12
-0
20160901213340_add_lfs_enabled_to_namespaces.rb
db/migrate/20160901213340_add_lfs_enabled_to_namespaces.rb
+29
-0
schema.rb
db/schema.rb
+1
-0
groups.md
doc/api/groups.md
+2
-0
entities.rb
lib/api/entities.rb
+1
-1
groups.rb
lib/api/groups.rb
+4
-2
project_spec.rb
spec/models/project_spec.rb
+66
-0
No files found.
app/controllers/admin/groups_controller.rb
View file @
fd621429
...
...
@@ -60,6 +60,14 @@ class Admin::GroupsController < Admin::ApplicationController
end
def
group_params
params
.
require
(
:group
).
permit
(
:name
,
:description
,
:path
,
:avatar
,
:visibility_level
,
:request_access_enabled
)
params
.
require
(
:group
).
permit
(
:name
,
:description
,
:path
,
:avatar
,
:visibility_level
,
:request_access_enabled
,
:lfs_enabled
)
end
end
app/controllers/groups_controller.rb
View file @
fd621429
...
...
@@ -121,7 +121,17 @@ class GroupsController < Groups::ApplicationController
end
def
group_params
params
.
require
(
:group
).
permit
(
:name
,
:description
,
:path
,
:avatar
,
:public
,
:visibility_level
,
:share_with_group_lock
,
:request_access_enabled
)
params
.
require
(
:group
).
permit
(
:name
,
:description
,
:path
,
:avatar
,
:public
,
:visibility_level
,
:share_with_group_lock
,
:request_access_enabled
,
:lfs_enabled
)
end
def
load_events
...
...
app/helpers/groups_helper.rb
View file @
fd621429
...
...
@@ -23,4 +23,9 @@ module GroupsHelper
full_title
end
end
def
projects_with_lfs_enabled
(
group
)
total
=
group
.
projects
.
size
"
#{
total
-
group
.
projects
.
select
{
|
p
|
!
p
.
lfs_enabled?
}
.size}/
#{
total
}
projects have it enabled"
end
end
app/helpers/projects_helper.rb
View file @
fd621429
...
...
@@ -202,8 +202,8 @@ module ProjectsHelper
nav_tabs
.
flatten
end
def
project_lfs_status
(
pro
ject
)
if
pro
ject
.
lfs_enabled?
def
lfs_status_helper
(
sub
ject
)
if
sub
ject
.
lfs_enabled?
content_tag
(
:span
,
class:
'lfs-enabled'
)
do
'Enabled'
end
...
...
app/models/group.rb
View file @
fd621429
...
...
@@ -95,6 +95,13 @@ class Group < Namespace
end
end
def
lfs_enabled?
return
false
unless
Gitlab
.
config
.
lfs
.
enabled
return
Gitlab
.
config
.
lfs
.
enabled
if
self
[
:lfs_enabled
].
nil?
self
[
:lfs_enabled
]
end
def
add_users
(
user_ids
,
access_level
,
current_user:
nil
,
expires_at:
nil
)
user_ids
.
each
do
|
user_id
|
Member
.
add_user
(
...
...
app/models/namespace.rb
View file @
fd621429
...
...
@@ -141,6 +141,11 @@ class Namespace < ActiveRecord::Base
projects
.
joins
(
:forked_project_link
).
find_by
(
'forked_project_links.forked_from_project_id = ?'
,
project
.
id
)
end
def
lfs_enabled?
# User namespace will always default to the global setting
Gitlab
.
config
.
lfs
.
enabled
end
private
def
repository_storage_paths
...
...
app/models/project.rb
View file @
fd621429
...
...
@@ -393,10 +393,13 @@ class Project < ActiveRecord::Base
end
def
lfs_enabled?
return
false
unless
Gitlab
.
config
.
lfs
.
enabled
return
Gitlab
.
config
.
lfs
.
enabled
if
self
[
:lfs_enabled
].
nil?
# Specifically check is lfs_enabled is false
return
false
if
self
[
:lfs_enabled
]
==
false
self
[
:lfs_enabled
]
# Should only fallback to the namespace value if no value is set for the project
return
namespace
.
lfs_enabled?
if
self
[
:lfs_enabled
].
nil?
self
[
:lfs_enabled
]
&&
Gitlab
.
config
.
lfs
.
enabled
end
def
repository_storage_path
...
...
app/views/admin/groups/_form.html.haml
View file @
fd621429
...
...
@@ -13,6 +13,8 @@
.col-sm-offset-2.col-sm-10
=
render
'shared/allow_request_access'
,
form:
f
=
render
'shared/groups/group_lfs_settings'
,
f:
f
-
if
@group
.
new_record?
.form-group
.col-sm-offset-2.col-sm-10
...
...
app/views/admin/groups/show.html.haml
View file @
fd621429
...
...
@@ -37,6 +37,13 @@
%strong
=
@group
.
created_at
.
to_s
(
:medium
)
%li
%span
.light
Group Git LFS status:
%strong
=
lfs_status_helper
(
@group
)
=
projects_with_lfs_enabled
(
@group
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'workflow/lfs/manage_large_binaries_with_git_lfs'
)
.panel.panel-default
.panel-heading
%h3
.panel-title
...
...
app/views/admin/projects/show.html.haml
View file @
fd621429
...
...
@@ -77,7 +77,7 @@
%li
%span
.light
Git LFS status:
%strong
=
project_lfs_status
(
@project
)
=
lfs_status_helper
(
@project
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'workflow/lfs/manage_large_binaries_with_git_lfs'
)
-
else
%li
...
...
app/views/groups/edit.html.haml
View file @
fd621429
...
...
@@ -25,6 +25,8 @@
.col-sm-offset-2.col-sm-10
=
render
'shared/allow_request_access'
,
form:
f
=
render
'shared/groups/group_lfs_settings'
,
f:
f
.form-group
%hr
=
f
.
label
:share_with_group_lock
,
class:
'control-label'
do
...
...
app/views/shared/_visibility_level.html.haml
View file @
fd621429
.form-group.project-visibility-level-holder
=
f
.
label
:visibility_level
,
class:
'control-label'
do
Visibility Level
=
link_to
"(?)"
,
help_page_path
(
"public_access/public_access"
)
=
link_to
icon
(
'question-circle'
)
,
help_page_path
(
"public_access/public_access"
)
.col-sm-10
-
if
can_change_visibility_level
=
render
(
'shared/visibility_radios'
,
model_method: :visibility_level
,
form:
f
,
selected_level:
visibility_level
,
form_model:
form_model
)
...
...
app/views/shared/groups/_group_lfs_settings.html.haml
0 → 100644
View file @
fd621429
-
if
current_user
.
admin?
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
=
f
.
label
:lfs_enabled
do
=
f
.
check_box
:lfs_enabled
,
checked:
@group
.
lfs_enabled?
%strong
Allow projects within this group to use Git LFS
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'workflow/lfs/manage_large_binaries_with_git_lfs'
)
%br
/
%span
.descr
This setting can be overridden in each project.
\ No newline at end of file
db/migrate/20160901213340_add_lfs_enabled_to_namespaces.rb
0 → 100644
View file @
fd621429
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class
AddLfsEnabledToNamespaces
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
# DOWNTIME_REASON = ''
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
# existing transaction. When using "add_concurrent_index" make sure that this
# method is the _only_ method called in the migration, any other changes
# should go in a separate migration. This ensures that upon failure _only_ the
# index creation fails and can be retried or reverted easily.
#
# To disable transactions uncomment the following line and remove these
# comments:
# disable_ddl_transaction!
def
change
add_column
:namespaces
,
:lfs_enabled
,
:boolean
end
end
db/schema.rb
View file @
fd621429
...
...
@@ -650,6 +650,7 @@ ActiveRecord::Schema.define(version: 20160913162434) do
t
.
integer
"visibility_level"
,
default:
20
,
null:
false
t
.
boolean
"request_access_enabled"
,
default:
true
,
null:
false
t
.
datetime
"deleted_at"
t
.
boolean
"lfs_enabled"
end
add_index
"namespaces"
,
[
"created_at"
],
name:
"index_namespaces_on_created_at"
,
using: :btree
...
...
doc/api/groups.md
View file @
fd621429
...
...
@@ -288,6 +288,7 @@ Parameters:
-
`path`
(required) - The path of the group
-
`description`
(optional) - The group's description
-
`visibility_level`
(optional) - The group's visibility. 0 for private, 10 for internal, 20 for public.
-
`lfs_enabled`
(optional) - Enable/disable LFS for the projects in this group
## Transfer project to group
...
...
@@ -317,6 +318,7 @@ PUT /groups/:id
|
`path`
| string | no | The path of the group |
|
`description`
| string | no | The description of the group |
|
`visibility_level`
| integer | no | The visibility level of the group. 0 for private, 10 for internal, 20 for public. |
|
`lfs_enabled`
(optional) | boolean | no | Enable/disable LFS for the projects in this group |
```
bash
curl
--request
PUT
--header
"PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK"
"https://gitlab.example.com/api/v3/groups/5?name=Experimental"
...
...
lib/api/entities.rb
View file @
fd621429
...
...
@@ -120,7 +120,7 @@ module API
end
class
Group
<
Grape
::
Entity
expose
:id
,
:name
,
:path
,
:description
,
:visibility_level
expose
:id
,
:name
,
:path
,
:description
,
:visibility_level
,
:lfs_enabled
expose
:avatar_url
expose
:web_url
end
...
...
lib/api/groups.rb
View file @
fd621429
...
...
@@ -27,13 +27,14 @@ module API
# path (required) - The path of the group
# description (optional) - The description of the group
# visibility_level (optional) - The visibility level of the group
# lfs_enabled (optional) - Enable/disable LFS for the projects in this group
# Example Request:
# POST /groups
post
do
authorize!
:create_group
required_attributes!
[
:name
,
:path
]
attrs
=
attributes_for_keys
[
:name
,
:path
,
:description
,
:visibility_level
]
attrs
=
attributes_for_keys
[
:name
,
:path
,
:description
,
:visibility_level
,
:lfs_enabled
]
@group
=
Group
.
new
(
attrs
)
if
@group
.
save
...
...
@@ -51,13 +52,14 @@ module API
# path (optional) - The path of the group
# description (optional) - The description of the group
# visibility_level (optional) - The visibility level of the group
# lfs_enabled (optional) - Enable/disable LFS for the projects in this group
# Example Request:
# PUT /groups/:id
put
':id'
do
group
=
find_group
(
params
[
:id
])
authorize!
:admin_group
,
group
attrs
=
attributes_for_keys
[
:name
,
:path
,
:description
,
:visibility_level
]
attrs
=
attributes_for_keys
[
:name
,
:path
,
:description
,
:visibility_level
,
:lfs_enabled
]
if
::
Groups
::
UpdateService
.
new
(
group
,
current_user
,
attrs
).
execute
present
group
,
with:
Entities
::
GroupDetail
...
...
spec/models/project_spec.rb
View file @
fd621429
...
...
@@ -1417,6 +1417,68 @@ describe Project, models: true do
end
end
describe
'#lfs_enabled?'
do
let
(
:project
)
{
create
(
:project
)
}
shared_examples
'project overrides group'
do
it
'returns true when enabled in project'
do
project
.
update_attribute
(
:lfs_enabled
,
true
)
expect
(
project
.
lfs_enabled?
).
to
be_truthy
end
it
'returns false when disabled in project'
do
project
.
update_attribute
(
:lfs_enabled
,
false
)
expect
(
project
.
lfs_enabled?
).
to
be_falsey
end
it
'returns the value from the namespace, when no value is set in project'
do
expect
(
project
.
lfs_enabled?
).
to
eq
(
project
.
namespace
.
lfs_enabled?
)
end
end
context
'LFS disabled in group'
do
before
do
project
.
namespace
.
update_attribute
(
:lfs_enabled
,
false
)
enable_lfs
end
it_behaves_like
'project overrides group'
end
context
'LFS enabled in group'
do
before
do
project
.
namespace
.
update_attribute
(
:lfs_enabled
,
true
)
enable_lfs
end
it_behaves_like
'project overrides group'
end
describe
'LFS disabled globally'
do
shared_examples
'it always returns false'
do
it
do
expect
(
project
.
lfs_enabled?
).
to
be_falsey
expect
(
project
.
namespace
.
lfs_enabled?
).
to
be_falsey
end
end
context
'when no values are set'
do
it_behaves_like
'it always returns false'
end
context
'when all values are set to true'
do
before
do
project
.
namespace
.
update_attribute
(
:lfs_enabled
,
true
)
project
.
update_attribute
(
:lfs_enabled
,
true
)
end
it_behaves_like
'it always returns false'
end
end
end
describe
'.where_paths_in'
do
context
'without any paths'
do
it
'returns an empty relation'
do
...
...
@@ -1581,4 +1643,8 @@ describe Project, models: true do
expect
(
project
.
pushes_since_gc
).
to
eq
(
0
)
end
end
def
enable_lfs
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
end
end
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