diff --git a/app/assets/javascripts/projects/settings/branch_rules/components/view/index.vue b/app/assets/javascripts/projects/settings/branch_rules/components/view/index.vue index cc138ddcaf9523c1fd0038a126a5a927107d51bf..2ef281c818f45e5100b8e7186fd185717295e931 100644 --- a/app/assets/javascripts/projects/settings/branch_rules/components/view/index.vue +++ b/app/assets/javascripts/projects/settings/branch_rules/components/view/index.vue @@ -111,7 +111,14 @@ export default { }; }, update({ project: { branchRules, group } }) { - const branchRule = branchRules.nodes.find((rule) => rule.name === this.branch); + const branchRule = branchRules.nodes.find((rule) => { + if (this.ruleId) { + // If we have a rule ID, match by both name and ID for precision + return rule.name === this.branch && getIdFromGraphQLId(rule.id) === this.ruleId; + } + // Fallback to name-only matching for backward compatibility + return rule.name === this.branch; + }); this.branchRule = branchRule; this.branchProtection = branchRule?.branchProtection; this.statusChecks = branchRule?.externalStatusChecks?.nodes || []; @@ -149,8 +156,12 @@ export default { }, }, data() { + const branchParam = getParameterByName(BRANCH_PARAM_NAME); + const ruleId = getParameterByName('id'); + return { - branch: getParameterByName(BRANCH_PARAM_NAME), + branch: branchParam, + ruleId, branchProtection: {}, statusChecks: [], branchRule: {}, diff --git a/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue b/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue index 5aeabbace7e22bf199bc2d409d6867efcdfae93d..9c54f4d56bfddb537a816a3f445873f3c49db0b9 100644 --- a/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue +++ b/app/assets/javascripts/projects/settings/repository/branch_rules/app.vue @@ -188,6 +188,7 @@ export default {