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
7d4ae819
Commit
7d4ae819
authored
Apr 06, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor GitlabShell#exec a bit.
parent
b5757b74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+9
-7
No files found.
lib/gitlab_shell.rb
View file @
7d4ae819
...
...
@@ -7,6 +7,8 @@ class GitlabShell
class
DisallowedCommandError
<
StandardError
;
end
class
InvalidRepositoryPathError
<
StandardError
;
end
GIT_COMMANDS
=
%w(git-upload-pack git-receive-pack git-upload-archive git-annex-shell)
.
freeze
attr_accessor
:key_id
,
:repo_name
,
:git_cmd
,
:repos_path
,
:repo_name
def
initialize
(
key_id
,
origin_cmd
)
...
...
@@ -24,11 +26,7 @@ class GitlabShell
parse_cmd
raise
DisallowedCommandError
unless
git_cmds
.
include?
(
@git_cmd
)
status
=
api
.
check_access
(
@git_cmd
,
@repo_name
,
@key_id
,
'_any'
)
raise
AccessDeniedError
,
status
.
message
unless
status
.
allowed?
verify_access
process_cmd
...
...
@@ -59,6 +57,8 @@ class GitlabShell
args
=
Shellwords
.
shellwords
(
@origin_cmd
)
@git_cmd
=
args
.
first
raise
DisallowedCommandError
unless
GIT_COMMANDS
.
include?
(
@git_cmd
)
if
@git_cmd
==
'git-annex-shell'
raise
DisallowedCommandError
unless
@config
.
git_annex_enabled?
...
...
@@ -72,8 +72,10 @@ class GitlabShell
end
end
def
git_cmds
%w(git-upload-pack git-receive-pack git-upload-archive git-annex-shell)
def
verify_access
status
=
api
.
check_access
(
@git_cmd
,
@repo_name
,
@key_id
,
'_any'
)
raise
AccessDeniedError
,
status
.
message
unless
status
.
allowed?
end
def
process_cmd
...
...
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