Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: sky/tools/roll_versions.py

Issue 1175393002: Teach roll_versions.py how to update CHANGELOG.md files. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/sdk/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tools/roll_versions.py
diff --git a/sky/tools/roll_versions.py b/sky/tools/roll_versions.py
index 0108cca01565ab86e134d8b9ea9babefade710fd..ec9adc7afb5eb8617925b6aa0c0dd141f1080614 100755
--- a/sky/tools/roll_versions.py
+++ b/sky/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')
« no previous file with comments | « sky/sdk/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698