Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-shell
Commits
0f4ad24f
Commit
0f4ad24f
authored
Mar 12, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'import-timeout' into 'master'
Import Timeout
parents
d207d69b
323545fc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
11 deletions
+57
-11
CHANGELOG
CHANGELOG
+3
-0
README.md
README.md
+5
-1
VERSION
VERSION
+1
-1
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+19
-1
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+29
-8
No files found.
CHANGELOG
View file @
0f4ad24f
v1.8.3
- Add timeout option for repository import
v1.8.2
v1.8.2
- Fix broken 1.8.1
- Fix broken 1.8.1
...
...
README.md
View file @
0f4ad24f
...
@@ -36,8 +36,12 @@ Remove repo
...
@@ -36,8 +36,12 @@ Remove repo
Import repo
Import repo
# Default timeout is 2 minutes
./bin/gitlab-projects import-project randx/six.git https://github.com/randx/six.git
./bin/gitlab-projects import-project randx/six.git https://github.com/randx/six.git
# Override timeout in seconds
./bin/gitlab-projects import-project randx/six.git https://github.com/randx/six.git 90
Fork repo
Fork repo
./bin/gitlab-projects fork-project gitlab/gitlab-ci.git randx
./bin/gitlab-projects fork-project gitlab/gitlab-ci.git randx
...
...
VERSION
View file @
0f4ad24f
1.8.
2
1.8.
3
lib/gitlab_projects.rb
View file @
0f4ad24f
require
'fileutils'
require
'fileutils'
require
'timeout'
require_relative
'gitlab_config'
require_relative
'gitlab_config'
require_relative
'gitlab_logger'
require_relative
'gitlab_logger'
...
@@ -92,9 +93,26 @@ class GitlabProjects
...
@@ -92,9 +93,26 @@ class GitlabProjects
# URL must be publicly cloneable
# URL must be publicly cloneable
def
import_project
def
import_project
@source
=
ARGV
.
shift
@source
=
ARGV
.
shift
# timeout for clone
timeout
=
(
ARGV
.
shift
||
120
).
to_i
$logger
.
info
"Importing project
#{
@project_name
}
from <
#{
@source
}
> to <
#{
full_path
}
>."
$logger
.
info
"Importing project
#{
@project_name
}
from <
#{
@source
}
> to <
#{
full_path
}
>."
cmd
=
%W(git clone --bare --
#{
@source
}
#{
full_path
}
)
cmd
=
%W(git clone --bare --
#{
@source
}
#{
full_path
}
)
system
(
*
cmd
)
&&
self
.
class
.
create_hooks
(
full_path
)
pid
=
Process
.
spawn
(
*
cmd
)
begin
Timeout
.
timeout
(
timeout
)
do
Process
.
wait
(
pid
)
end
rescue
Timeout
::
Error
Process
.
kill
(
'KILL'
,
pid
)
$logger
.
error
"Importing project
#{
@project_name
}
from <
#{
@source
}
> failed due to timeout."
FileUtils
.
rm_rf
(
full_path
)
false
else
self
.
class
.
create_hooks
(
full_path
)
end
end
end
# Move repository from one directory to another
# Move repository from one directory to another
...
...
spec/gitlab_projects_spec.rb
View file @
0f4ad24f
...
@@ -196,8 +196,11 @@ describe GitlabProjects do
...
@@ -196,8 +196,11 @@ describe GitlabProjects do
end
end
describe
:import_project
do
describe
:import_project
do
context
'success import'
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/randx/six.git'
)
}
it
{
gl_projects
.
exec
.
should
be_true
}
it
"should import a repo"
do
it
"should import a repo"
do
gl_projects
.
exec
gl_projects
.
exec
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'HEAD'
)).
should
be_true
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'HEAD'
)).
should
be_true
...
@@ -210,6 +213,24 @@ describe GitlabProjects do
...
@@ -210,6 +213,24 @@ describe GitlabProjects do
end
end
end
end
context
'timeout'
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/gitlabhq/gitlabhq.git'
,
'1'
)
}
it
{
gl_projects
.
exec
.
should
be_false
}
it
"should not import a repo"
do
gl_projects
.
exec
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'HEAD'
)).
should
be_false
end
it
"should log an import-project event"
do
message
=
"Importing project
#{
repo_name
}
from <https://github.com/gitlabhq/gitlabhq.git> failed due to timeout."
$logger
.
should_receive
(
:error
).
with
(
message
)
gl_projects
.
exec
end
end
end
describe
:fork_project
do
describe
:fork_project
do
let
(
:source_repo_name
)
{
File
.
join
(
'source-namespace'
,
repo_name
)
}
let
(
:source_repo_name
)
{
File
.
join
(
'source-namespace'
,
repo_name
)
}
let
(
:dest_repo
)
{
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
)
}
let
(
:dest_repo
)
{
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
)
}
...
...
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