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
a686b9a0
Commit
a686b9a0
authored
Aug 01, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Struct::ParsedCommand to keep vars close
parent
feda260c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
lib/gitlab_shell.rb
lib/gitlab_shell.rb
+21
-13
No files found.
lib/gitlab_shell.rb
View file @
a686b9a0
...
...
@@ -16,6 +16,8 @@ class GitlabShell
GIT_COMMANDS
=
[
GIT_UPLOAD_PACK_COMMAND
,
GIT_RECEIVE_PACK_COMMAND
,
GIT_UPLOAD_ARCHIVE_COMMAND
,
GIT_LFS_AUTHENTICATE_COMMAND
].
freeze
Struct
.
new
(
'ParsedCommand'
,
:command
,
:git_access_command
,
:repo_name
,
:args
)
def
initialize
(
key_str
)
@key_str
=
key_str
@config
=
GitlabConfig
.
new
...
...
@@ -30,10 +32,9 @@ class GitlabShell
return
true
end
command
,
git_access_command
,
repo_name
,
args
=
parse_cmd
(
origin_cmd
)
action
=
determine_action
(
command
,
git_access_command
,
repo_name
)
action
.
execute
(
command
,
args
)
parsed_command
=
parse_cmd
(
origin_cmd
)
action
=
determine_action
(
parsed_command
)
action
.
execute
(
parsed_command
.
command
,
parsed_command
.
args
)
rescue
GitlabNet
::
ApiUnreachableError
$stderr
.
puts
"GitLab: Failed to authorize your Git request: internal API unreachable"
false
...
...
@@ -71,7 +72,9 @@ class GitlabShell
git_access_command
=
command
return
[
command
,
git_access_command
,
nil
,
args
]
if
command
==
API_2FA_RECOVERY_CODES_COMMAND
if
command
==
API_2FA_RECOVERY_CODES_COMMAND
return
Struct
::
ParsedCommand
.
new
(
command
,
git_access_command
,
nil
,
args
)
end
raise
DisallowedCommandError
unless
GIT_COMMANDS
.
include?
(
command
)
...
...
@@ -92,20 +95,25 @@ class GitlabShell
repo_name
=
args
.
last
end
[
command
,
git_access_command
,
repo_name
,
args
]
Struct
::
ParsedCommand
.
new
(
command
,
git_access_command
,
repo_name
,
args
)
end
def
determine_action
(
command
,
git_access_command
,
repo_name
)
return
Action
::
API2FARecovery
.
new
(
key
)
if
command
==
API_2FA_RECOVERY_CODES_COMMAND
def
determine_action
(
parsed_command
)
return
Action
::
API2FARecovery
.
new
(
key
)
if
parsed_command
.
command
==
API_2FA_RECOVERY_CODES_COMMAND
GitlabMetrics
.
measure
(
'verify-access'
)
do
# GitlatNet#check_access will raise exception in the event of a problem
initial_action
=
api
.
check_access
(
git_access_command
,
nil
,
repo_name
,
key
,
'_any'
)
case
command
initial_action
=
api
.
check_access
(
parsed_command
.
git_access_command
,
nil
,
parsed_command
.
repo_name
,
key
,
'_any'
)
case
parsed_command
.
command
when
GIT_LFS_AUTHENTICATE_COMMAND
Action
::
GitLFSAuthenticate
.
new
(
key
,
repo_name
)
Action
::
GitLFSAuthenticate
.
new
(
key
,
parsed_command
.
repo_name
)
else
initial_action
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