Skip to content

Support Python 3.x for changelog scripts. #1276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ target/
**/dependency-reduced-pom.xml

*.pyc
*.swp
2 changes: 1 addition & 1 deletion scripts/changelog/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from datetime import date

from model import ReleaseChanges, ChangelogEntry, Version
from changelog.model import ReleaseChanges, ChangelogEntry, Version


def version_cmp(a,b):
Expand Down
15 changes: 6 additions & 9 deletions scripts/changelog/writer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from git import stage_file
from util import load_all_released_changes, load_unreleased_changes, version_cmp

from changelog.git import stage_file
from changelog.util import load_all_released_changes, load_unreleased_changes, version_cmp
from functools import cmp_to_key

class ChangelogWriter(object):
"""
Expand Down Expand Up @@ -48,10 +48,7 @@ def group_entries(self):
self.categories.add(e.category)

def get_sorted_categories(self):
def category_cmp(a,b):
return cmp(a,b)

return sorted(list(self.categories), cmp=category_cmp)
return sorted(list(self.categories))

def is_service_category(self,s):
return s.lower() not in NON_SERVICE_CATEGORIES
Expand Down Expand Up @@ -106,7 +103,7 @@ def write(self, s):
def write_changelog():
unreleased = load_unreleased_changes(".changes/next-release")
released = load_all_released_changes(".changes")
released = sorted(released, key=lambda c: c.version, cmp=version_cmp)
released = sorted(released, key=lambda c: [c.version.major, c.version.minor, c.version.patch, c.version.prerelease_version_number()], reverse=True)

if unreleased is not None:
all_changes = [unreleased] + released
Expand All @@ -121,4 +118,4 @@ def write_changelog():
for changes in all_changes:
writer.write_changes(changes)

stage_file('CHANGELOG.md')
stage_file('CHANGELOG.md')
2 changes: 1 addition & 1 deletion scripts/finalize-release-changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import shutil
from changelog.git import stage_file
from changelog.util import load_unreleased_changes, marshall_release_changes, parse_version_string

VERSION_REGEX = re.compile('^[0-9]+\.[0-9]+\.[0-9]$')
VERSION_REGEX = re.compile('^[0-9]+\.[0-9]+\.[0-9]+$')
DATE_REGEX = re.compile('^[0-9]{4}-[0-9]{2}-[0-9]{2}$')

def validate_args(args):
Expand Down
2 changes: 1 addition & 1 deletion scripts/new-change
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def write_new_change(parsed_values):
category = parsed_values['category']
short_summary = ''.join(filter(lambda x: x in VALID_CHARS, category))
contents = json.dumps(parsed_values, indent=4) + "\n"
contents_digest = hashlib.sha1(contents).hexdigest()
contents_digest = hashlib.sha1(contents.encode('utf-8')).hexdigest()
filename = '{type_name}-{summary}-{digest}.json'.format(
type_name=parsed_values['type'],
summary=short_summary,
Expand Down