Skip to content

Commit

Permalink
Updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
R1tschY committed Jan 4, 2020
1 parent 2db929c commit 418a291
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rpm/harbour-sailfishconnect.changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# * date Author's Name <author's email> version-release
# - Summary of changes

* Fri Jan 3 2020 Richard Liebscher <r1tschy@posteo.de> 0.5-1
* Sat Jan 04 2020 Richard Liebscher <r1tschy@posteo.de> 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
Expand Down
8 changes: 4 additions & 4 deletions scripts/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Path(__file__).parent.parent / "rpm" / "harbour-sailfishconnect.changes"
)
HEADER_RE = re.compile(
r"^\* (?P<date>\w+ \w+ \d+ \d+) (?P<author>[^<]+) <(?P<email>[^>]+)> (?P<version>[\w.~]+)-(?P<release>\d+)",
r"^\*\s+(?P<date>\w+\s+\w+\s+\d+\s+\d+)\s+(?P<author>[^<]+)\s+<(?P<email>[^>]+)>\s+(?P<version>[\w.~]+)-(?P<release>\d+)",
re.M,
)

Expand Down Expand Up @@ -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):
Expand All @@ -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())
)


Expand Down
9 changes: 4 additions & 5 deletions scripts/test_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -46,8 +46,7 @@ def test_release():
* Sat Mar 02 2000 the author <mail@example.org> 0.1-1
""")

date = format_datetime(datetime.datetime.now())
assert dedent("""
* {} the author <mail@example.org> 0.1-1
""".format(date)) == apply_inplace(changelog, release, [])
* Fri Jan 03 2020 the author <mail@example.org> 0.1-1
""") == apply_inplace(changelog, release, date=datetime.datetime(2020, 1, 3))

0 comments on commit 418a291

Please sign in to comment.