From c1dee13b20a2e85278e651ca67d28ead605cb599 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 19 Apr 2016 14:03:56 +1000 Subject: [PATCH] Sort versions by semver The ordering in the output file is currently string-ordering, which puts 1.10.0 before 1.2.0. Use semver ordering to get this in the right order. Change-Id: I27291789193b9ff872a56cbefcb8271c8a765127 --- tools/tag_history_from_git.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/tag_history_from_git.py b/tools/tag_history_from_git.py index a3a946c349..16c3f6e489 100755 --- a/tools/tag_history_from_git.py +++ b/tools/tag_history_from_git.py @@ -23,6 +23,8 @@ Use git as the canonical source of version numbers. from __future__ import print_function from __future__ import unicode_literals +from distutils.version import StrictVersion + import argparse import datetime import os @@ -119,7 +121,9 @@ for series, milestones in sorted(series_data.items()): f.write('---\n') f.write('launchpad: %s\n' % args.project) f.write('releases:\n') - for milestone, milestone_data in sorted(milestones.items()): + milestones_sorted = sorted(milestones.items(), + key=lambda x: StrictVersion(x[0])) + for milestone, milestone_data in milestones_sorted: f.write(' - version: %s\n' % milestone) f.write(' projects:\n') for repo_short_name, sha in milestone_data: