From 46f27d72bf158ffdc4b60dff74176e3786995346 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.dos.anjos@gmail.com> Date: Tue, 22 Jan 2019 10:14:00 +0100 Subject: [PATCH] [release] Propose better default tags when no tags are available on the package --- bob/devtools/release.py | 15 +++++++++++++-- doc/release.rst | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bob/devtools/release.py b/bob/devtools/release.py index 5858bf55..a26b04a6 100644 --- a/bob/devtools/release.py +++ b/bob/devtools/release.py @@ -153,14 +153,25 @@ def get_parsed_tag(gitpkg, tag): # if we bump the version, we need to find the latest released version for # this package - if 'patch' == tag or 'minor' == tag or 'major' == tag: + if tag in ('major', 'minor', 'patch'): # find the correct latest tag of this package (without 'v' in front), # None if there are no tags yet latest_tag_name = get_latest_tag_name(gitpkg) # if there were no tags yet, assume the very first version - if not latest_tag_name: return 'v0.0.1' + if latest_tag_name is None: + if tag == 'major': + assume_version = 'v1.0.0' + elif tag == 'minor': + assume_version = 'v0.1.0' + elif tag == 'path': + assume_version = 'v0.0.1' + logger.warn('Package %s does not have any tags. I\'m assuming ' \ + 'version will be %s since you proposed a "%s" bump', + gitpkg.attributes['path_with_namespace'], assume_version, + tag) + return assume_version # check that it has expected format #.#.# # latest_tag_name = Version(latest_tag_name) diff --git a/doc/release.rst b/doc/release.rst index e83da16f..60d3e9cc 100644 --- a/doc/release.rst +++ b/doc/release.rst @@ -58,7 +58,9 @@ To manually update the changelog, follow these guidelines: version of this package will be automatically updated during the next tag/release. You can change ``patch`` to ``minor`` or ``major``, and the package will be then tagged/released with either minor or major version - bump. + bump. You may also set an explicit tag to the package (e.g. + ``v1.0.0``), which may be required if no tags are available yet on + gitlab. 3. Once all commits were changed to corresponding tag descriptions (no more lines start with ``-`` characters), this package is ready for release and you can continue to another package in the changelog. -- GitLab