Class: Gitlab::BackgroundMigration::BackfillDefaultBranchProtectionNamespaceSetting::BranchProtection
- Inherits:
-
Object
- Object
- Gitlab::BackgroundMigration::BackfillDefaultBranchProtectionNamespaceSetting::BranchProtection
- Defined in:
- lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb
Overview
Migration only version of Gitlab::Access:BranchProtection application code.
Constant Summary collapse
- PROTECTION_NONE =
0
- PROTECTION_DEV_CAN_PUSH =
1
- PROTECTION_FULL =
2
- PROTECTION_DEV_CAN_MERGE =
3
- PROTECTION_DEV_CAN_INITIAL_PUSH =
4
- DEVELOPER =
30
- MAINTAINER =
40
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Class Method Summary collapse
- .protected_after_initial_push ⇒ Object
- .protected_against_developer_pushes ⇒ Object
- .protected_fully ⇒ Object
- .protection_none ⇒ Object
- .protection_partial ⇒ Object
Instance Method Summary collapse
-
#initialize(level) ⇒ BranchProtection
constructor
A new instance of BranchProtection.
- #to_hash ⇒ Object
Constructor Details
#initialize(level) ⇒ BranchProtection
Returns a new instance of BranchProtection.
31 32 33 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 31 def initialize(level) @level = level end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
29 30 31 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 29 def level @level end |
Class Method Details
.protected_after_initial_push ⇒ Object
88 89 90 91 92 93 94 95 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 88 def protected_after_initial_push { allowed_to_push: [{ 'access_level' => MAINTAINER }], allowed_to_merge: [{ 'access_level' => DEVELOPER }], allow_force_push: true, developer_can_initial_push: true } end |
.protected_against_developer_pushes ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 80 def protected_against_developer_pushes { allowed_to_push: [{ 'access_level' => MAINTAINER }], allowed_to_merge: [{ 'access_level' => DEVELOPER }], allow_force_push: true } end |
.protected_fully ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 72 def protected_fully { allowed_to_push: [{ 'access_level' => MAINTAINER }], allowed_to_merge: [{ 'access_level' => MAINTAINER }], allow_force_push: false } end |
.protection_none ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 60 def protection_none { allowed_to_push: [{ 'access_level' => DEVELOPER }], allowed_to_merge: [{ 'access_level' => DEVELOPER }], allow_force_push: true } end |
.protection_partial ⇒ Object
68 69 70 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 68 def protection_partial protection_none.merge(allow_force_push: false) end |
Instance Method Details
#to_hash ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gitlab/background_migration/backfill_default_branch_protection_namespace_setting.rb', line 44 def to_hash case level when PROTECTION_NONE self.class.protection_none when PROTECTION_DEV_CAN_PUSH self.class.protection_partial when PROTECTION_FULL self.class.protected_fully when PROTECTION_DEV_CAN_MERGE self.class.protected_against_developer_pushes when PROTECTION_DEV_CAN_INITIAL_PUSH self.class.protected_after_initial_push end end |