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
Kazuhiko Shiozaki
gitlab-shell
Commits
8f0f6762
Commit
8f0f6762
authored
Apr 06, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write GitlabAccess error to stderr.
parent
63efd092
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
hooks/pre-receive
hooks/pre-receive
+3
-0
lib/gitlab_access.rb
lib/gitlab_access.rb
+10
-11
No files found.
hooks/pre-receive
View file @
8f0f6762
...
...
@@ -14,5 +14,8 @@ if GitlabAccess.new(repo_path, key_id, refs).exec &&
GitlabCustomHook
.
new
.
pre_receive
(
refs
,
repo_path
)
exit
0
else
# reset GL_ID env since we stop git push here
ENV
[
'GL_ID'
]
=
nil
exit
1
end
lib/gitlab_access.rb
View file @
8f0f6762
...
...
@@ -5,6 +5,8 @@ require_relative 'names_helper'
require
'json'
class
GitlabAccess
class
AccessDeniedError
<
StandardError
;
end
include
NamesHelper
attr_reader
:config
,
:repo_path
,
:repo_name
,
:changes
...
...
@@ -18,19 +20,16 @@ class GitlabAccess
end
def
exec
begin
status
=
api
.
check_access
(
'git-receive-pack'
,
@repo_name
,
@actor
,
@changes
)
return
true
if
status
.
allowed?
status
=
api
.
check_access
(
'git-receive-pack'
,
@repo_name
,
@actor
,
@changes
)
message
=
status
.
message
rescue
GitlabNet
::
ApiUnreachableError
message
=
"Failed to authorize your Git request: internal API unreachable"
end
raise
AccessDeniedError
,
status
.
message
unless
status
.
allowed?
# reset GL_ID env since we stop git push here
ENV
[
'GL_ID'
]
=
nil
puts
"GitLab:
#{
message
}
"
true
rescue
GitlabNet
::
ApiUnreachableError
$stderr
.
puts
"GitLab: Failed to authorize your Git request: internal API unreachable"
false
rescue
AccessDeniedError
=>
ex
$stderr
.
puts
"GitLab:
#{
ex
.
message
}
"
false
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