keep fork default branch and CODEOWNERS, reject private forks
This commit is contained in:
@@ -118,6 +118,8 @@ run "fork_from_source" {
|
||||
repository = {
|
||||
autocraft = { name = "autocraft", fork_from = "storytold/autocraft", maintainers = ["@maintainers"] }
|
||||
plain = { name = "plain" }
|
||||
secret = { name = "secret", maintainers = ["@maintainers"] }
|
||||
public = { name = "public", private = false, fork_from = "storytold/public" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +134,7 @@ run "fork_from_source" {
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = keys(module.ruleset) == ["autocraft/branch-protection", "autocraft/ref-names-tag", "autocraft/tag-protection", "plain/branch-protection", "plain/ref-names-tag", "plain/tag-protection"] && module.repository["autocraft"].codeowners != null
|
||||
condition = length([for k in keys(module.ruleset) : k if startswith(k, "autocraft/")]) == 3 && module.repository["autocraft"].codeowners != null
|
||||
error_message = "forks get the org rulesets and CODEOWNERS like any other repository"
|
||||
}
|
||||
|
||||
@@ -144,6 +146,34 @@ run "fork_from_source" {
|
||||
)
|
||||
error_message = "non-forks keep auto_init and configured visibility; forks keep repo settings"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
!module.repository["autocraft"].branch_default.rename &&
|
||||
module.repository["autocraft"].codeowners.overwrite_on_create
|
||||
)
|
||||
error_message = "forks must select the existing default branch and overwrite an inherited CODEOWNERS"
|
||||
}
|
||||
|
||||
assert {
|
||||
condition = (
|
||||
module.repository["plain"].branch_default.rename &&
|
||||
!module.repository["secret"].codeowners.overwrite_on_create
|
||||
)
|
||||
error_message = "non-forks must rename the auto_init branch and never overwrite CODEOWNERS"
|
||||
}
|
||||
}
|
||||
|
||||
run "private_fork_rejected" {
|
||||
command = plan
|
||||
|
||||
variables {
|
||||
repository = {
|
||||
bad = { name = "bad", fork_from = "storytold/autocraft", private = true }
|
||||
}
|
||||
}
|
||||
|
||||
expect_failures = [var.repository]
|
||||
}
|
||||
|
||||
run "invalid_fork_from_rejected" {
|
||||
|
||||
Reference in New Issue
Block a user