303 lines · 7.5 KB · JSONRaw
{ "format_version": 1, "id": "repo_rule", "name": "Branch rule", "plural": "Branch rules", "builtin": true, "visibility": "owner", "title": "branch", "columns": [ { "key": "repo_id", "name": "Repository", "type": "link", "link_to": "repository", "required": true, "readonly": true }, { "key": "branch", "name": "Branch", "type": "text", "readonly": true, "required": true }, { "key": "required_contexts_json", "type": "longtext", "readonly": true }, { "key": "required_approvals", "type": "number", "readonly": true }, { "key": "block_outdated", "type": "bool", "readonly": true }, { "key": "allow_push", "name": "Pushing straight to the branch", "type": "bool", "readonly": true }, { "key": "rule_line", "name": "What it takes", "type": "text", "readonly": true }, { "key": "checks", "name": "Checks that must be green", "type": "longtext", "readonly": true }, { "key": "approvals", "name": "Approvals", "type": "number", "readonly": true }, { "key": "up_to_date", "name": "Head up to date", "type": "bool", "readonly": true }, { "key": "origin", "name": "Hosted by", "type": "text", "readonly": true } ], "instructions": "A branch rule is what one branch of a repository requires before a pull request merges into it: the checks that must be green, how many approvals, whether the head must be up to date with the base, and whether anything may be pushed straight to it. It is written whole: setting a rule replaces whatever that branch's rule was, on the host too.", "tables": [ { "name": "cotton_repo_rules", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "repo_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n repo_id TEXT NOT NULL", "position": 2 }, { "name": "branch", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n branch TEXT NOT NULL", "position": 3 }, { "name": "required_contexts_json", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n required_contexts_json TEXT NOT NULL DEFAULT '[]'", "position": 4 }, { "name": "required_approvals", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n required_approvals INTEGER NOT NULL DEFAULT 0", "position": 5 }, { "name": "block_outdated", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n block_outdated INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "allow_push", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n allow_push INTEGER NOT NULL DEFAULT 0", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, repo_id, branch)", "position": 12 }, { "declaration": "\n CHECK (length(trim(branch)) > 0)", "position": 13 }, { "declaration": "\n CHECK (json_type(required_contexts_json) = 'array')", "position": 14 }, { "declaration": "\n CHECK (required_approvals >= 0)", "position": 15 }, { "declaration": "\n CHECK (block_outdated IN (0, 1))", "position": 16 }, { "declaration": "\n CHECK (allow_push IN (0, 1))", "position": 17 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE", "position": 18 }, { "declaration": "\n FOREIGN KEY (repo_id) REFERENCES cotton_repos(id)\n ", "position": 19 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_repo_rules (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_repo_rules_repo ON cotton_repo_rules (workspace_id, repo_id, branch)", "CREATE INDEX IF NOT EXISTS idx_cotton_repo_rules_author ON cotton_repo_rules (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] } ], "picture": null, "engine": "repos", "date": null, "project": null, "order": null, "slip": { "title": "branch", "subtitle": "rule_line", "trailing": null, "photo": null, "toggle": null, "caption": { "columns": [ "checks" ] } }, "tile": { "face": "slip-list" }, "page": [ { "heading": null, "columns": [ "branch", "rule_line" ] }, { "heading": "The rule", "columns": [ "checks", "approvals", "up_to_date", "allow_push" ] }, { "heading": "Details", "columns": [ "origin", "repo_id" ] } ], "empty": { "title": "No branch rules.", "message": "No branch of this repository is protected by a rule written here." }, "delete": false, "commands": [ { "id": "save", "label": "Save", "kind": "update", "method": "repo.setRules", "bindings": { "id": "repo_id", "branch": "branch", "checks": "checks", "approvals": "approvals", "blockOutdated": "up_to_date", "allowPush": "allow_push" }, "receipt": "Saved rules", "object": "file" } ]}