群组级设置合并检查
问题(Problem to solve)
客户希望能在群组级设置“All threads must be resolved”,该需求可延伸为群组级“合并请求”设置,如“合并方法”、“合并选项”等
客户链接(Customer Link)
解决方案(Proposal)
可以参考群组级分支保护、群组级审批规则实现方式
针对的用户(Intended users)
- Delaney (Development Team Lead)
- Sasha (Software Developer)
- Priyanka (Platform Engineer)
- Sidney (Systems Administrator)
功能使用度量指标(Feature Usage Metrics)- 可选
动态
-
最新在前 最早在前
-
显示所有活动 仅显示评论 仅显示历史记录
- Rang Wu added CREQhigh TeamPresales customer insight typefeature labels
added CREQhigh TeamPresales customer insight typefeature labels
- Maintainer
@rang.wu,请补全详细的标记:- featureaddition:为用户提供的全新功能。
- featureenhancement:为了提升用户体验而对现有功能进行的改进。
- featureconsolidation:为了简化用户体验,将两个功能进行合并。
- featureremoval:删除一个不再需要的功能。
要详细了解标记,请查阅文档:极狐 Handbook。
- Rang Wu added featureaddition label
added featureaddition label
- Guest
- Guest
在upstream提出建议进行方案讨论 https://gitlab.com/gitlab-org/gitlab/-/issues/372040
- 彭亮 assigned to @luzhiyuan.deer
assigned to @luzhiyuan.deer
- Maintainer
技术方案
改动围绕三个字段进行:
- only_allow_merge_if_pipeline_succeeds
- allow_merge_on_skipped_pipeline
- only_allow_merge_if_all_discussions_are_resolved
1. Migration
方案一:使用 CascadingSetting
利用
CascadingSetting
特性,为两张表namespace_settings
application_settings
分别增加六个新列:only_allow_merge_if_pipeline_succeeds boolean DEFAULT false NOT NULL lock_only_allow_merge_if_pipeline_succeeds boolean DEFAULT false NOT NULL allow_merge_on_skipped_pipeline boolean DEFAULT false NOT NULL lock_ allow_merge_on_skipped_pipeline boolean DEFAULT false NOT NULL only_allow_merge_if_all_discussions_are_resolved boolean DEFAULT false NOT NULL lock_only_allow_merge_if_all_discussions_are_resolved boolean DEFAULT false NOT NULL
Migration 代码如下:
# frozen_string_literal: true class AddOnlyAllowMergeIfPipelineSucceedsCascadingSetting < Gitlab::Database::Migration[2.0] include Gitlab::Database::MigrationHelpers::CascadingNamespaceSettings enable_lock_retries! def up add_cascading_namespace_setting :only_allow_merge_if_pipeline_succeeds, :boolean, default: false, null: false add_cascading_namespace_setting :allow_merge_on_skipped_pipeline, :boolean, default: false, null: false add_cascading_namespace_setting :only_allow_merge_if_all_discussions_are_resolved, :boolean, default: false, null: false end def down remove_cascading_namespace_setting :only_allow_merge_if_pipeline_succeeds remove_cascading_namespace_setting :allow_merge_on_skipped_pipeline remove_cascading_namespace_setting :only_allow_merge_if_all_discussions_are_resolved end end
方案二:用常规方法为表 `namespace_settings` 增加三个新列:
only_allow_merge_if_pipeline_succeeds boolean DEFAULT false NOT NULL allow_merge_on_skipped_pipeline boolean DEFAULT false NOT NULL only_allow_merge_if_all_discussions_are_resolved boolean DEFAULT false NOT NULL
2. 后端
- namespace_settings 的 model 和 controller 适配三个新字段
-
projects 的 model,用
函数覆盖这三个字段,新增函数,函数中先读祖先配置,决定是否覆盖自己的配置。以其中一个为例:
def xxx_only_allow_merge_if_pipeline_succeeds return Gitlab::CurrentSettings.only_allow_merge_if_pipeline_succeeds if Gitlab::CurrentSettings.lock_only_allow_merge_if_pipeline_succeeds return super unless group namespace_setting = group&.namespace_settings return namespace_setting.only_allow_merge_if_pipeline_succeeds if namespace_setting.lock_only_allow_merge_if_pipeline_succeeds? super end def xxx_only_allow_merge_if_pipeline_succeeds? only_allow_merge_if_pipeline_succeeds end
3. 前端
- Group/settings/MRs 新增三个 checkbox 的 UI
- Project/settings/MRs 原来的三个 checkbox,要根据 Group 的配置判断是否 disabled
遗留问题
- cascading settings 有必要吗?我们要处理的是 group-project,不是 application-group (waitting reply of Comment)
-
project settings 里的东西会被 cascading 影响吗?还是说继续保留这三个 column 不用变化
不会被影响。
由 路志远 已编辑 于 - Maintainer
今天 Upstream 合入一个新的 Project settings:Issue
原来的三个配置变成四个了,新增的这个在 Group 没有对应的配置。所以当 feature flag 打开后,Group 里有三个选框,Project 里有四个选框,这种现状可以被接受吗?@lpeng1991 🤯
由 路志远 已编辑 于 收起回复 - Guest
@luzhiyuan.deer 可以接受,我们后面再优化,把新的加进去
1
请注册或登录再回复