idiap_devtools.gitlab.changelog#

Utilities for retrieving, parsing and auto-generating changelogs.

Functions

get_changes_since(gitpkg, since)

Gets the list of MRs, tags, and commits since the provided date.

get_file_from_gitlab(gitpkg, path[, ref])

Retrieves a file from a Gitlab repository.

get_last_tag_date(package)

Returns the last release date for the given package.

parse_date(s)

Parses any date supported by dateutil.parser.parse()

write_tags(f, gitpkg, since)

Writes all tags of a given package to the output file.

write_tags_with_commits(f, gitpkg, since, mode)

Writes all tags and commits of a given package to the output file.

idiap_devtools.gitlab.changelog.parse_date(s)[source]#

Parses any date supported by dateutil.parser.parse()

Automatically applies the “Europe/Zurich” timezone

Parameters:

s (TextIO | str) – The input readable stream or string to be parsed into a date

Return type:

datetime

Returns:

A datetime.datetime.

idiap_devtools.gitlab.changelog.get_file_from_gitlab(gitpkg, path, ref='main')[source]#

Retrieves a file from a Gitlab repository.

Parameters:
  • gitpkg (Project) – The gitlab project to fetch the datafile from

  • path (str) – The internal path to the file to retrieve

  • ref (str) – Branch, commit or reference to get file from, at GitLab

Return type:

StringIO

Returns:

A string I/O object you can use like a file.

idiap_devtools.gitlab.changelog.get_last_tag_date(package)[source]#

Returns the last release date for the given package.

Falls back to the first commit date if the package has not yet been tagged

Parameters:

package (Project) – The gitlab project object from where to fetch the last release date information

Return type:

datetime

Returns:

A datetime.datetime object that refers to the last date the package was released. If the package was never released, then returns the date just before the first commit.

Raises:

RuntimeError – if the project has no commits.

idiap_devtools.gitlab.changelog.get_changes_since(gitpkg, since)[source]#

Gets the list of MRs, tags, and commits since the provided date.

Parameters:
  • gitpkg (Project) – A gitlab package object

  • since (datetime) – a date and time to start looking changes from

Return type:

tuple[list[ProjectMergeRequest], list[ProjectTag], list[ProjectCommit]]

Returns:

A list of merge requests, tags and commits for the given package, since the determined date.

idiap_devtools.gitlab.changelog.write_tags_with_commits(f, gitpkg, since, mode)[source]#

Writes all tags and commits of a given package to the output file.

Parameters:
  • f (TextIO) – A stream ready to be written at

  • gitpkg (Project) – A pointer to the gitlab package object

  • since (datetime) – Starting date

  • mode (str) – One of mrs (merge-requests), commits or tags indicating how to list entries in the changelog for this package

Return type:

None

idiap_devtools.gitlab.changelog.write_tags(f, gitpkg, since)[source]#

Writes all tags of a given package to the output file.

Parameters:
  • f (TextIO) – A stream ready to be written at

  • gitpkg (Project) – A pointer to the gitlab package object

  • since (datetime) – Starting date

Return type:

None