Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9cd70ec1
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9cd70ec1
编写于
5月 30, 2019
作者:
I
Imre Farkas
提交者:
Robert Speicher
5月 30, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CE port of Move EE specific lines in API::Projects
上级
9302485e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
90 addition
and
60 deletion
+90
-60
lib/api/helpers/projects_helpers.rb
lib/api/helpers/projects_helpers.rb
+36
-39
lib/api/project_import.rb
lib/api/project_import.rb
+2
-1
lib/api/projects.rb
lib/api/projects.rb
+4
-19
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+48
-1
未找到文件。
lib/api/helpers/projects_helpers.rb
浏览文件 @
9cd70ec1
...
...
@@ -4,48 +4,45 @@ module API
module
Helpers
module
ProjectsHelpers
extend
ActiveSupport
::
Concern
extend
Grape
::
API
::
Helpers
included
do
helpers
do
params
:optional_project_params_ce
do
optional
:description
,
type:
String
,
desc:
'The description of the project'
optional
:ci_config_path
,
type:
String
,
desc:
'The path to CI config file. Defaults to `.gitlab-ci.yml`'
optional
:issues_enabled
,
type:
Boolean
,
desc:
'Flag indication if the issue tracker is enabled'
optional
:merge_requests_enabled
,
type:
Boolean
,
desc:
'Flag indication if merge requests are enabled'
optional
:wiki_enabled
,
type:
Boolean
,
desc:
'Flag indication if the wiki is enabled'
optional
:jobs_enabled
,
type:
Boolean
,
desc:
'Flag indication if jobs are enabled'
optional
:snippets_enabled
,
type:
Boolean
,
desc:
'Flag indication if snippets are enabled'
optional
:shared_runners_enabled
,
type:
Boolean
,
desc:
'Flag indication if shared runners are enabled for that project'
optional
:resolve_outdated_diff_discussions
,
type:
Boolean
,
desc:
'Automatically resolve merge request diffs discussions on lines changed with a push'
optional
:container_registry_enabled
,
type:
Boolean
,
desc:
'Flag indication if the container registry is enabled for that project'
optional
:lfs_enabled
,
type:
Boolean
,
desc:
'Flag indication if Git LFS is enabled for that project'
optional
:visibility
,
type:
String
,
values:
Gitlab
::
VisibilityLevel
.
string_values
,
desc:
'The visibility of the project.'
optional
:public_builds
,
type:
Boolean
,
desc:
'Perform public builds'
optional
:request_access_enabled
,
type:
Boolean
,
desc:
'Allow users to request member access'
optional
:only_allow_merge_if_pipeline_succeeds
,
type:
Boolean
,
desc:
'Only allow to merge if builds succeed'
optional
:only_allow_merge_if_all_discussions_are_resolved
,
type:
Boolean
,
desc:
'Only allow to merge if all discussions are resolved'
optional
:tag_list
,
type:
Array
[
String
],
desc:
'The list of tags for a project'
optional
:avatar
,
type:
File
,
desc:
'Avatar image for project'
optional
:printing_merge_request_link_enabled
,
type:
Boolean
,
desc:
'Show link to create/view merge request when pushing from the command line'
optional
:merge_method
,
type:
String
,
values:
%w(ff rebase_merge merge)
,
desc:
'The merge method used when merging merge requests'
optional
:initialize_with_readme
,
type:
Boolean
,
desc:
"Initialize a project with a README.md"
optional
:external_authorization_classification_label
,
type:
String
,
desc:
'The classification label for the project'
end
params
:optional_project_params_ce
do
optional
:description
,
type:
String
,
desc:
'The description of the project'
optional
:ci_config_path
,
type:
String
,
desc:
'The path to CI config file. Defaults to `.gitlab-ci.yml`'
optional
:issues_enabled
,
type:
Boolean
,
desc:
'Flag indication if the issue tracker is enabled'
optional
:merge_requests_enabled
,
type:
Boolean
,
desc:
'Flag indication if merge requests are enabled'
optional
:wiki_enabled
,
type:
Boolean
,
desc:
'Flag indication if the wiki is enabled'
optional
:jobs_enabled
,
type:
Boolean
,
desc:
'Flag indication if jobs are enabled'
optional
:snippets_enabled
,
type:
Boolean
,
desc:
'Flag indication if snippets are enabled'
optional
:shared_runners_enabled
,
type:
Boolean
,
desc:
'Flag indication if shared runners are enabled for that project'
optional
:resolve_outdated_diff_discussions
,
type:
Boolean
,
desc:
'Automatically resolve merge request diffs discussions on lines changed with a push'
optional
:container_registry_enabled
,
type:
Boolean
,
desc:
'Flag indication if the container registry is enabled for that project'
optional
:lfs_enabled
,
type:
Boolean
,
desc:
'Flag indication if Git LFS is enabled for that project'
optional
:visibility
,
type:
String
,
values:
Gitlab
::
VisibilityLevel
.
string_values
,
desc:
'The visibility of the project.'
optional
:public_builds
,
type:
Boolean
,
desc:
'Perform public builds'
optional
:request_access_enabled
,
type:
Boolean
,
desc:
'Allow users to request member access'
optional
:only_allow_merge_if_pipeline_succeeds
,
type:
Boolean
,
desc:
'Only allow to merge if builds succeed'
optional
:only_allow_merge_if_all_discussions_are_resolved
,
type:
Boolean
,
desc:
'Only allow to merge if all discussions are resolved'
optional
:tag_list
,
type:
Array
[
String
],
desc:
'The list of tags for a project'
optional
:avatar
,
type:
File
,
desc:
'Avatar image for project'
optional
:printing_merge_request_link_enabled
,
type:
Boolean
,
desc:
'Show link to create/view merge request when pushing from the command line'
optional
:merge_method
,
type:
String
,
values:
%w(ff rebase_merge merge)
,
desc:
'The merge method used when merging merge requests'
optional
:initialize_with_readme
,
type:
Boolean
,
desc:
"Initialize a project with a README.md"
optional
:external_authorization_classification_label
,
type:
String
,
desc:
'The classification label for the project'
end
params
:optional_project_params_ee
do
end
if
Gitlab
.
ee?
params
:optional_project_params_ee
do
optional
:repository_storage
,
type:
String
,
desc:
'Which storage shard the repository is on. Available only to admins'
optional
:approvals_before_merge
,
type:
Integer
,
desc:
'How many approvers should approve merge request by default'
optional
:mirror
,
type:
Boolean
,
desc:
'Enables pull mirroring in a project'
optional
:mirror_trigger_builds
,
type:
Boolean
,
desc:
'Pull mirroring triggers builds'
end
end
params
:optional_project_params
do
use
:optional_project_params_ce
use
:optional_project_params_ee
end
params
:optional_filter_params_ee
do
end
params
:optional_project_params
do
use
:optional_project_params_ce
use
:optional_project_params_ee
if
Gitlab
.
ee?
end
end
params
:optional_update_params_ee
do
end
def
self
.
update_params_at_least_one_of
...
...
lib/api/project_import.rb
浏览文件 @
9cd70ec1
...
...
@@ -3,7 +3,8 @@
module
API
class
ProjectImport
<
Grape
::
API
include
PaginationParams
include
Helpers
::
ProjectsHelpers
helpers
Helpers
::
ProjectsHelpers
helpers
do
def
import_params
...
...
lib/api/projects.rb
浏览文件 @
9cd70ec1
...
...
@@ -6,27 +6,12 @@ module API
class
Projects
<
Grape
::
API
include
PaginationParams
include
Helpers
::
CustomAttributes
include
Helpers
::
ProjectsHelpers
helpers
Helpers
::
ProjectsHelpers
before
{
authenticate_non_get!
}
helpers
do
if
Gitlab
.
ee?
params
:optional_filter_params_ee
do
optional
:wiki_checksum_failed
,
type:
Grape
::
API
::
Boolean
,
default:
false
,
desc:
'Limit by projects where wiki checksum is failed'
optional
:repository_checksum_failed
,
type:
Grape
::
API
::
Boolean
,
default:
false
,
desc:
'Limit by projects where repository checksum is failed'
end
params
:optional_update_params_ee
do
optional
:mirror_user_id
,
type:
Integer
,
desc:
'User responsible for all the activity surrounding a pull mirror event'
optional
:only_mirror_protected_branches
,
type:
Grape
::
API
::
Boolean
,
desc:
'Only mirror protected branches'
optional
:mirror_overwrites_diverged_branches
,
type:
Grape
::
API
::
Boolean
,
desc:
'Pull mirror overwrites diverged branches'
optional
:import_url
,
type:
String
,
desc:
'URL from which the project is imported'
optional
:packages_enabled
,
type:
Grape
::
API
::
Boolean
,
desc:
'Enable project packages feature'
optional
:fallback_approvals_required
,
type:
Integer
,
desc:
'Overall approvals required when no rule is present'
end
end
# EE::API::Projects would override this method
def
apply_filters
(
projects
)
projects
=
projects
.
with_issues_available_for_user
(
current_user
)
if
params
[
:with_issues_enabled
]
...
...
@@ -77,7 +62,7 @@ module API
optional
:with_programming_language
,
type:
String
,
desc:
'Limit to repositories which use the given programming language'
optional
:min_access_level
,
type:
Integer
,
values:
Gitlab
::
Access
.
all_values
,
desc:
'Limit by minimum access level of authenticated user'
use
:optional_filter_params_ee
if
Gitlab
.
ee?
use
:optional_filter_params_ee
end
params
:create_params
do
...
...
@@ -296,7 +281,7 @@ module API
optional
:path
,
type:
String
,
desc:
'The path of the repository'
use
:optional_project_params
use
:optional_update_params_ee
if
Gitlab
.
ee?
use
:optional_update_params_ee
at_least_one_of
(
*
Helpers
::
ProjectsHelpers
.
update_params_at_least_one_of
)
end
...
...
spec/requests/api/projects_spec.rb
浏览文件 @
9cd70ec1
...
...
@@ -1025,7 +1025,54 @@ describe API::Projects do
end
end
context
'when authenticated'
do
context
'when authenticated as an admin'
do
it
'returns a project by id'
do
project
project_member
group
=
create
(
:group
)
link
=
create
(
:project_group_link
,
project:
project
,
group:
group
)
get
api
(
"/projects/
#{
project
.
id
}
"
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'id'
]).
to
eq
(
project
.
id
)
expect
(
json_response
[
'description'
]).
to
eq
(
project
.
description
)
expect
(
json_response
[
'default_branch'
]).
to
eq
(
project
.
default_branch
)
expect
(
json_response
[
'tag_list'
]).
to
be_an
Array
expect
(
json_response
[
'archived'
]).
to
be_falsey
expect
(
json_response
[
'visibility'
]).
to
be_present
expect
(
json_response
[
'ssh_url_to_repo'
]).
to
be_present
expect
(
json_response
[
'http_url_to_repo'
]).
to
be_present
expect
(
json_response
[
'web_url'
]).
to
be_present
expect
(
json_response
[
'owner'
]).
to
be_a
Hash
expect
(
json_response
[
'name'
]).
to
eq
(
project
.
name
)
expect
(
json_response
[
'path'
]).
to
be_present
expect
(
json_response
[
'issues_enabled'
]).
to
be_present
expect
(
json_response
[
'merge_requests_enabled'
]).
to
be_present
expect
(
json_response
[
'wiki_enabled'
]).
to
be_present
expect
(
json_response
[
'jobs_enabled'
]).
to
be_present
expect
(
json_response
[
'snippets_enabled'
]).
to
be_present
expect
(
json_response
[
'container_registry_enabled'
]).
to
be_present
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'last_activity_at'
]).
to
be_present
expect
(
json_response
[
'shared_runners_enabled'
]).
to
be_present
expect
(
json_response
[
'creator_id'
]).
to
be_present
expect
(
json_response
[
'namespace'
]).
to
be_present
expect
(
json_response
[
'avatar_url'
]).
to
be_nil
expect
(
json_response
[
'star_count'
]).
to
be_present
expect
(
json_response
[
'forks_count'
]).
to
be_present
expect
(
json_response
[
'public_jobs'
]).
to
be_present
expect
(
json_response
[
'shared_with_groups'
]).
to
be_an
Array
expect
(
json_response
[
'shared_with_groups'
].
length
).
to
eq
(
1
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_id'
]).
to
eq
(
group
.
id
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_name'
]).
to
eq
(
group
.
name
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_access_level'
]).
to
eq
(
link
.
group_access
)
expect
(
json_response
[
'only_allow_merge_if_pipeline_succeeds'
]).
to
eq
(
project
.
only_allow_merge_if_pipeline_succeeds
)
expect
(
json_response
[
'only_allow_merge_if_all_discussions_are_resolved'
]).
to
eq
(
project
.
only_allow_merge_if_all_discussions_are_resolved
)
end
end
context
'when authenticated as a regular user'
do
before
do
project
project_member
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录