prometa.git.gitlab.badges package

Subpackages

Submodules

prometa.git.gitlab.badges.badge_manager module

Base class for each badge manager.

class prometa.git.gitlab.badges.badge_manager.BadgeManager(gitlab_api)[source]

Bases: Registrable

Registrable base class for each badge manager.

NAME = None[source]
__init__(gitlab_api)[source]
Parameters:

gitlab_api – A GitLabApi instance.

create_badge(name, link_url, image_url)[source]

Create a new badge.

Parameters:
  • name – The badge name.

  • link_url – The badge link URL.

  • image_url – The badge image URL.

static delete_badge(badge)[source]

Delete a badge.

Parameters:

badge – A Badge instance.

property enabled[source]

The badge’s name is in the gitlab.enabled_badges list in the configuration file.

get_badge_by_name(name)[source]

Get a badge by name.

Parameters:

name – The name of the badge.

Returns:

The Badge instance, or None of not badge of the given name was found.

property gitlab_project[source]

The python-gitlab Project instance.

property include[source]

True if the condition for including this badge is met, else False. The configuration file determines of the badge is managed whereas this property determines if the badge is added or removed when the badge is managed.

manage()[source]

Manage the badge.

property project[source]

The Project instance.

static update_badge(badge, link_url, image_url)[source]

Update a badge if necessary.

Parameters:
  • badge – A Badge instance.

  • link_url – The badge link URL.

  • image_url – The badge image URL.

property urls[source]

The link and image URLs for the badge.

prometa.git.gitlab.badges.common module

Common functions for badge management.

prometa.git.gitlab.badges.common.get_badge_url(label, message, color, **query_params)[source]

Get a URL to an SVG image of a custom badge generated by the img.shields.io website.

Parameters:
  • label – The text on the left side of the badge.

  • message – The text on the right side of the badge.

  • color – The hexadecimal color code for the background of the message.

  • query_params – Additional query parameters for the img.shields.io URL.

Returns:

The image URL as a string.

prometa.git.gitlab.badges.latest_release module

Latest release badge.

class prometa.git.gitlab.badges.latest_release.LatestReleaseBadgeManager(gitlab_api)[source]

Bases: BadgeManager

The latest tagged release on the project’s GitLab host. This uses the built-in GitLab release badge.

NAME = 'Latest Release'[source]
property include[source]

The badge’s name is in the gitlab.enabled_badges list in the configuration file.

AND

The project’s GitLab CI file contains a release job.

property urls[source]

The link and image URLs for the badge.

prometa.git.gitlab.badges.license module

Project license.

class prometa.git.gitlab.badges.license.LicenseBadgeManager(gitlab_api)[source]

Bases: BadgeManager

The project’s license name, as recognized by SPDX.

NAME = 'License'[source]
property include[source]

The badge’s name is in the gitlab.enabled_badges list in the configuration file.

AND

The project has a recognized SPDX license.

property urls[source]

The link and image URLs for the badge.

prometa.git.gitlab.badges.pipeline_status module

Pipeline status badge.

class prometa.git.gitlab.badges.pipeline_status.PipelineStatusBadgeManager(gitlab_api)[source]

Bases: BadgeManager

The current pipeline status on the project’s GitLab host. This uses the built-in GitLab pipeline badge.

NAME = 'Pipeline Status'[source]
property include[source]

The badge’s name is in the gitlab.enabled_badges list in the configuration file.

AND

The GitLab CI configuration file exists.

property urls[source]

The link and image URLs for the badge.

prometa.git.gitlab.badges.test_coverage module

Test coverage badge.

class prometa.git.gitlab.badges.test_coverage.TestCoverageBadgeManager(gitlab_api)[source]

Bases: BadgeManager

Display the currently configured test coverage results.

NAME = 'Test Coverage'[source]
property include[source]

The badge’s name is in the gitlab.enabled_badges list in the configuration file.

AND

The project’s GitLab CI file contains test jobs with coverage fields.

property urls[source]

The link and image URLs for the badge.

Module contents

Manage project badges on GitLab.

class prometa.git.gitlab.badges.BadgeManager(gitlab_api)[source]

Bases: Registrable

Registrable base class for each badge manager.

NAME = None[source]
__init__(gitlab_api)[source]
Parameters:

gitlab_api – A GitLabApi instance.

create_badge(name, link_url, image_url)[source]

Create a new badge.

Parameters:
  • name – The badge name.

  • link_url – The badge link URL.

  • image_url – The badge image URL.

static delete_badge(badge)[source]

Delete a badge.

Parameters:

badge – A Badge instance.

property enabled[source]

The badge’s name is in the gitlab.enabled_badges list in the configuration file.

get_badge_by_name(name)[source]

Get a badge by name.

Parameters:

name – The name of the badge.

Returns:

The Badge instance, or None of not badge of the given name was found.

property gitlab_project[source]

The python-gitlab Project instance.

property include[source]

True if the condition for including this badge is met, else False. The configuration file determines of the badge is managed whereas this property determines if the badge is added or removed when the badge is managed.

manage()[source]

Manage the badge.

property project[source]

The Project instance.

static update_badge(badge, link_url, image_url)[source]

Update a badge if necessary.

Parameters:
  • badge – A Badge instance.

  • link_url – The badge link URL.

  • image_url – The badge image URL.

property urls[source]

The link and image URLs for the badge.

class prometa.git.gitlab.badges.GitLabBadgesMixin[source]

Bases: object

Mixin to handle badges in GitLabApi class.

get_badge_manager(name)[source]

Get an instance of the named BadgeManager subclass.

get_markdown_badges()[source]

Get an iterable over all badges as Markdown image links.

manage_badges()[source]

Add or remove badges depending on the current repository configuration.