Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
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-ce
Commits
74f9a987
Commit
74f9a987
authored
May 09, 2021
by
Justin Farmiloe
Committed by
Stan Hu
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve deploy key script code following review
parent
68579fb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md
...dministration/troubleshooting/gitlab_rails_cheat_sheet.md
+11
-7
No files found.
doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md
View file @
74f9a987
...
...
@@ -321,19 +321,23 @@ DeployKeysProject.with_write_access.find_each do |deploy_key_mapping|
access_checker
=
Gitlab
::
DeployKeyAccess
.
new
(
deploy_key
,
container:
project
)
#
can_push_for_ref? tests if deploy_key can push to default branch - by default will fail if user role not Maintainer
#
Can_push_for_ref? tests if deploy_key can push to specified (possibly protected) branch - change branch name below as required
#
next
if
access_checker
.
allowed?
&&
access_checker
.
can_do_action?
(
:push_code
)
&&
access_checker
.
can_push_for_ref?
(
project
.
repository
.
root_ref
)
branch
=
project
.
repository
.
root_ref
#default branch
#branch = 'b1'
puts
"==="
puts
"Unusable deploy key for pushing: key ID:
#{
deploy_key
.
id
}
, title:
#{
deploy_key
.
title
}
for project ID:
#{
project
.
id
}
, path:
#{
project
.
full_path
}
"
next
if
access_checker
.
allowed?
&&
access_checker
.
can_do_action?
(
:push_code
)
&&
access_checker
.
can_push_for_ref?
(
branch
)
if
user
.
nil?
||
user
.
id
==
ghost_user_id
puts
"No user associated"
next
user
.
username
=
'none'
user
.
state
=
'-'
end
puts
"Associated user:
#{
user
.
username
}
, status:
#{
user
.
state
}
"
puts
"Deploy key:
#{
deploy_key
.
id
}
, Project:
#{
project
.
full_path
}
, Can push?: "
+
(
access_checker
.
can_do_action?
(
:push_code
)
?
'YES'
:
'NO'
)
+
", Can push to branch
#{
branch
}
?: "
+
(
access_checker
.
can_push_for_ref?
(
project
.
repository
.
root_ref
)
?
'YES'
:
'NO'
)
+
", User:
#{
user
.
username
}
, User state:
#{
user
.
state
}
"
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