hermes.commands.init.util.git_info

Attributes

Functions

get_valid_cwd(→ str)

Returns the given cwd if valid or the default_cwd / os.getcwd() when not cwd is given.

run_git_command(→ str)

Runs any git command using subprocess. Raises Exception when returncode != 0.

get_remotes(→ list[str])

Returns a list of all remotes.

convert_remote_url(→ str)

Takes any url produced by 'git remote get-url ...' and returns a consistent version with https & without '.git'.

get_remote_url(→ str)

Returns the url of the given remote.

get_current_branch(→ str)

Returns the name of the current branch.

is_git_installed(→ bool)

Uses the --version command to check whether git is installed.

Module Contents

hermes.commands.init.util.git_info.default_cwd = ''
hermes.commands.init.util.git_info.get_valid_cwd(cwd='') str

Returns the given cwd if valid or the default_cwd / os.getcwd() when not cwd is given.

hermes.commands.init.util.git_info.run_git_command(command: str, cwd='', throw_exception=False) str

Runs any git command using subprocess. Raises Exception when returncode != 0. :param command: The command as string with or without the ‘git’ main command. :param cwd: Path to target directory ( if it differs from os.getcwd() ). :return: The command’s output.

hermes.commands.init.util.git_info.get_remotes() list[str]

Returns a list of all remotes.

hermes.commands.init.util.git_info.convert_remote_url(url: str) str

Takes any url produced by ‘git remote get-url …’ and returns a consistent version with https & without ‘.git’.

hermes.commands.init.util.git_info.get_remote_url(remote: str) str

Returns the url of the given remote.

hermes.commands.init.util.git_info.get_current_branch() str

Returns the name of the current branch.

hermes.commands.init.util.git_info.is_git_installed() bool

Uses the –version command to check whether git is installed.