From ebab6d60ea846d3bbddadae4fb336407f82d984e Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Tue, 18 Feb 2020 09:29:07 +0100
Subject: [PATCH] Always add bob.devtools to the output of changelog

---
 bob/devtools/scripts/changelog.py | 34 +++++++++++++++----------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/bob/devtools/scripts/changelog.py b/bob/devtools/scripts/changelog.py
index 186b4e35..12813737 100644
--- a/bob/devtools/scripts/changelog.py
+++ b/bob/devtools/scripts/changelog.py
@@ -22,41 +22,39 @@ Examples:
 
   1. Generates the changelog for a single package using merge requests:
 
-     $ bdt gitlab changelog group/package.xyz changelog.md
+     $ bdt gitlab changelog -vvv group/package.xyz changelog.md
 
 
   2. The same as above, but dumps the changelog to stdout instead of a file:
 
-     $ bdt gitlab changelog group/package.xyz
+     $ bdt gitlab changelog -vvv group/package.xyz
 
 
   3. Generates the changelog for a single package looking at commits
      (not merge requests):
 
-     $ bdt gitlab changelog --mode=commits group/package.xyz changelog.md
+     $ bdt gitlab changelog -vvv --mode=commits group/package.xyz changelog.md
 
 
   4. Generates the changelog for a single package looking at merge requests starting from a given date of January 1, 2016:
 
 \b
-     $ bdt gitlab changelog --mode=mrs --since=2016-01-01 group/package.xyz changelog.md
+     $ bdt gitlab changelog -vvv --mode=mrs --since=2016-01-01 group/package.xyz changelog.md
 
 
-  5. Generates a complete list of changelogs for a list of packages (one per line:
+  5. Generates a complete list of changelogs for a list of packages (one per line):
 
 \b
      $ bdt gitlab getpath bob/bob.nightlies order.txt
      $ bdt gitlab lasttag bob/bob
      # copy and paste date to next command
-     $ bdt gitlab changelog --since="2018-07-17 10:23:40" order.txt changelog.md
+     $ bdt gitlab changelog -vvv --since="2018-07-17 10:23:40" order.txt changelog.md
 """
 )
 @click.argument("target")
 @click.argument(
     "changelog",
-    type=click.Path(
-        exists=False, dir_okay=False, file_okay=True, writable=True
-    ),
+    type=click.Path(exists=False, dir_okay=False, file_okay=True, writable=True),
     required=False,
 )
 @click.option(
@@ -102,9 +100,9 @@ def changelog(target, changelog, group, mode, since):
     an existing file containing a list of packages that will be iterated on.
 
     For each package, we will contact the Gitlab server and create a changelog
-                using merge-requests (default), tags or commits since a given date.  If a
-                starting date is not passed, we'll use the date of the last tagged value or
-                the date of the first commit, if no tags are available in the package.
+    using merge-requests (default), tags or commits since a given date.  If a
+    starting date is not passed, we'll use the date of the last tagged value or
+    the date of the first commit, if no tags are available in the package.
     """
 
     gl = get_gitlab_instance()
@@ -119,15 +117,17 @@ def changelog(target, changelog, group, mode, since):
                 if k.strip() and not k.strip().startswith("#")
             ]
     else:
-        logger.info(
-            "Assuming %s is a package name (file does not exist)...", target
-        )
+        logger.info("Assuming %s is a package name (file does not exist)...", target)
         packages = [target]
 
     # if the user passed a date, convert it
     if since:
         since = parse_date(since)
 
+    # Since tagging packages requires bob.devtools to be tagged first. Add that to the
+    # list as well. Note that bob.devtools can release itself.
+    packages.insert(0, "bob/bob.devtools")
+
     # iterates over the packages and dumps required information
     for package in packages:
 
@@ -179,7 +179,5 @@ def changelog(target, changelog, group, mode, since):
             changelog_file = open(changelog, "at")
 
         # write_tags(f, use_package, last_release_date)
-        write_tags_with_commits(
-            changelog_file, use_package, last_release_date, mode
-        )
+        write_tags_with_commits(changelog_file, use_package, last_release_date, mode)
         changelog_file.flush()
-- 
GitLab