mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
Merge pull request #372 from FrostyX/changelog-datetime
Add a possibility to have full datetime entries in changelog
This commit is contained in:
commit
6e1ebf4a3f
5 changed files with 60 additions and 10 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
|
||||
|
|
|
@ -25,15 +25,7 @@ from os.path import join
|
|||
from tito.common import run_command
|
||||
from tito.compat import * # NOQA
|
||||
from functional.fixture import TitoGitTestFixture, tito
|
||||
from unit import Capture
|
||||
|
||||
|
||||
# There is not many simple options to check on what distribution this is running.
|
||||
# Fortunately, we only need to check for Fedora Rawhide and EPEL6, so we can
|
||||
# determine it from python version. This is compatible for all distributions.
|
||||
import sys
|
||||
is_rawhide = sys.version_info[:2] >= (3, 8)
|
||||
is_epel6 = sys.version_info[:2] == (2, 6)
|
||||
from unit import Capture, is_epel6, is_rawhide
|
||||
|
||||
if is_epel6:
|
||||
import unittest2 as unittest
|
||||
|
|
|
@ -17,6 +17,14 @@ from contextlib import contextmanager
|
|||
from mock import patch, MagicMock
|
||||
from tito.compat import PY2, StringIO
|
||||
|
||||
|
||||
# There is not many simple options to check on what distribution this is running.
|
||||
# Fortunately, we only need to check for Fedora Rawhide and EPEL6, so we can
|
||||
# determine it from python version. This is compatible for all distributions.
|
||||
is_rawhide = sys.version_info[:2] >= (3, 8)
|
||||
is_epel6 = sys.version_info[:2] == (2, 6)
|
||||
|
||||
|
||||
file_spec = None
|
||||
|
||||
|
||||
|
|
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