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
99a65d67
Commit
99a65d67
authored
Jul 26, 2018
by
Ash McKenzie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use HTTP status constants in GitLabNet
parent
9853fe04
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
24 deletions
+11
-24
lib/gitlab_net.rb
lib/gitlab_net.rb
+11
-24
No files found.
lib/gitlab_net.rb
View file @
99a65d67
...
@@ -55,16 +55,10 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
...
@@ -55,16 +55,10 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
end
end
def
lfs_authenticate
(
key
,
repo
)
def
lfs_authenticate
(
key
,
repo
)
params
=
{
params
=
{
project:
sanitize_path
(
repo
),
key_id:
key
.
gsub
(
'key-'
,
''
)
}
project:
sanitize_path
(
repo
),
key_id:
key
.
gsub
(
'key-'
,
''
)
}
resp
=
post
(
"
#{
internal_api_endpoint
}
/lfs_authenticate"
,
params
)
resp
=
post
(
"
#{
internal_api_endpoint
}
/lfs_authenticate"
,
params
)
if
resp
.
code
==
'200'
GitlabLfsAuthentication
.
build_from_json
(
resp
.
body
)
if
resp
.
code
==
HTTP_SUCCESS
GitlabLfsAuthentication
.
build_from_json
(
resp
.
body
)
end
end
end
def
broadcast_message
def
broadcast_message
...
@@ -79,11 +73,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
...
@@ -79,11 +73,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
url
+=
"&gl_repository=
#{
URI
.
escape
(
gl_repository
)
}
"
if
gl_repository
url
+=
"&gl_repository=
#{
URI
.
escape
(
gl_repository
)
}
"
if
gl_repository
resp
=
get
(
url
)
resp
=
get
(
url
)
if
resp
.
code
==
'200'
resp
.
code
==
HTTP_SUCCESS
?
JSON
.
parse
(
resp
.
body
)
:
[]
JSON
.
parse
(
resp
.
body
)
else
[]
end
rescue
rescue
[]
[]
end
end
...
@@ -94,7 +84,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
...
@@ -94,7 +84,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
def
authorized_key
(
key
)
def
authorized_key
(
key
)
resp
=
get
(
"
#{
internal_api_endpoint
}
/authorized_keys?key=
#{
URI
.
escape
(
key
,
'+/='
)
}
"
)
resp
=
get
(
"
#{
internal_api_endpoint
}
/authorized_keys?key=
#{
URI
.
escape
(
key
,
'+/='
)
}
"
)
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
"200"
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
HTTP_SUCCESS
rescue
rescue
nil
nil
end
end
...
@@ -102,8 +92,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
...
@@ -102,8 +92,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
def
two_factor_recovery_codes
(
key
)
def
two_factor_recovery_codes
(
key
)
key_id
=
key
.
gsub
(
'key-'
,
''
)
key_id
=
key
.
gsub
(
'key-'
,
''
)
resp
=
post
(
"
#{
internal_api_endpoint
}
/two_factor_recovery_codes"
,
key_id:
key_id
)
resp
=
post
(
"
#{
internal_api_endpoint
}
/two_factor_recovery_codes"
,
key_id:
key_id
)
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
HTTP_SUCCESS
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
'200'
rescue
rescue
{}
{}
end
end
...
@@ -112,7 +101,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
...
@@ -112,7 +101,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
params
=
{
gl_repository:
gl_repository
,
project:
repo_path
}
params
=
{
gl_repository:
gl_repository
,
project:
repo_path
}
resp
=
post
(
"
#{
internal_api_endpoint
}
/notify_post_receive"
,
params
)
resp
=
post
(
"
#{
internal_api_endpoint
}
/notify_post_receive"
,
params
)
resp
.
code
==
'200'
resp
.
code
==
HTTP_SUCCESS
rescue
rescue
false
false
end
end
...
@@ -124,21 +113,19 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
...
@@ -124,21 +113,19 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
changes:
changes
changes:
changes
}
}
resp
=
post
(
"
#{
internal_api_endpoint
}
/post_receive"
,
params
)
resp
=
post
(
"
#{
internal_api_endpoint
}
/post_receive"
,
params
)
raise
NotFound
if
resp
.
code
==
HTTP_NOT_FOUND
raise
NotFound
if
resp
.
code
==
'404'
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
HTTP_SUCCESS
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
'200'
end
end
def
pre_receive
(
gl_repository
)
def
pre_receive
(
gl_repository
)
resp
=
post
(
"
#{
internal_api_endpoint
}
/pre_receive"
,
gl_repository:
gl_repository
)
resp
=
post
(
"
#{
internal_api_endpoint
}
/pre_receive"
,
gl_repository:
gl_repository
)
raise
NotFound
if
resp
.
code
==
HTTP_NOT_FOUND
raise
NotFound
if
resp
.
code
==
'404'
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
HTTP_SUCCESS
JSON
.
parse
(
resp
.
body
)
if
resp
.
code
==
'200'
end
end
pr
otected
pr
ivate
def
sanitize_path
(
repo
)
def
sanitize_path
(
repo
)
repo
.
delete
(
"'"
)
repo
.
delete
(
"'"
)
...
...
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