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
nexedi
gitlab-shell
Commits
26147a3a
Commit
26147a3a
authored
Mar 12, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mv-project feature added
parent
9d03bb10
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
0 deletions
+43
-0
bin/gitlab-projects
bin/gitlab-projects
+2
-0
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+26
-0
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+15
-0
No files found.
bin/gitlab-projects
View file @
26147a3a
...
@@ -11,6 +11,8 @@ require_relative '../lib/gitlab_init'
...
@@ -11,6 +11,8 @@ require_relative '../lib/gitlab_init'
#
#
# /bin/gitlab-projects rm-project gitlab/gitlab-ci.git
# /bin/gitlab-projects rm-project gitlab/gitlab-ci.git
#
#
# /bin/gitlab-projects mv-project gitlab/gitlab-ci.git randx/fork.git
#
# /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
#
#
require
File
.
join
(
ROOT_PATH
,
'lib'
,
'gitlab_projects'
)
require
File
.
join
(
ROOT_PATH
,
'lib'
,
'gitlab_projects'
)
...
...
lib/gitlab_projects.rb
View file @
26147a3a
...
@@ -27,6 +27,7 @@ class GitlabProjects
...
@@ -27,6 +27,7 @@ class GitlabProjects
case
@command
case
@command
when
'add-project'
;
add_project
when
'add-project'
;
add_project
when
'rm-project'
;
rm_project
when
'rm-project'
;
rm_project
when
'mv-project'
;
mv_project
when
'import-project'
;
import_project
when
'import-project'
;
import_project
else
else
puts
'not allowed'
puts
'not allowed'
...
@@ -52,9 +53,34 @@ class GitlabProjects
...
@@ -52,9 +53,34 @@ class GitlabProjects
FileUtils
.
rm_rf
(
full_path
)
FileUtils
.
rm_rf
(
full_path
)
end
end
# Import project via git clone --bare
# URL must be publicly clonable
def
import_project
def
import_project
@source
=
ARGV
.
shift
@source
=
ARGV
.
shift
cmd
=
"cd
#{
repos_path
}
&& git clone --bare
#{
@source
}
#{
project_name
}
&&
#{
create_hooks_cmd
}
"
cmd
=
"cd
#{
repos_path
}
&& git clone --bare
#{
@source
}
#{
project_name
}
&&
#{
create_hooks_cmd
}
"
system
(
cmd
)
system
(
cmd
)
end
end
# Move repository from one directory to another
#
# Ex.
# gitlab.git -> gitlabhq.git
# gitlab/gitlab-ci.git -> randx/six.git
#
# Wont work if target namespace directory does not exist
#
def
mv_project
new_path
=
ARGV
.
shift
return
false
unless
new_path
new_full_path
=
File
.
join
(
repos_path
,
new_path
)
# check if source repo exists
# and target repo does not exist
return
false
unless
File
.
exists?
(
full_path
)
return
false
if
File
.
exists?
(
new_full_path
)
FileUtils
.
mv
(
full_path
,
new_full_path
)
end
end
end
spec/gitlab_projects_spec.rb
View file @
26147a3a
...
@@ -39,6 +39,21 @@ describe GitlabProjects do
...
@@ -39,6 +39,21 @@ describe GitlabProjects do
end
end
end
end
describe
:mv_project
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'mv-project'
,
repo_name
,
'repo.git'
)
}
before
do
FileUtils
.
mkdir_p
(
tmp_repo_path
)
end
it
"should move a repo directory"
do
File
.
exists?
(
tmp_repo_path
).
should
be_true
gl_projects
.
exec
File
.
exists?
(
tmp_repo_path
).
should
be_false
File
.
exists?
(
File
.
join
(
tmp_repos_path
,
'repo.git'
)).
should
be_true
end
end
describe
:rm_project
do
describe
:rm_project
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'rm-project'
,
repo_name
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'rm-project'
,
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