diff --git a/rpm/harbour-sailfishconnect.changes b/rpm/harbour-sailfishconnect.changes index 02678f6..3800258 100644 --- a/rpm/harbour-sailfishconnect.changes +++ b/rpm/harbour-sailfishconnect.changes @@ -1,7 +1,7 @@ # * date Author's Name version-release # - Summary of changes -* Fri Jan 3 2020 Richard Liebscher 0.5-1 +* Sat Jan 04 2020 Richard Liebscher 0.5-1 - Added Contacts plugin. - Resolve Phonenumbers to contact names in telephony plugin. - Starts now at system start as systemd user service when in background mode diff --git a/scripts/changelog.py b/scripts/changelog.py index 74ee07e..522e94e 100755 --- a/scripts/changelog.py +++ b/scripts/changelog.py @@ -29,7 +29,7 @@ Path(__file__).parent.parent / "rpm" / "harbour-sailfishconnect.changes" ) HEADER_RE = re.compile( - r"^\* (?P\w+ \w+ \d+ \d+) (?P[^<]+) <(?P[^>]+)> (?P[\w.~]+)-(?P\d+)", + r"^\*\s+(?P\w+\s+\w+\s+\d+\s+\d+)\s+(?P[^<]+)\s+<(?P[^>]+)>\s+(?P[\w.~]+)-(?P\d+)", re.M, ) @@ -94,7 +94,7 @@ def find_first_header(changelog: str) -> ChangelogHeader: def format_datetime(datetime): locale.setlocale(locale.LC_ALL, "C") - return datetime.strftime("%a %b %e %Y") + return datetime.strftime("%a %b %d %Y") def apply_commandfn(fn, args): @@ -110,12 +110,12 @@ def apply_commandfn(fn, args): fp.write(changelog[change.end:]) -def release(changelog: str, args) -> Change: +def release(changelog: str, args, date=None) -> Change: header = find_first_header(changelog) return Change( start=header.date_loc[0], end=header.date_loc[1], - replacement=format_datetime(datetime.datetime.now()) + replacement=format_datetime(date or datetime.datetime.now()) ) diff --git a/scripts/test_changelog.py b/scripts/test_changelog.py index 1afcc5e..93c7cb1 100644 --- a/scripts/test_changelog.py +++ b/scripts/test_changelog.py @@ -21,8 +21,8 @@ import datetime -def apply_inplace(text, fn, args): - change = fn(changelog=text, args=args) +def apply_inplace(text, fn, *args, **kwargs): + change = fn(changelog=text, args=args, **kwargs) if change: return text[:change.start] + change.replacement + text[change.end:] else: @@ -46,8 +46,7 @@ def test_release(): * Sat Mar 02 2000 the author 0.1-1 """) - date = format_datetime(datetime.datetime.now()) assert dedent(""" - * {} the author 0.1-1 - """.format(date)) == apply_inplace(changelog, release, []) + * Fri Jan 03 2020 the author 0.1-1 + """) == apply_inplace(changelog, release, date=datetime.datetime(2020, 1, 3))