mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
Add a possibility to have full datetime entries in changelog
Fix #305 Unfortunatelly we need to use `pytz` instead of `datetime.timezone` because of python2.
This commit is contained in:
parent
a72d4fbe50
commit
219efc50a2
3 changed files with 51 additions and 1 deletions
|
@ -68,7 +68,7 @@ class VersionTagger(ConfigObject):
|
|||
self.spec_file_name)
|
||||
self.keep_version = keep_version
|
||||
|
||||
self.today = strftime("%a %b %d %Y")
|
||||
self.today = self._changelog_date()
|
||||
(self.git_user, self.git_email) = self._get_git_user_info()
|
||||
git_email = self.git_email
|
||||
if git_email is None:
|
||||
|
@ -163,6 +163,12 @@ class VersionTagger(ConfigObject):
|
|||
print
|
||||
undo_tag(tag)
|
||||
|
||||
def _changelog_date(self):
|
||||
option = (BUILDCONFIG_SECTION, "changelog_date_with_time")
|
||||
if self.config.has_option(*option) and self.config.getboolean(*option):
|
||||
return strftime("%a %b %d %T %Z %Y")
|
||||
return strftime("%a %b %d %Y")
|
||||
|
||||
def _changelog_remove_cherrypick(self, line):
|
||||
"""
|
||||
remove text "(cherry picked from commit ..." from line unless
|
||||
|
|
38
test/unit/tagger_tests.py
Normal file
38
test/unit/tagger_tests.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
import unittest
|
||||
import mock
|
||||
from datetime import datetime
|
||||
from tito.tagger import VersionTagger
|
||||
from tito.compat import PY2, RawConfigParser
|
||||
|
||||
from unit import is_epel6
|
||||
if is_epel6:
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
|
||||
|
||||
def strftime_mock(s):
|
||||
if not PY2:
|
||||
from datetime import timezone
|
||||
tzinfo = None if PY2 else timezone.utc
|
||||
someday = datetime(2020, 4, 22, 15, 2, tzinfo=tzinfo)
|
||||
return someday.strftime(s)
|
||||
|
||||
|
||||
class TestVersionTagger(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.config = RawConfigParser()
|
||||
|
||||
@mock.patch("tito.tagger.main.strftime", strftime_mock)
|
||||
def test_today(self):
|
||||
tagger = VersionTagger(self.config)
|
||||
assert tagger.today == "Wed Apr 22 2020"
|
||||
|
||||
@unittest.skipIf(PY2, "It is not trivial to represent timezone in python2 because"
|
||||
"datetime.timezone is python3 only and pytz is not in EPEL. This feature"
|
||||
"is for F27+ and EPEL8+ so we don't need to test it for python2")
|
||||
@mock.patch("tito.tagger.main.strftime", strftime_mock)
|
||||
def test_today_datetime(self):
|
||||
self.config["buildconfig"] = {"changelog_date_with_time": True}
|
||||
tagger = VersionTagger(self.config)
|
||||
assert tagger.today == "Wed Apr 22 15:02:00 UTC 2020"
|
|
@ -69,6 +69,12 @@ changelog_do_not_remove_cherrypick::
|
|||
If set to 0, it will not remove from cherry picked commits the part "(cherry
|
||||
picked from commit ...)"
|
||||
|
||||
changelog_date_with_time::
|
||||
By default, changelog dates don't contain time (e.g. Wed Nov 1 2017). When
|
||||
this option is set to `True`, changelog entries are generated in a datetime
|
||||
format (e.g. Wed Nov 1 11:08:13 EDT 2017). This feature requires RPM 4.14,
|
||||
therefore it is supported only on Fedora 27, EPEL8, openSUSE Leap 15 and higher.
|
||||
|
||||
tag_suffix::
|
||||
An optional specification of a suffix to append to all tags created by tito
|
||||
for this repo. Can be useful for situations where one git repository is
|
||||
|
|
Loading…
Add table
Reference in a new issue