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
9626d17d
Commit
9626d17d
authored
May 10, 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
74f9a987
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md
...dministration/troubleshooting/gitlab_rails_cheat_sheet.md
+13
-13
No files found.
doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md
View file @
9626d17d
...
...
@@ -321,23 +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 specified (possibly protected) branch - change branch name below as required
#
branch
=
project
.
repository
.
root_ref
#default branch
#branch = 'b1'
next
if
access_checker
.
allowed?
&&
access_checker
.
can_do_action?
(
:push_code
)
&&
access_checker
.
can_push_for_ref?
(
branch
)
# can_push_for_ref? tests if deploy_key can push to default branch, which is likely to be protected
can_push
=
access_checker
.
can_do_action?
(
:push_code
)
can_push_to_default
=
access_checker
.
can_push_for_ref?
(
project
.
repository
.
root_ref
)
next
if
access_checker
.
allowed?
&&
can_push
&&
can_push_to_default
if
user
.
nil?
||
user
.
id
==
ghost_user_id
user
.
username
=
'none'
user
.
state
=
'-'
username
=
'none'
state
=
'-'
else
username
=
user
.
username
user_state
=
user
.
state
end
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
}
"
puts
"Deploy key:
#{
deploy_key
.
id
}
, Project:
#{
project
.
full_path
}
, Can push?: "
+
(
can_push
?
'YES'
:
'NO'
)
+
", Can push to default branch
#{
project
.
repository
.
root_ref
}
?: "
+
(
can_push_to_default
?
'YES'
:
'NO'
)
+
", 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