Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
37db76a3
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,发现更多精彩内容 >>
未验证
提交
37db76a3
编写于
3月 12, 2014
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Project import and retry import scaffold
Signed-off-by:
N
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
上级
1436433c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
89 addition
and
55 deletion
+89
-55
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+25
-12
app/views/projects/create.js.haml
app/views/projects/create.js.haml
+6
-2
app/views/projects/empty.html.haml
app/views/projects/empty.html.haml
+29
-41
app/views/projects/import.html.haml
app/views/projects/import.html.haml
+29
-0
未找到文件。
app/controllers/projects_controller.rb
浏览文件 @
37db76a3
...
@@ -5,7 +5,7 @@ class ProjectsController < ApplicationController
...
@@ -5,7 +5,7 @@ class ProjectsController < ApplicationController
# Authorize
# Authorize
before_filter
:authorize_read_project!
,
except:
[
:index
,
:new
,
:create
]
before_filter
:authorize_read_project!
,
except:
[
:index
,
:new
,
:create
]
before_filter
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:destroy
,
:transfer
,
:archive
,
:unarchive
]
before_filter
:authorize_admin_project!
,
only:
[
:edit
,
:update
,
:destroy
,
:transfer
,
:archive
,
:unarchive
,
:retry_import
]
before_filter
:require_non_empty_project
,
only:
[
:blob
,
:tree
,
:graph
]
before_filter
:require_non_empty_project
,
only:
[
:blob
,
:tree
,
:graph
]
layout
'navless'
,
only:
[
:new
,
:create
,
:fork
]
layout
'navless'
,
only:
[
:new
,
:create
,
:fork
]
...
@@ -21,16 +21,9 @@ class ProjectsController < ApplicationController
...
@@ -21,16 +21,9 @@ class ProjectsController < ApplicationController
def
create
def
create
@project
=
::
Projects
::
CreateService
.
new
(
current_user
,
params
[
:project
]).
execute
@project
=
::
Projects
::
CreateService
.
new
(
current_user
,
params
[
:project
]).
execute
flash
[
:notice
]
=
'Project was successfully created.'
if
@project
.
saved?
respond_to
do
|
format
|
respond_to
do
|
format
|
flash
[
:notice
]
=
'Project was successfully created.'
if
@project
.
saved?
format
.
html
do
if
@project
.
saved?
redirect_to
@project
else
render
"new"
end
end
format
.
js
format
.
js
end
end
end
end
...
@@ -67,9 +60,7 @@ class ProjectsController < ApplicationController
...
@@ -67,9 +60,7 @@ class ProjectsController < ApplicationController
if
@project
.
empty_repo?
if
@project
.
empty_repo?
render
"projects/empty"
,
layout:
user_layout
render
"projects/empty"
,
layout:
user_layout
else
else
if
current_user
@last_push
=
current_user
.
recent_push
(
@project
.
id
)
if
current_user
@last_push
=
current_user
.
recent_push
(
@project
.
id
)
end
render
:show
,
layout:
user_layout
render
:show
,
layout:
user_layout
end
end
end
end
...
@@ -77,6 +68,28 @@ class ProjectsController < ApplicationController
...
@@ -77,6 +68,28 @@ class ProjectsController < ApplicationController
end
end
end
end
def
import
if
project
.
import_finished?
redirect_to
@project
return
end
end
def
retry_import
unless
@project
.
import_failed?
redirect_to
import_project_path
(
@project
)
end
@project
.
import_url
=
params
[
:project
][
:import_url
]
if
@project
.
save
@project
.
reload
@project
.
import_retry
end
redirect_to
import_project_path
(
@project
)
end
def
destroy
def
destroy
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
project
)
return
access_denied!
unless
can?
(
current_user
,
:remove_project
,
project
)
...
...
app/views/projects/create.js.haml
浏览文件 @
37db76a3
-
if
@project
.
saved?
-
if
@project
.
saved?
:plain
-
if
@project
.
import?
location.href = "
#{
project_path
(
@project
)
}
";
:plain
location.href = "
#{
import_project_path
(
@project
)
}
";
-
else
:plain
location.href = "
#{
project_path
(
@project
)
}
";
-
else
-
else
:plain
:plain
$(".project-edit-errors").html("
#{
escape_javascript
(
render
(
'errors'
))
}
");
$(".project-edit-errors").html("
#{
escape_javascript
(
render
(
'errors'
))
}
");
...
...
app/views/projects/empty.html.haml
浏览文件 @
37db76a3
=
render
"home_panel"
=
render
"home_panel"
-
if
@project
.
import?
&&
!
@project
.
imported
%div
.git-empty
.save-project-loader
%fieldset
%center
%legend
Git global setup:
%h2
%pre
.dark
%i
.icon-spinner.icon-spin
:preserve
Importing repository.
git config --global user.name "
#{
git_user_name
}
"
%p
.monospace
git clone --bare
#{
@project
.
import_url
}
git config --global user.email "
#{
git_user_email
}
"
%p
Please wait while we import the repository for you. Refresh at will.
:javascript
new
ProjectImport
();
-
else
%fieldset
%div
.git-empty
%legend
Create Repository
%fieldset
%pre
.dark
%legend
Git global setup:
:preserve
%pre
.dark
mkdir
#{
@project
.
path
}
:preserve
cd
#{
@project
.
path
}
git config --global user.name "
#{
git_user_name
}
"
git init
git config --global user.email "
#{
git_user_email
}
"
touch README
git add README
git commit -m 'first commit'
git remote add origin
#{
content_tag
(
:span
,
default_url_to_repo
,
class:
'clone'
)
}
git push -u origin master
%fieldset
%fieldset
%legend
Create Repository
%legend
Existing Git Repo?
%pre
.dark
%pre
.dark
:preserve
:preserve
mkdir
#{
@project
.
path
}
cd existing_git_repo
cd
#{
@project
.
path
}
git remote add origin
#{
content_tag
(
:span
,
default_url_to_repo
,
class:
'clone'
)
}
git init
git push -u origin master
touch README
git add README
git commit -m 'first commit'
git remote add origin
#{
content_tag
(
:span
,
default_url_to_repo
,
class:
'clone'
)
}
git push -u origin master
%fieldset
-
if
can?
current_user
,
:remove_project
,
@project
%legend
Existing Git Repo?
.prepend-top-20
%pre
.dark
=
link_to
'Remove project'
,
@project
,
data:
{
confirm:
remove_project_message
(
@project
)},
method: :delete
,
class:
"btn btn-remove pull-right"
:preserve
cd existing_git_repo
git remote add origin
#{
content_tag
(
:span
,
default_url_to_repo
,
class:
'clone'
)
}
git push -u origin master
-
if
can?
current_user
,
:remove_project
,
@project
.prepend-top-20
=
link_to
'Remove project'
,
@project
,
data:
{
confirm:
remove_project_message
(
@project
)},
method: :delete
,
class:
"btn btn-remove pull-right"
app/views/projects/import.html.haml
0 → 100644
浏览文件 @
37db76a3
-
if
@project
.
import_in_progress?
.save-project-loader
%center
%h2
%i
.icon-spinner.icon-spin
Import in progress.
%p
.monospace
git clone --bare
#{
@project
.
import_url
}
%p
Please wait while we import the repository for you. Refresh at will.
:javascript
new
ProjectImport
();
-
elsif
@project
.
import_failed?
.save-project-loader
%center
%h2
Import failed. Retry?
%hr
=
form_for
@project
,
url:
retry_import_project_path
(
@project
),
method: :put
,
html:
{
class:
'form-horizontal'
}
do
|
f
|
.form-group.import-url-data
=
f
.
label
:import_url
,
class:
'control-label'
do
%span
Import existing repo
.col-sm-10
=
f
.
text_field
:import_url
,
class:
'form-control'
,
placeholder:
'https://github.com/randx/six.git'
.bs-callout.bs-callout-info
This url must be publicly accessible or you can add a username and password like this: https://username:password@gitlab.com/company/project.git.
%br
The import will time out after 2 minutes. For big repositories, use a clone/push combination.
.form-actions
=
f
.
submit
'Retry import'
,
class:
"btn btn-create"
,
tabindex:
4
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录