gitmopy.cli

Command line interface for gitmopy.

Module Contents

gitmopy.cli.catch_keyboard_interrupt(func, *args, **kwargs)[source]

Function to wrap another function in a try/finally block and catch Aborts.

Executes its first argument with the following arguments and keyword arguments. When the function is done (or has been aborted by ctrl+c), it will prompt the user to restart the commit process or quit.

Required because I couldn’t find a way to catch typer.Abort exceptions in a standard try/except block.

Parameters:
  • func (Callable) – the function to wrap.

  • *args (Any) – positional arguments to pass to func.

  • **kwargs (Any) – keyword arguments to pass to func.

gitmopy.cli.commit(repo='.', add=False, push=None, dry=False, remote=[], keep_alive=False, simple=False, sign=False, no_verify=False)[source]

Main command: commit staged files, and staging files if need be.

Parameters:
  • repo (str, optional) – Path to the git repository. Defaults to “.”.

  • add (bool, optional) – Whether or not to select unstaged files to add if none is already staged. Defaults to False.

  • dry (bool, optional) – Whether or not to actually commit. Defaults to False.

  • push (typing_extensions.Annotated[bool, typer.Option(help='Whether to `git push` after commit. If multiple remotes exist, ' + 'you will be asked to interactively choose the ones to push to. ' + 'Use --remote to skip interactive selection. Disabled by default.')])

  • remote (typing_extensions.Annotated[Optional[List[str]], typer.Option(help='Remote to push to after commit. Use to skip interactive remote' + " selection when several exist. Use several '--remote {remote name}' " + 'to push to multiple remotes')])

  • keep_alive (typing_extensions.Annotated[Optional[bool], typer.Option(help='Whether or not to keep the app alive after commit, to be ready ' + 'for another one. ')])

  • simple (typing_extensions.Annotated[bool, typer.Option(help='Whether or not to use a simple commit which merges conventional commits and gitmoji.')])

  • sign (typing_extensions.Annotated[bool, typer.Option(help='Whether or not to sign the commit with GPG. Equivalent to `git commit -S`.')])

  • no_verify (typing_extensions.Annotated[bool, typer.Option(help='Whether or not to commit without running pre-commit hooks.')])

Raises:
  • typer.Exit – Path to repository is not a Git repository.

  • typer.Exit – No staged files and user does not want to add.

  • typer.Exit – User asked for a dry run.

gitmopy.cli.config()[source]

Command to setup gitmopy’s configuration.

gitmopy.cli.info()[source]

Command to print gitmopy’s info.

gitmopy.cli.pull_cli(repo, remote_cli_args)[source]

Pull from remotes.

If several remotes, use either the values from –remote, or prompt the user to choose them.

Parameters:
  • repo (git.Repo) – The git repository.

  • remote_cli_args (List[str]) – The remotes passed as CLI arguments.

Raises:

typer.Abort – Stops the process if the users does not choose a remote.

gitmopy.cli.push_cli(repo, remote_cli_args)[source]

Push to user remotes.

If several remotes, use either the values from –remote or prompt the user to select them.

Parameters:
  • repo (Repo) – The git repository.

  • remote_cli_args (List[str]) – The remotes passed as CLI arguments.

Raises:

typer.Abort – If no remote is selected.

gitmopy.cli.should_commit_again(repo, remote)[source]

Prompt the user to continue or stop the current commit loop.

Parameters:
  • repo (Repo) – The git repository.

  • remote (List[str])

Returns:

Whether the user wants to continue or not.

Return type:

bool

gitmopy.cli.start()[source]

Runs the commit command with the default arguments you have set in the configuration file. If no such arguments are set, you will be prompted to set them interactively.

gitmopy.cli.app[source]