repomatic.cli.github module

GitHub commands of the repomatic CLI: issues, pull requests and labels.

repomatic.cli.main.COMMANDS registers each command here, and files it under its help section.

repomatic.cli.github.SPONSOR_LABEL = '💖 sponsor'

The label sponsor-label applies, as repomatic/data/labels.toml names it.

repomatic.cli.github.require_token(validator)[source]

Run a token validator of repomatic.github.token before a command.

The validator is read with a late getattr, so a test patching it on that module after import reaches the command too. A validator raising RuntimeError ends the command with its message.

Parameters:

validator (str) – The name of the validator, like validate_gh_token_env.

Return type:

Callable[[TypeVar(FC, bound= Callable[…, Any])], TypeVar(FC, bound= Callable[…, Any])]

repomatic.cli.github.thread_options(func)[source]

--number and --pr/--issue, read from the event payload when absent.

The thread a command acts on: resolve_thread() applies the defaults.

Return type:

TypeVar(FC, bound= Callable[…, Any])

repomatic.cli.github.resolve_thread(number, is_pr)[source]

Complete the thread_options() values from the event payload.

Parameters:
  • number (int | None) – The --number value, read from the event when None.

  • is_pr (bool | None) – The --pr/--issue value, read from the event when None.

Return type:

tuple[int, ThreadKind]

Returns:

The thread number and kind.

Raises:

click.UsageError – When neither the option nor the event names a thread.

repomatic.cli.github.template_options(func)[source]

The options that pick a template and feed its arguments.

resolve_template() reads --template and --template-file into one template, and parse_template_args() reads --template-arg and --template-arg-file into one mapping.

Return type:

TypeVar(FC, bound= Callable[…, Any])

repomatic.cli.github.resolve_template(template, template_file)[source]

The template --template or --template-file names, if either does.

Raises:

click.UsageError – When both are given.

Return type:

PrTemplate | None

repomatic.cli.github.parse_template_args(template_args_cli, template_arg_files)[source]

Read --template-arg and --template-arg-file into one mapping.

The files are read after the inline pairs, so a file wins on a key given both ways.

Raises:

click.UsageError – On a malformed pair, or a file that cannot be read.

Return type:

dict[str, str]