diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-08-06 19:10:59 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-08-06 19:10:59 +0100 |
| commit | 7aee6a2be4a0d0dd46ff8ccf27212446adf7ae23 (patch) | |
| tree | 67cae6376c80f25406733a361f7dc1411ca6d361 | |
| parent | 5571f25c0d930d776174da8307c398ff7b0d281c (diff) | |
Allow extraction of latest versions of different major releases.working-dir-changes
| -rwxr-xr-x | cdist | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -558,6 +558,7 @@ parser.add_argument('-p', '--project', help='project name') parser.add_argument('-d', '--directory', help='directory within project repo', default='.') parser.add_argument('--minor', help='minor version number bump', action='store_true') parser.add_argument('--micro', help='micro version number bump', action='store_true') +parser.add_argument('--major', help='major version to return with latest', type=int) parser.add_argument('-c', '--checkout', help='string to pass to git for checkout') parser.add_argument('-o', '--output', help='output directory', default='.') parser.add_argument('-q', '--quiet', help='be quiet', action='store_true') @@ -724,17 +725,20 @@ elif args.command == 'latest': project.checkout(target) f = command_and_read('git log --tags --simplify-by-decoration --pretty="%d"') - t = f.readline() - m = re.compile(".*\((.*)\).*").match(t) latest = None - if m: - tags = m.group(1).split(', ') - for t in tags: - s = t.split() - if len(s) > 1: - t = s[1] - if len(t) > 0 and t[0] == 'v': - latest = t[1:] + while latest is None: + t = f.readline() + m = re.compile(".*\((.*)\).*").match(t) + if m: + tags = m.group(1).split(', ') + for t in tags: + s = t.split() + if len(s) > 1: + t = s[1] + if len(t) > 0 and t[0] == 'v': + v = Version(t[1:]) + if args.major is None or v.major == args.major: + latest = v print latest target.cleanup() |
