Module: Gitlab::Access
- Included in:
- Git::BranchPushService, Member
- Defined in:
- lib/gitlab/access.rb,
lib/gitlab/access/branch_protection.rb
Defined Under Namespace
Classes: BranchProtection
Constant Summary collapse
- AccessDeniedError =
Class.new(StandardError)
- NO_ACCESS =
0
- MINIMAL_ACCESS =
5
- GUEST =
10
- REPORTER =
20
- DEVELOPER =
30
- MAINTAINER =
40
- OWNER =
50
- ADMIN =
60
- PROTECTION_NONE =
Branch protection settings
0
- PROTECTION_DEV_CAN_PUSH =
1
- PROTECTION_FULL =
2
- PROTECTION_DEV_CAN_MERGE =
3
- PROTECTION_DEV_CAN_INITIAL_PUSH =
4
- NO_ONE_PROJECT_ACCESS =
Default project creation level
0
- MAINTAINER_PROJECT_ACCESS =
1
- DEVELOPER_MAINTAINER_PROJECT_ACCESS =
2
- OWNER_SUBGROUP_ACCESS =
Default subgroup creation level
0
- MAINTAINER_SUBGROUP_ACCESS =
1
Class Method Summary collapse
- .all_values ⇒ Object
- .human_access(access) ⇒ Object
- .human_access_with_none(access) ⇒ Object
- .options ⇒ Object
- .options_with_none ⇒ Object
- .options_with_owner ⇒ Object
- .project_creation_level_name(name) ⇒ Object
- .project_creation_options ⇒ Object
- .project_creation_string_options ⇒ Object
- .project_creation_string_values ⇒ Object
- .project_creation_values ⇒ Object
- .protection_options ⇒ Object
- .protection_values ⇒ Object
- .subgroup_creation_options ⇒ Object
- .subgroup_creation_string_options ⇒ Object
- .subgroup_creation_string_values ⇒ Object
- .subgroup_creation_values ⇒ Object
- .sym_options ⇒ Object
- .sym_options_with_owner ⇒ Object
Instance Method Summary collapse
Class Method Details
.all_values ⇒ Object
40 41 42 |
# File 'lib/gitlab/access.rb', line 40 def all_values .values end |
.human_access(access) ⇒ Object
112 113 114 |
# File 'lib/gitlab/access.rb', line 112 def human_access(access) .key(access) end |
.human_access_with_none(access) ⇒ Object
116 117 118 |
# File 'lib/gitlab/access.rb', line 116 def human_access_with_none(access) .key(access) end |
.options ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/gitlab/access.rb', line 44 def { "Guest" => GUEST, "Reporter" => REPORTER, "Developer" => DEVELOPER, "Maintainer" => MAINTAINER } end |
.options_with_none ⇒ Object
59 60 61 62 63 |
# File 'lib/gitlab/access.rb', line 59 def .merge( "None" => NO_ACCESS ) end |
.options_with_owner ⇒ Object
53 54 55 56 57 |
# File 'lib/gitlab/access.rb', line 53 def .merge( "Owner" => OWNER ) end |
.project_creation_level_name(name) ⇒ Object
144 145 146 |
# File 'lib/gitlab/access.rb', line 144 def project_creation_level_name(name) .key(name) end |
.project_creation_options ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/gitlab/access.rb', line 120 def { s_('ProjectCreationLevel|No one') => NO_ONE_PROJECT_ACCESS, s_('ProjectCreationLevel|Maintainers') => MAINTAINER_PROJECT_ACCESS, s_('ProjectCreationLevel|Developers + Maintainers') => DEVELOPER_MAINTAINER_PROJECT_ACCESS } end |
.project_creation_string_options ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/gitlab/access.rb', line 128 def { 'noone' => NO_ONE_PROJECT_ACCESS, 'maintainer' => MAINTAINER_PROJECT_ACCESS, 'developer' => DEVELOPER_MAINTAINER_PROJECT_ACCESS } end |
.project_creation_string_values ⇒ Object
140 141 142 |
# File 'lib/gitlab/access.rb', line 140 def project_creation_string_values .keys end |
.project_creation_values ⇒ Object
136 137 138 |
# File 'lib/gitlab/access.rb', line 136 def project_creation_values .values end |
.protection_options ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/gitlab/access.rb', line 78 def [ { label: s_('DefaultBranchProtection|Not protected'), help_text: s_('DefaultBranchProtection|Both developers and maintainers can push new commits, force push, or delete the branch.'), value: PROTECTION_NONE }, { label: s_('DefaultBranchProtection|Protected against pushes'), help_text: s_('DefaultBranchProtection|Developers cannot push new commits, but are allowed to accept merge requests to the branch. Maintainers can push to the branch.'), value: PROTECTION_DEV_CAN_MERGE }, { label: s_('DefaultBranchProtection|Partially protected'), help_text: s_('DefaultBranchProtection|Both developers and maintainers can push new commits, but cannot force push.'), value: PROTECTION_DEV_CAN_PUSH }, { label: s_('DefaultBranchProtection|Fully protected'), help_text: s_('DefaultBranchProtection|Developers cannot push new commits, but maintainers can. No one can force push.'), value: PROTECTION_FULL }, { label: s_('DefaultBranchProtection|Fully protected after initial push'), help_text: s_('DefaultBranchProtection|Developers can push the initial commit to a repository, but none afterward. Maintainers can always push. No one can force push.'), value: PROTECTION_DEV_CAN_INITIAL_PUSH } ] end |
.protection_values ⇒ Object
108 109 110 |
# File 'lib/gitlab/access.rb', line 108 def protection_values .map { |option| option[:value] } end |
.subgroup_creation_options ⇒ Object
148 149 150 151 152 153 |
# File 'lib/gitlab/access.rb', line 148 def { s_('SubgroupCreationlevel|Owners') => OWNER_SUBGROUP_ACCESS, s_('SubgroupCreationlevel|Maintainers') => MAINTAINER_SUBGROUP_ACCESS } end |
.subgroup_creation_string_options ⇒ Object
155 156 157 158 159 160 |
# File 'lib/gitlab/access.rb', line 155 def { 'owner' => OWNER_SUBGROUP_ACCESS, 'maintainer' => MAINTAINER_SUBGROUP_ACCESS } end |
.subgroup_creation_string_values ⇒ Object
166 167 168 |
# File 'lib/gitlab/access.rb', line 166 def subgroup_creation_string_values .keys end |
.subgroup_creation_values ⇒ Object
162 163 164 |
# File 'lib/gitlab/access.rb', line 162 def subgroup_creation_values .values end |
.sym_options ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/gitlab/access.rb', line 65 def { guest: GUEST, reporter: REPORTER, developer: DEVELOPER, maintainer: MAINTAINER } end |
.sym_options_with_owner ⇒ Object
74 75 76 |
# File 'lib/gitlab/access.rb', line 74 def .merge(owner: OWNER) end |
Instance Method Details
#human_access ⇒ Object
171 172 173 |
# File 'lib/gitlab/access.rb', line 171 def human_access Gitlab::Access.human_access(access_field) end |
#human_access_with_none ⇒ Object
175 176 177 |
# File 'lib/gitlab/access.rb', line 175 def human_access_with_none Gitlab::Access.human_access_with_none(access_field) end |
#owner? ⇒ Boolean
179 180 181 |
# File 'lib/gitlab/access.rb', line 179 def owner? access_field == OWNER end |