hermes.commands.init.util.git_info
==================================

.. py:module:: hermes.commands.init.util.git_info


Attributes
----------

.. autoapisummary::

   hermes.commands.init.util.git_info.default_cwd


Functions
---------

.. autoapisummary::

   hermes.commands.init.util.git_info.get_valid_cwd
   hermes.commands.init.util.git_info.run_git_command
   hermes.commands.init.util.git_info.get_remotes
   hermes.commands.init.util.git_info.convert_remote_url
   hermes.commands.init.util.git_info.get_remote_url
   hermes.commands.init.util.git_info.get_current_branch
   hermes.commands.init.util.git_info.is_git_installed


Module Contents
---------------

.. py:data:: default_cwd
   :value: ''


.. py:function:: get_valid_cwd(cwd='') -> str

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


.. py:function:: 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.


.. py:function:: get_remotes() -> list[str]

   Returns a list of all remotes.


.. py:function:: convert_remote_url(url: str) -> str

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


.. py:function:: get_remote_url(remote: str) -> str

   Returns the url of the given remote.


.. py:function:: get_current_branch() -> str

   Returns the name of the current branch.


.. py:function:: is_git_installed() -> bool

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


