Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
faf2ce89
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,发现更多精彩内容 >>
提交
faf2ce89
编写于
5月 05, 2017
作者:
S
Sean McGivern
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'mrchrisw-import-shell-timeout'
上级
7e0e45db
0f1273fa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
2 deletion
+51
-2
changelogs/unreleased/mrchrisw-import-shell-timeout.yml
changelogs/unreleased/mrchrisw-import-shell-timeout.yml
+4
-0
config/gitlab.yml.example
config/gitlab.yml.example
+3
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
lib/gitlab/shell.rb
lib/gitlab/shell.rb
+2
-2
spec/lib/gitlab/shell_spec.rb
spec/lib/gitlab/shell_spec.rb
+41
-0
未找到文件。
changelogs/unreleased/mrchrisw-import-shell-timeout.yml
0 → 100644
浏览文件 @
faf2ce89
---
title
:
Add configurable timeout for git fetch and clone operations
merge_request
:
10697
author
:
config/gitlab.yml.example
浏览文件 @
faf2ce89
...
...
@@ -502,6 +502,9 @@ production: &base
upload_pack: true
receive_pack: true
# Git import/fetch timeout
# git_timeout: 800
# If you use non-standard ssh port you need to specify it
# ssh_port: 22
...
...
config/initializers/1_settings.rb
浏览文件 @
faf2ce89
...
...
@@ -386,6 +386,7 @@ Settings.gitlab_shell['ssh_port'] ||= 22
Settings
.
gitlab_shell
[
'ssh_user'
]
||=
Settings
.
gitlab
.
user
Settings
.
gitlab_shell
[
'owner_group'
]
||=
Settings
.
gitlab
.
user
Settings
.
gitlab_shell
[
'ssh_path_prefix'
]
||=
Settings
.
__send__
(
:build_gitlab_shell_ssh_path_prefix
)
Settings
.
gitlab_shell
[
'git_timeout'
]
||=
800
#
# Workhorse
...
...
lib/gitlab/shell.rb
浏览文件 @
faf2ce89
...
...
@@ -83,7 +83,7 @@ module Gitlab
# Timeout should be less than 900 ideally, to prevent the memory killer
# to silently kill the process without knowing we are timing out here.
output
,
status
=
Popen
.
popen
([
gitlab_shell_projects_path
,
'import-project'
,
storage
,
"
#{
name
}
.git"
,
url
,
'800'
])
storage
,
"
#{
name
}
.git"
,
url
,
"
#{
Gitlab
.
config
.
gitlab_shell
.
git_timeout
}
"
])
raise
Error
,
output
unless
status
.
zero?
true
end
...
...
@@ -99,7 +99,7 @@ module Gitlab
# fetch_remote("gitlab/gitlab-ci", "upstream")
#
def
fetch_remote
(
storage
,
name
,
remote
,
forced:
false
,
no_tags:
false
)
args
=
[
gitlab_shell_projects_path
,
'fetch-remote'
,
storage
,
"
#{
name
}
.git"
,
remote
,
'800'
]
args
=
[
gitlab_shell_projects_path
,
'fetch-remote'
,
storage
,
"
#{
name
}
.git"
,
remote
,
"
#{
Gitlab
.
config
.
gitlab_shell
.
git_timeout
}
"
]
args
<<
'--force'
if
forced
args
<<
'--no-tags'
if
no_tags
...
...
spec/lib/gitlab/shell_spec.rb
浏览文件 @
faf2ce89
...
...
@@ -91,4 +91,45 @@ describe Gitlab::Shell, lib: true do
end
end
end
describe
'projects commands'
do
let
(
:projects_path
)
{
'tmp/tests/shell-projects-test/bin/gitlab-projects'
}
before
do
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:path
).
and_return
(
'tmp/tests/shell-projects-test'
)
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:git_timeout
).
and_return
(
800
)
end
describe
'#fetch_remote'
do
it
'returns true when the command succeeds'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'fetch-remote'
,
'current/storage'
,
'project/path.git'
,
'new/storage'
,
'800'
]).
and_return
([
nil
,
0
])
expect
(
gitlab_shell
.
fetch_remote
(
'current/storage'
,
'project/path'
,
'new/storage'
)).
to
be
true
end
it
'raises an exception when the command fails'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'fetch-remote'
,
'current/storage'
,
'project/path.git'
,
'new/storage'
,
'800'
]).
and_return
([
"error"
,
1
])
expect
{
gitlab_shell
.
fetch_remote
(
'current/storage'
,
'project/path'
,
'new/storage'
)
}.
to
raise_error
(
Gitlab
::
Shell
::
Error
,
"error"
)
end
end
describe
'#import_repository'
do
it
'returns true when the command succeeds'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'import-project'
,
'current/storage'
,
'project/path.git'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
,
"800"
]).
and_return
([
nil
,
0
])
expect
(
gitlab_shell
.
import_repository
(
'current/storage'
,
'project/path'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
)).
to
be
true
end
it
'raises an exception when the command fails'
do
expect
(
Gitlab
::
Popen
).
to
receive
(
:popen
)
.
with
([
projects_path
,
'import-project'
,
'current/storage'
,
'project/path.git'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
,
"800"
]).
and_return
([
"error"
,
1
])
expect
{
gitlab_shell
.
import_repository
(
'current/storage'
,
'project/path'
,
'https://gitlab.com/gitlab-org/gitlab-ce.git'
)
}.
to
raise_error
(
Gitlab
::
Shell
::
Error
,
"error"
)
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录