prometa.git package

Subpackages

Submodules

prometa.git.host module

Base class for Git hosts.

class prometa.git.host.GitHost(project)[source]

Bases: Registrable

Base class for Git hosts.

__init__(project)[source]
classmethod get_primary_host(project)[source]

Get the primary Git host of a project.

Parameters:

project – A Project instance.

Returns:

A GitHost subclass instance, or None if no host was found.

property is_used[source]

Check if the configuration indicates that this project uses this host.

Parameters:

project – A Project instance.

Returns:

True if the project is configured to use this host, else False.

update()[source]

Update the host via metadata files and/or API calls. This should handle CI, hooks, badges, etc.

property urls[source]

A dict of URLs specific to this host.

prometa.git.repo module

Common Git functions.

class prometa.git.repo.GitRepo(path, remote='origin')[source]

Bases: object

Basic functionality for retrieving Git information.

__init__(path, remote='origin')[source]
Parameters:
  • path – A path to the Git repository or any non-submodule path within it.

  • remote – The remote repository name to use for generating URLs.

get_main_blob_url(path)[source]

Get the main branch URL to the given path.

get_section_url(section)[source]

The URL to one of the various GitLab sections, e.g. “blob/main” or “packages”.

property parsed_origin[source]

A 3-tuple of the origin’s host, namespace and project name.

property public_git_url[source]

The publically accessible HTTPS URL.

property public_url[source]

The URL for the main project page.

property readme_url[source]

The URL to the README.

property remote_url[source]

The origin URL.

run_cmd(cmd)[source]

Run a git command and return its output.

Parameters:

cmd – The git sub-command and arguments.

Returns:

The command output.

property top_level[source]

The top-level directory.

property urls[source]

A dict of URLs for the project.

Module contents

Package stub.

class prometa.git.GitHost(project)[source]

Bases: Registrable

Base class for Git hosts.

__init__(project)[source]
classmethod get_primary_host(project)[source]

Get the primary Git host of a project.

Parameters:

project – A Project instance.

Returns:

A GitHost subclass instance, or None if no host was found.

property is_used[source]

Check if the configuration indicates that this project uses this host.

Parameters:

project – A Project instance.

Returns:

True if the project is configured to use this host, else False.

update()[source]

Update the host via metadata files and/or API calls. This should handle CI, hooks, badges, etc.

property urls[source]

A dict of URLs specific to this host.

class prometa.git.GitRepo(path, remote='origin')[source]

Bases: object

Basic functionality for retrieving Git information.

__init__(path, remote='origin')[source]
Parameters:
  • path – A path to the Git repository or any non-submodule path within it.

  • remote – The remote repository name to use for generating URLs.

get_main_blob_url(path)[source]

Get the main branch URL to the given path.

get_section_url(section)[source]

The URL to one of the various GitLab sections, e.g. “blob/main” or “packages”.

property parsed_origin[source]

A 3-tuple of the origin’s host, namespace and project name.

property public_git_url[source]

The publically accessible HTTPS URL.

property public_url[source]

The URL for the main project page.

property readme_url[source]

The URL to the README.

property remote_url[source]

The origin URL.

run_cmd(cmd)[source]

Run a git command and return its output.

Parameters:

cmd – The git sub-command and arguments.

Returns:

The command output.

property top_level[source]

The top-level directory.

property urls[source]

A dict of URLs for the project.