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
488a0340
Commit
488a0340
authored
Jun 10, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update head feature
parent
79c58482
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
bin/gitlab-projects
bin/gitlab-projects
+2
-0
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+22
-1
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+21
-0
No files found.
bin/gitlab-projects
View file @
488a0340
...
@@ -17,6 +17,8 @@ require_relative '../lib/gitlab_init'
...
@@ -17,6 +17,8 @@ require_relative '../lib/gitlab_init'
#
#
# /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
#
#
# /bin/gitlab-projects update-head gitlab/gitlab-ci.git 5-2-stable
#
require
File
.
join
(
ROOT_PATH
,
'lib'
,
'gitlab_projects'
)
require
File
.
join
(
ROOT_PATH
,
'lib'
,
'gitlab_projects'
)
# Return non-zero if command execution was not successful
# Return non-zero if command execution was not successful
...
...
lib/gitlab_projects.rb
View file @
488a0340
...
@@ -31,6 +31,7 @@ class GitlabProjects
...
@@ -31,6 +31,7 @@ class GitlabProjects
when
'mv-project'
;
mv_project
when
'mv-project'
;
mv_project
when
'import-project'
;
import_project
when
'import-project'
;
import_project
when
'fork-project'
;
fork_project
when
'fork-project'
;
fork_project
when
'update-head'
;
update_head
else
else
$logger
.
warn
"Attempt to execute invalid gitlab-projects command
#{
@command
.
inspect
}
."
$logger
.
warn
"Attempt to execute invalid gitlab-projects command
#{
@command
.
inspect
}
."
puts
'not allowed'
puts
'not allowed'
...
@@ -127,6 +128,27 @@ class GitlabProjects
...
@@ -127,6 +128,27 @@ class GitlabProjects
system
(
cmd
)
system
(
cmd
)
end
end
def
update_head
new_head
=
ARGV
.
shift
unless
new_head
$logger
.
error
"update-head failed: no branch provided."
return
false
end
unless
File
.
exists?
(
File
.
join
(
full_path
,
'refs/heads'
,
new_head
))
$logger
.
error
"update-head failed: specified branch does not exist in ref/heads."
return
false
end
File
.
open
(
File
.
join
(
full_path
,
'HEAD'
),
'w'
)
do
|
f
|
f
.
write
(
"ref: refs/heads/
#{
new_head
}
"
)
end
$logger
.
info
"Update head in project
#{
project_name
}
to <
#{
new_head
}
>."
true
end
private
private
def
create_hooks_to
(
dest_path
)
def
create_hooks_to
(
dest_path
)
...
@@ -135,5 +157,4 @@ class GitlabProjects
...
@@ -135,5 +157,4 @@ class GitlabProjects
"ln -s
#{
pr_hook_path
}
#{
dest_path
}
/hooks/post-receive && ln -s
#{
up_hook_path
}
#{
dest_path
}
/hooks/update"
"ln -s
#{
pr_hook_path
}
#{
dest_path
}
/hooks/post-receive && ln -s
#{
up_hook_path
}
#{
dest_path
}
/hooks/update"
end
end
end
end
spec/gitlab_projects_spec.rb
View file @
488a0340
...
@@ -106,6 +106,27 @@ describe GitlabProjects do
...
@@ -106,6 +106,27 @@ describe GitlabProjects do
end
end
end
end
describe
:update_head
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'update-head'
,
repo_name
,
'stable'
)
}
before
do
FileUtils
.
mkdir_p
(
tmp_repo_path
)
system
(
"git init --bare
#{
tmp_repo_path
}
"
)
system
(
"touch
#{
tmp_repo_path
}
/refs/heads/stable"
)
File
.
read
(
File
.
join
(
tmp_repo_path
,
'HEAD'
)).
strip
.
should
==
'ref: refs/heads/master'
end
it
"should update head for repo"
do
gl_projects
.
exec
.
should
be_true
File
.
read
(
File
.
join
(
tmp_repo_path
,
'HEAD'
)).
strip
.
should
==
'ref: refs/heads/stable'
end
it
"should log an update_head event"
do
$logger
.
should_receive
(
:info
).
with
(
"Update head in project
#{
repo_name
}
to <stable>."
)
gl_projects
.
exec
end
end
describe
:import_project
do
describe
:import_project
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'
)
}
...
...
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