config
repo_scaffold.github_init.config ¶
Configuration resolution for gh-init.
Collects repo metadata, secrets, and variables into a GhInitConfig from
CLI args, the environment, a .env file, pyproject.toml, and an
optional interactive prompter. Kept separate from the PyGithub client and the
orchestrator so the resolution logic can be unit-tested in isolation.
GhInitConfig
dataclass
¶
GhInitConfig(
project_path: Path,
name: str,
description: str,
private: bool,
default_branch: str,
secrets: dict[str, str] = dict(),
variables: dict[str, str] = dict(),
owner: str | None = None,
push: bool = True,
force_push: bool = False,
allow_existing: bool = False,
setup_pages: bool = True,
protect_branch: bool = False,
)
Resolved configuration for one gh-init invocation.
GhInitResult
dataclass
¶
GhInitResult(
html_url: str,
actions_url: str,
pages_url: str,
skipped_secrets: list[str],
pushed: bool,
pages_configured: bool = False,
pages_branch: str = PAGES_BRANCH,
pages_error: str | None = None,
homepage_set: bool = False,
branch_protected: bool = False,
protection_error: str | None = None,
)
Outputs surfaced to the CLI after a successful run.
_github_owner_from_url ¶
Extract owner from a github.com/<owner>/<repo> URL, else None.
build_config ¶
build_config(
project_path: Path,
*,
owner: str | None = None,
name: str | None = None,
description: str | None = None,
private: bool = False,
default_branch: str | None = None,
push: bool = True,
force_push: bool = False,
allow_existing: bool = False,
setup_pages: bool = True,
protect_branch: bool = False,
extra_env: dict[str, str] | None = None,
prompter: Callable[[str, str | None], str]
| None = None,
) -> GhInitConfig
Resolve a GhInitConfig from CLI args, environment, .env, and pyproject.
Precedence per key (highest first): explicit kwarg, extra_env (used for
secrets/variables and for pulling values from os.environ at the call
site), then the project's .env file, then pyproject.toml defaults,
then prompter if provided.
prompter receives (key, default) and returns the user's answer, or
an empty string to skip. When prompter is None (i.e. --no-input)
missing optional values are simply dropped.
Source code in repo_scaffold/github_init/config.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
detect_default_branch ¶
Return the current local git branch name, or None if not a git repo.
Source code in repo_scaffold/github_init/config.py
detect_owner ¶
Best-effort GitHub owner for the project and the source it came from.
Resolution order: a github.com/<owner>/... URL in pyproject.toml's
[project.urls], then the Cocogitto [changelog].owner field in
cog.toml. Returns (None, None) when no owner can be determined, in
which case the caller falls back to the authenticated user.
Source code in repo_scaffold/github_init/config.py
load_pyproject ¶
Return the [project] table from the project's pyproject.toml.
Source code in repo_scaffold/github_init/config.py
parse_dotenv ¶
Parse a tiny subset of dotenv syntax: KEY=VALUE lines, # comments.
Quoted values are unquoted. Anything more exotic (export, multiline, command substitution) is intentionally not supported — projects that need that should set real env vars before running gh-init.