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
a1491913
Commit
a1491913
authored
Nov 01, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refactor_gitlab_projects' of /home/git/repositories/gitlab/gitlab-shell
parents
06670e8a
7ba6725f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
25 deletions
+22
-25
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+18
-22
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+4
-3
No files found.
lib/gitlab_projects.rb
View file @
a1491913
...
@@ -48,38 +48,40 @@ class GitlabProjects
...
@@ -48,38 +48,40 @@ class GitlabProjects
def
create_branch
def
create_branch
branch_name
=
ARGV
.
shift
branch_name
=
ARGV
.
shift
ref
=
ARGV
.
shift
||
"HEAD"
ref
=
ARGV
.
shift
||
"HEAD"
cmd
=
"cd
#{
full_path
}
&& git branch
#{
branch_name
}
#{
ref
}
"
cmd
=
%W(git --git-dir=
#{
full_path
}
branch
#{
branch_name
}
#{
ref
}
)
system
(
cmd
)
system
(
*
cmd
)
end
end
def
rm_branch
def
rm_branch
branch_name
=
ARGV
.
shift
branch_name
=
ARGV
.
shift
cmd
=
"cd
#{
full_path
}
&& git branch -D
#{
branch_name
}
"
cmd
=
%W(git --git-dir=
#{
full_path
}
branch -D
#{
branch_name
}
)
system
(
cmd
)
system
(
*
cmd
)
end
end
def
create_tag
def
create_tag
tag_name
=
ARGV
.
shift
tag_name
=
ARGV
.
shift
ref
=
ARGV
.
shift
||
"HEAD"
ref
=
ARGV
.
shift
||
"HEAD"
cmd
=
"cd
#{
full_path
}
&& git tag
#{
tag_name
}
#{
ref
}
"
cmd
=
%W(git --git-dir=
#{
full_path
}
tag
#{
tag_name
}
#{
ref
}
)
system
(
cmd
)
system
(
*
cmd
)
end
end
def
rm_tag
def
rm_tag
tag_name
=
ARGV
.
shift
tag_name
=
ARGV
.
shift
cmd
=
"cd
#{
full_path
}
&& git tag -d
#{
tag_name
}
"
cmd
=
%W(git --git-dir=
#{
full_path
}
tag -d
#{
tag_name
}
)
system
(
cmd
)
system
(
*
cmd
)
end
end
def
add_project
def
add_project
$logger
.
info
"Adding project
#{
@project_name
}
at <
#{
full_path
}
>."
$logger
.
info
"Adding project
#{
@project_name
}
at <
#{
full_path
}
>."
FileUtils
.
mkdir_p
(
full_path
,
mode:
0770
)
FileUtils
.
mkdir_p
(
full_path
,
mode:
0770
)
cmd
=
"cd
#{
full_path
}
&& git init --bare &&
#{
create_hooks_cmd
}
"
cmd
=
%W(git --git-dir=
#{
full_path
}
init --bare)
system
(
cmd
)
system
(
*
cmd
)
&&
create_hooks
(
full_path
)
end
end
def
create_hooks_cmd
def
create_hooks
(
path
)
create_hooks_to
(
full_path
)
hook
=
File
.
join
(
path
,
'hooks'
,
'update'
)
File
.
delete
(
hook
)
if
File
.
exists?
(
hook
)
File
.
symlink
(
File
.
join
(
ROOT_PATH
,
'hooks'
,
'update'
),
hook
)
end
end
def
rm_project
def
rm_project
...
@@ -92,8 +94,8 @@ class GitlabProjects
...
@@ -92,8 +94,8 @@ class GitlabProjects
def
import_project
def
import_project
@source
=
ARGV
.
shift
@source
=
ARGV
.
shift
$logger
.
info
"Importing project
#{
@project_name
}
from <
#{
@source
}
> to <
#{
full_path
}
>."
$logger
.
info
"Importing project
#{
@project_name
}
from <
#{
@source
}
> to <
#{
full_path
}
>."
cmd
=
"cd
#{
repos_path
}
&& git clone --bare
#{
@source
}
#{
project_name
}
&&
#{
create_hooks_cmd
}
"
cmd
=
%W(git clone --bare
#{
@source
}
#{
project_name
}
)
system
(
cmd
)
system
(
*
cmd
,
chdir:
repos_path
)
&&
create_hooks
(
full_path
)
end
end
# Move repository from one directory to another
# Move repository from one directory to another
...
@@ -154,8 +156,8 @@ class GitlabProjects
...
@@ -154,8 +156,8 @@ class GitlabProjects
end
end
$logger
.
info
"Forking project from <
#{
full_path
}
> to <
#{
full_destination_path
}
>."
$logger
.
info
"Forking project from <
#{
full_path
}
> to <
#{
full_destination_path
}
>."
cmd
=
"cd
#{
namespaced_path
}
&& git clone --bare
#{
full_path
}
&&
#{
create_hooks_to
(
full_destination_path
)
}
"
cmd
=
%W(git clone --bare
#{
full_path
}
)
system
(
cmd
)
system
(
*
cmd
,
chdir:
namespaced_path
)
&&
create_hooks
(
full_destination_path
)
end
end
def
update_head
def
update_head
...
@@ -178,10 +180,4 @@ class GitlabProjects
...
@@ -178,10 +180,4 @@ class GitlabProjects
$logger
.
info
"Update head in project
#{
project_name
}
to <
#{
new_head
}
>."
$logger
.
info
"Update head in project
#{
project_name
}
to <
#{
new_head
}
>."
true
true
end
end
private
def
create_hooks_to
(
dest_path
)
"ln -s
#{
File
.
join
(
ROOT_PATH
,
'hooks'
,
'update'
)
}
#{
dest_path
}
/hooks/update"
end
end
end
spec/gitlab_projects_spec.rb
View file @
a1491913
...
@@ -95,14 +95,15 @@ describe GitlabProjects do
...
@@ -95,14 +95,15 @@ describe GitlabProjects do
it
"should create a directory"
do
it
"should create a directory"
do
gl_projects
.
stub
(
system:
true
)
gl_projects
.
stub
(
system:
true
)
gl_projects
.
stub
(
create_hooks:
true
)
gl_projects
.
exec
gl_projects
.
exec
File
.
exists?
(
tmp_repo_path
).
should
be_true
File
.
exists?
(
tmp_repo_path
).
should
be_true
end
end
it
"should receive valid cmd"
do
it
"should receive valid cmd"
do
valid_cmd
=
"cd
#{
tmp_repo_path
}
&& git init --bare"
valid_cmd
=
[
'git'
,
"--git-dir=
#{
tmp_repo_path
}
"
,
'init'
,
'--bare'
]
valid_cmd
<<
" && ln -s
#{
ROOT_PATH
}
/hooks/update
#{
tmp_repo_path
}
/hooks/update"
gl_projects
.
should_receive
(
:system
).
with
(
*
valid_cmd
).
and_return
(
true
)
gl_projects
.
should_receive
(
:
system
).
with
(
valid_cmd
)
gl_projects
.
should_receive
(
:
create_hooks
).
with
(
tmp_repo_path
)
gl_projects
.
exec
gl_projects
.
exec
end
end
...
...
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