From b164b86e358165b65f80dbbcd6c6fabe006b52bf Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Thu, 11 Jun 2015 12:48:33 -0700 Subject: [PATCH] Teach roll_versions.py how to update CHANGELOG.md files. This is feature creep. But it was simple and fun. :p R=abarth@chromium.org Review URL: https://codereview.chromium.org/1175393002. --- apk/demo/AndroidManifest.xml | 2 +- sdk/CHANGELOG.md | 4 ++++ sdk/pubspec.yaml | 2 +- tools/roll_versions.py | 32 +++++++++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/apk/demo/AndroidManifest.xml b/apk/demo/AndroidManifest.xml index 39ed421aa49..59b57990922 100644 --- a/apk/demo/AndroidManifest.xml +++ b/apk/demo/AndroidManifest.xml @@ -3,7 +3,7 @@ Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. --> - + diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index e723b223f2a..14c577a7294 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.10 + + - 23 changes: https://github.com/domokit/mojo/compare/1b7bcee...be9dad7 + ## 0.0.8 - Fix 2 crashes in SkyDemo.apk, updated widgets. 0.0.7 was skipped. diff --git a/sdk/pubspec.yaml b/sdk/pubspec.yaml index 3b853260eaa..3b7a9666fd0 100644 --- a/sdk/pubspec.yaml +++ b/sdk/pubspec.yaml @@ -6,4 +6,4 @@ dependencies: description: Dart files to support executing inside Sky. homepage: https://github.com/domokit/mojo/tree/master/sky name: sky -version: 0.0.9 +version: 0.0.10 diff --git a/tools/roll_versions.py b/tools/roll_versions.py index 0108cca0156..ec9adc7afb5 100755 --- a/tools/roll_versions.py +++ b/tools/roll_versions.py @@ -3,9 +3,12 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import os +import subprocess import yaml import xml.etree.ElementTree as ET + PUBSPECS = [ 'sky/sdk/pubspec.yaml', 'mojo/public/dart/pubspec.yaml', @@ -38,6 +41,15 @@ def sort_dict(unsorted): return sorted_dict +def count_commits(start, end): + return subprocess.check_output([ + 'git', 'rev-list', '%s...%s' % (start, end)]).count('\n') + + +def last_commit_to(file_path): + return subprocess.check_output(['git', 'log', '-1', '--format=%h', file_path]).strip() + + def update_pubspec(pubspec): # TODO(eseidel): This does not prserve any manual sort-order of the yaml. with open(pubspec, 'r') as stream: @@ -48,6 +60,20 @@ def update_pubspec(pubspec): with open(pubspec, 'w') as stream: yaml.dump(spec, stream=stream, default_flow_style=False) + return spec['version'] + + +def update_changelog(changelog, pubspec, version): + old = last_commit_to(pubspec) + new = last_commit_to('.') + url = "https://github.com/domokit/mojo/compare/%s...%s" % (old, new) + count = count_commits(old, new) + message = """## %s + + - %s changes: %s + +""" % (version, count, url) + prepend_to_file(message, changelog) def prepend_to_file(to_prepend, filepath): @@ -77,9 +103,13 @@ def update_manifest(manifest): def main(): + # Should chdir to the root directory. + print 'Pub packages:' for pubspec in PUBSPECS: - update_pubspec(pubspec) + new_version = update_pubspec(pubspec) + changelog = os.path.join(os.path.dirname(pubspec), 'CHANGELOG.md') + update_changelog(changelog, pubspec, new_version) # TODO(eseidel): Without this ET uses 'ns0' for 'android' which is wrong. ET.register_namespace('android', 'http://schemas.android.com/apk/res/android')