Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
d52ef5ef
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,发现更多精彩内容 >>
提交
d52ef5ef
编写于
2月 07, 2017
作者:
V
Valery Sizov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes after review
上级
ef27b4be
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
26 deletion
+33
-26
app/controllers/projects/branches_controller.rb
app/controllers/projects/branches_controller.rb
+15
-5
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+5
-12
changelogs/unreleased/create_branch_repo_less.yml
changelogs/unreleased/create_branch_repo_less.yml
+1
-1
spec/controllers/projects/branches_controller_spec.rb
spec/controllers/projects/branches_controller_spec.rb
+2
-8
spec/factories/services.rb
spec/factories/services.rb
+10
-0
未找到文件。
app/controllers/projects/branches_controller.rb
浏览文件 @
d52ef5ef
class
Projects::BranchesController
<
Projects
::
ApplicationController
include
ActionView
::
Helpers
::
SanitizeHelper
include
SortingHelper
include
ProjectsHelper
# Authorize
before_action
:require_non_empty_project
,
except: :create
...
...
@@ -34,7 +33,7 @@ class Projects::BranchesController < Projects::ApplicationController
branch_name
=
sanitize
(
strip_tags
(
params
[
:branch_name
]))
branch_name
=
Addressable
::
URI
.
unescape
(
branch_name
)
is_redirect_to_autodeploy_needed
=
project
.
empty_repo?
&&
project
.
deployment_services
.
present?
redirect_to_autodeploy
=
project
.
empty_repo?
&&
project
.
deployment_services
.
present?
result
=
CreateBranchService
.
new
(
project
,
current_user
).
execute
(
branch_name
,
ref
)
...
...
@@ -47,11 +46,10 @@ class Projects::BranchesController < Projects::ApplicationController
if
result
[
:status
]
==
:success
@branch
=
result
[
:branch
]
if
is_redirect_to_autodeploy_needed
if
redirect_to_autodeploy
redirect_to
(
url_to_autodeploy_setup
(
project
,
branch_name
),
notice:
"Branch
\"
#{
sanitize
(
branch_name
)
}
\"
was created. To set up auto deploy, \
choose a GitLab CI Yaml template and commit your changes.
#{
view_context
.
link_to_autodeploy_doc
}
"
.
html_safe
)
notice:
view_context
.
autodeploy_flash_notice
(
branch_name
))
else
redirect_to
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
@branch
.
name
)
...
...
@@ -91,4 +89,16 @@ class Projects::BranchesController < Projects::ApplicationController
@project
.
default_branch
||
'master'
end
end
def
url_to_autodeploy_setup
(
project
,
branch_name
)
namespace_project_new_blob_path
(
project
.
namespace
,
project
,
branch_name
,
file_name:
'.gitlab-ci.yml'
,
commit_message:
'Set up auto deploy'
,
target_branch:
branch_name
,
context:
'autodeploy'
)
end
end
app/helpers/projects_helper.rb
浏览文件 @
d52ef5ef
...
...
@@ -154,6 +154,11 @@ module ProjectsHelper
link_to
'About auto deploy'
,
help_page_path
(
'ci/autodeploy/index'
),
target:
'_blank'
end
def
autodeploy_flash_notice
(
branch_name
)
"Branch <strong>
#{
truncate
(
sanitize
(
branch_name
))
}
</strong> was created. To set up auto deploy, \
choose a GitLab CI Yaml template and commit your changes.
#{
link_to_autodeploy_doc
}
"
.
html_safe
end
private
def
repo_children_classes
(
field
)
...
...
@@ -272,18 +277,6 @@ module ProjectsHelper
)
end
def
url_to_autodeploy_setup
(
project
,
branch_name
)
namespace_project_new_blob_path
(
project
.
namespace
,
project
,
branch_name
,
file_name:
'.gitlab-ci.yml'
,
commit_message:
'Set up auto deploy'
,
target_branch:
branch_name
,
context:
'autodeploy'
)
end
def
add_koding_stack_path
(
project
)
namespace_project_new_blob_path
(
project
.
namespace
,
...
...
changelogs/unreleased/create_branch_repo_less.yml
浏览文件 @
d52ef5ef
---
title
:
Creat
e new branch from issue for repo-less project using new branch button
title
:
Creat
ing a new branch from an issue will automatically initialize a repository if one doesn't already exist.
merge_request
:
author
:
spec/controllers/projects/branches_controller_spec.rb
浏览文件 @
d52ef5ef
...
...
@@ -116,14 +116,7 @@ describe Projects::BranchesController do
it
'redirects to autodeploy setup page'
do
result
=
{
status: :success
,
branch:
double
(
name:
branch
)
}
project
.
create_kubernetes_service
(
active:
true
,
properties:
{
namespace:
project
.
path
,
api_url:
'https://kubernetes.example.com'
,
token:
'a'
*
40
,
}
)
project
.
services
<<
build
(
:kubernetes_service
)
expect_any_instance_of
(
CreateBranchService
).
to
receive
(
:execute
).
and_return
(
result
)
expect
(
SystemNoteService
).
to
receive
(
:new_issue_branch
).
and_return
(
true
)
...
...
@@ -135,6 +128,7 @@ describe Projects::BranchesController do
issue_iid:
issue
.
iid
expect
(
response
.
location
).
to
include
(
namespace_project_new_blob_path
(
project
.
namespace
,
project
,
branch
))
expect
(
response
).
to
have_http_status
(
302
)
end
end
...
...
spec/factories/services.rb
浏览文件 @
d52ef5ef
...
...
@@ -2,4 +2,14 @@ FactoryGirl.define do
factory
:service
do
project
factory: :empty_project
end
factory
:kubernetes_service
do
project
factory: :empty_project
active
true
properties
({
namespace:
'somepath'
,
api_url:
'https://kubernetes.example.com'
,
token:
'a'
*
40
,
})
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录