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
05e2c435
Commit
05e2c435
authored
Jul 08, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #69 from thomasbiddle/support_adding_and_removing_branches_and_tags
Support adding and removing branches and tags
parents
e049749a
66cfc50f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
0 deletions
+98
-0
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+30
-0
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+68
-0
No files found.
lib/gitlab_projects.rb
View file @
05e2c435
...
...
@@ -26,6 +26,10 @@ class GitlabProjects
def
exec
case
@command
when
'create-branch'
;
create_branch
when
'rm-branch'
;
rm_branch
when
'create-tag'
;
create_tag
when
'rm-tag'
;
rm_tag
when
'add-project'
;
add_project
when
'rm-project'
;
rm_project
when
'mv-project'
;
mv_project
...
...
@@ -41,6 +45,32 @@ class GitlabProjects
protected
def
create_branch
branch_name
=
ARGV
.
shift
ref
=
ARGV
.
shift
||
"HEAD"
cmd
=
"cd
#{
full_path
}
&& git branch
#{
branch_name
}
#{
ref
}
"
system
(
cmd
)
end
def
rm_branch
branch_name
=
ARGV
.
shift
cmd
=
"cd
#{
full_path
}
&& git branch -D
#{
branch_name
}
"
system
(
cmd
)
end
def
create_tag
tag_name
=
ARGV
.
shift
ref
=
ARGV
.
shift
||
"HEAD"
cmd
=
"cd
#{
full_path
}
&& git tag
#{
tag_name
}
#{
ref
}
"
system
(
cmd
)
end
def
rm_tag
tag_name
=
ARGV
.
shift
cmd
=
"cd
#{
full_path
}
&& git tag -d
#{
tag_name
}
"
system
(
cmd
)
end
def
add_project
$logger
.
info
"Adding project
#{
@project_name
}
at <
#{
full_path
}
>."
FileUtils
.
mkdir_p
(
full_path
,
mode:
0770
)
...
...
spec/gitlab_projects_spec.rb
View file @
05e2c435
...
...
@@ -22,6 +22,74 @@ describe GitlabProjects do
it
{
@gl_projects
.
instance_variable_get
(
:@full_path
).
should
==
"
#{
GitlabConfig
.
new
.
repos_path
}
/gitlab-ci.git"
}
end
describe
:create_branch
do
let
(
:gl_projects_create
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'create-branch'
,
repo_name
,
'test_branch'
,
'master'
)
}
it
"should create a branch"
do
gl_projects_create
.
exec
gl_projects
.
exec
branch_ref
=
`cd
#{
tmp_repo_path
}
&& git rev-parse test_branch`
.
strip
master_ref
=
`cd
#{
tmp_repo_path
}
&& git rev-parse master`
.
strip
branch_ref
.
should
==
master_ref
end
end
describe
:rm_branch
do
let
(
:gl_projects_create
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects_create_branch
)
{
build_gitlab_projects
(
'create-branch'
,
repo_name
,
'test_branch'
,
'master'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'rm-branch'
,
repo_name
,
'test_branch'
)
}
it
"should remove a branch"
do
gl_projects_create
.
exec
gl_projects_create_branch
.
exec
branch_ref
=
`cd
#{
tmp_repo_path
}
&& git rev-parse test_branch`
.
strip
gl_projects
.
exec
branch_del
=
`cd
#{
tmp_repo_path
}
&& git rev-parse test_branch`
.
strip
branch_del
.
should_not
==
branch_ref
end
end
describe
:create_tag
do
let
(
:gl_projects_create
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'create-tag'
,
repo_name
,
'test_tag'
,
'master'
)
}
it
"should create a tag"
do
gl_projects_create
.
exec
gl_projects
.
exec
tag_ref
=
`cd
#{
tmp_repo_path
}
&& git rev-parse test_tag`
.
strip
master_ref
=
`cd
#{
tmp_repo_path
}
&& git rev-parse master`
.
strip
tag_ref
.
should
==
master_ref
end
end
describe
:rm_tag
do
let
(
:gl_projects_create
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects_create_tag
)
{
build_gitlab_projects
(
'create-tag'
,
repo_name
,
'test_tag'
,
'master'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'rm-tag'
,
repo_name
,
'test_tag'
)
}
it
"should remove a branch"
do
gl_projects_create
.
exec
gl_projects_create_tag
.
exec
branch_ref
=
`cd
#{
tmp_repo_path
}
&& git rev-parse test_tag`
.
strip
gl_projects
.
exec
branch_del
=
`cd
#{
tmp_repo_path
}
&& git rev-parse test_tag`
.
strip
branch_del
.
should_not
==
branch_ref
end
end
describe
:add_project
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'add-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