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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-shell
Commits
db79c32e
Commit
db79c32e
authored
Oct 31, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #87 from bobot/master
Execute command directly without using shell
parents
be2f82b0
d64ddc87
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+8
-8
spec/gitlab_shell_spec.rb
spec/gitlab_shell_spec.rb
+2
-2
No files found.
lib/gitlab_shell.rb
View file @
db79c32e
require
'open3'
require
'shellwords'
require_relative
'gitlab_net'
...
...
@@ -40,9 +41,9 @@ class GitlabShell
protected
def
parse_cmd
args
=
@origin_cmd
.
split
(
' '
)
@git_cmd
=
args
.
shift
@repo_name
=
args
.
shift
args
=
Shellwords
.
shellwords
(
@origin_cmd
)
@git_cmd
=
args
[
0
]
@repo_name
=
args
[
1
]
end
def
git_cmds
...
...
@@ -51,17 +52,16 @@ class GitlabShell
def
process_cmd
repo_full_path
=
File
.
join
(
repos_path
,
repo_name
)
cmd
=
"
#{
@git_cmd
}
#{
repo_full_path
}
"
$logger
.
info
"gitlab-shell: executing git command <
#{
cmd
}
> for
#{
log_username
}
."
exec_cmd
(
cmd
)
$logger
.
info
"gitlab-shell: executing git command <
#{
@git_cmd
}
#{
repo_full_path
}
> for
#{
log_username
}
."
exec_cmd
(
@git_cmd
,
repo_full_path
)
end
def
validate_access
api
.
allowed?
(
@git_cmd
,
@repo_name
,
@key_id
,
'_any'
)
end
def
exec_cmd
args
Kernel
::
exec
args
def
exec_cmd
*
args
Kernel
::
exec
*
args
end
def
api
...
...
spec/gitlab_shell_spec.rb
View file @
db79c32e
...
...
@@ -60,7 +60,7 @@ describe GitlabShell do
end
it
"should execute the command"
do
subject
.
should_receive
(
:exec_cmd
).
with
(
"git-upload-pack
#{
File
.
join
(
repository_path
,
'gitlab-ci.git'
)
}
"
)
subject
.
should_receive
(
:exec_cmd
).
with
(
"git-upload-pack
"
,
File
.
join
(
repository_path
,
'gitlab-ci.git'
)
)
end
it
"should set the GL_ID environment variable"
do
...
...
@@ -89,7 +89,7 @@ describe GitlabShell do
end
it
"should execute the command"
do
subject
.
should_receive
(
:exec_cmd
).
with
(
"git-receive-pack
#{
File
.
join
(
repository_path
,
'gitlab-ci.git'
)
}
"
)
subject
.
should_receive
(
:exec_cmd
).
with
(
"git-receive-pack
"
,
File
.
join
(
repository_path
,
'gitlab-ci.git'
)
)
end
it
"should log the command execution"
do
...
...
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