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
02b960c9
Commit
02b960c9
authored
Feb 25, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make GitlabProjects#create_hooks a class method
parent
56e216f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+9
-9
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+2
-2
No files found.
lib/gitlab_projects.rb
View file @
02b960c9
...
...
@@ -16,6 +16,12 @@ class GitlabProjects
# Ex /home/git/repositories/test.git
attr_reader
:full_path
def
self
.
create_hooks
(
path
)
hook
=
File
.
join
(
path
,
'hooks'
,
'update'
)
File
.
delete
(
hook
)
if
File
.
exists?
(
hook
)
File
.
symlink
(
File
.
join
(
ROOT_PATH
,
'hooks'
,
'update'
),
hook
)
end
def
initialize
@command
=
ARGV
.
shift
@project_name
=
ARGV
.
shift
...
...
@@ -74,13 +80,7 @@ class GitlabProjects
$logger
.
info
"Adding project
#{
@project_name
}
at <
#{
full_path
}
>."
FileUtils
.
mkdir_p
(
full_path
,
mode:
0770
)
cmd
=
%W(git --git-dir=
#{
full_path
}
init --bare)
system
(
*
cmd
)
&&
create_hooks
(
full_path
)
end
def
create_hooks
(
path
)
hook
=
File
.
join
(
path
,
'hooks'
,
'update'
)
File
.
delete
(
hook
)
if
File
.
exists?
(
hook
)
File
.
symlink
(
File
.
join
(
ROOT_PATH
,
'hooks'
,
'update'
),
hook
)
system
(
*
cmd
)
&&
self
.
class
.
create_hooks
(
full_path
)
end
def
rm_project
...
...
@@ -94,7 +94,7 @@ class GitlabProjects
@source
=
ARGV
.
shift
$logger
.
info
"Importing project
#{
@project_name
}
from <
#{
@source
}
> to <
#{
full_path
}
>."
cmd
=
%W(git clone --bare --
#{
@source
}
#{
full_path
}
)
system
(
*
cmd
)
&&
create_hooks
(
full_path
)
system
(
*
cmd
)
&&
self
.
class
.
create_hooks
(
full_path
)
end
# Move repository from one directory to another
...
...
@@ -156,7 +156,7 @@ class GitlabProjects
$logger
.
info
"Forking project from <
#{
full_path
}
> to <
#{
full_destination_path
}
>."
cmd
=
%W(git clone --bare --
#{
full_path
}
#{
full_destination_path
}
)
system
(
*
cmd
)
&&
create_hooks
(
full_destination_path
)
system
(
*
cmd
)
&&
self
.
class
.
create_hooks
(
full_destination_path
)
end
def
update_head
...
...
spec/gitlab_projects_spec.rb
View file @
02b960c9
...
...
@@ -95,7 +95,7 @@ describe GitlabProjects do
it
"should create a directory"
do
gl_projects
.
stub
(
system:
true
)
gl_p
rojects
.
stub
(
create_hooks:
true
)
GitlabP
rojects
.
stub
(
create_hooks:
true
)
gl_projects
.
exec
File
.
exists?
(
tmp_repo_path
).
should
be_true
end
...
...
@@ -103,7 +103,7 @@ describe GitlabProjects do
it
"should receive valid cmd"
do
valid_cmd
=
[
'git'
,
"--git-dir=
#{
tmp_repo_path
}
"
,
'init'
,
'--bare'
]
gl_projects
.
should_receive
(
:system
).
with
(
*
valid_cmd
).
and_return
(
true
)
gl_p
rojects
.
should_receive
(
:create_hooks
).
with
(
tmp_repo_path
)
GitlabP
rojects
.
should_receive
(
:create_hooks
).
with
(
tmp_repo_path
)
gl_projects
.
exec
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