Skip to content

Commit ecb1481

Browse files
committed
update branch creation validation condition
1 parent 41bfa41 commit ecb1481

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

backend/infrahub/core/branch/models.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,18 @@ def validate_branch_name(cls, value: str) -> str:
8585
@model_validator(mode="after")
8686
def validate_name(self) -> Self:
8787
if (
88-
not self.sync_with_git
89-
and config.SETTINGS.git.sync_branch_names
90-
and not branch_name_in_sync_branches(branch_short_name=self.name)
88+
not config.SETTINGS.git.sync_branch_names
89+
or self.name == GLOBAL_BRANCH_NAME
90+
or self.is_default
91+
or self.sync_with_git
9192
):
93+
return self
94+
95+
if not branch_name_in_sync_branches(branch_short_name=self.name):
9296
raise ValidationError(
9397
f"Branch name '{self.name}' does not match sync branch names {config.SETTINGS.git.sync_branch_names}"
9498
)
99+
95100
return self
96101

97102
@field_validator("branched_from", mode="before")

0 commit comments

Comments
 (0)