Merge ~racb/git-ubuntu:changelog-date-edge-cases into git-ubuntu:main

Proposed by Robie Basak
Status: Merged
Approved by: Robie Basak
Approved revision: f24300f657a413c91be9c222478a0bb9498d380d
Merged at revision: 66cd050ce92c1a0960a22aae0336f0165a6e468c
Proposed branch: ~racb/git-ubuntu:changelog-date-edge-cases
Merge into: git-ubuntu:main
Diff against target: 75 lines (+38/-7)
2 files modified
gitubuntu/git_repository.py (+27/-7)
gitubuntu/git_repository_test.py (+11/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Bryce Harrington Approve
Canonical Server Reporter Pending
Review via email: mp+431516@code.launchpad.net

Commit message

Make Jenkins happy

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:f24300f657a413c91be9c222478a0bb9498d380d
https://jenkins.canonical.com/server-team/job/git-ubuntu-ci/15/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: VM Reset
    SUCCESS: Unit Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.canonical.com/server-team/job/git-ubuntu-ci/15//rebuild

review: Approve (continuous-integration)
Revision history for this message
Bryce Harrington (bryce) wrote :

"abbreviation" -> "abbreviations"

Grammatically three 'as' in the same sentence reads funny, but the comment is perfectly comprehensible. I might suggest changing the third 'as' to 'since'.

Otherwise LGTM, +1.

review: Approve
Revision history for this message
Robie Basak (racb) wrote :

Thanks! I've adopted all your suggestions. I also fixed a minor docstring omission I noticed. I'll just wait for CI to pass, then merge.

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:66cd050ce92c1a0960a22aae0336f0165a6e468c
https://jenkins.canonical.com/server-team/job/git-ubuntu-ci/16/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: VM Reset
    SUCCESS: Unit Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.canonical.com/server-team/job/git-ubuntu-ci/16//rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/gitubuntu/git_repository.py b/gitubuntu/git_repository.py
index 2c2a3da..27ed645 100644
--- a/gitubuntu/git_repository.py
+++ b/gitubuntu/git_repository.py
@@ -517,6 +517,23 @@ def unescape_dot_git(path):
517class ChangelogError(Exception):517class ChangelogError(Exception):
518 pass518 pass
519519
520
521def _apply_re_substitutions(original_string, subs):
522 """Apply a sequence of regular expression substitutions to a string
523
524 :param str original_string: the string to which to apply substitutions
525 :param list(str, str) subs: a list of substitutions to apply. The first
526 element of each tuple is the regexp to match, and the second is what to
527 replace it with.
528 :rtype: str
529 :returns: the original string but altered by all the substitutions
530 """
531 changed_string = original_string
532 for regex, replacement in subs:
533 changed_string = re.sub(regex, replacement, changed_string)
534 return changed_string
535
536
520class Changelog:537class Changelog:
521 '''Representation of a debian/changelog file found inside a git tree-ish538 '''Representation of a debian/changelog file found inside a git tree-ish
522539
@@ -792,14 +809,17 @@ class Changelog:
792 # time.strptime ignores time zones, so we must use datetime.strptime()809 # time.strptime ignores time zones, so we must use datetime.strptime()
793810
794 # strptime doesn't support anything other than standard locale names811 # strptime doesn't support anything other than standard locale names
795 # for days of the week, so handle the "Thur" abbreviation as a special812 # for days of the week, so handle "Thur", "Thurs", "Tues" and "Sept"
796 # case as defined in the spec as it is unambiguous.813 # abbreviations as special cases as defined in the spec since they are
797 adjusted_changelog_timestamp_string = re.sub(814 # unambiguous.
798 r'^Thur,',815 adjusted_changelog_timestamp_string = _apply_re_substitutions(
799 'Thu,',816 original_string=changelog_timestamp_string,
800 changelog_timestamp_string,817 subs=[
818 (r'^Thur(s)?,', 'Thu,'),
819 (r'^Tues,', 'Tue,'),
820 (r'\bSept\b', 'Sep'),
821 ],
801 )822 )
802
803 acceptable_date_formats = [823 acceptable_date_formats = [
804 '%a, %d %b %Y %H:%M:%S %z', # standard824 '%a, %d %b %Y %H:%M:%S %z', # standard
805 '%A, %d %b %Y %H:%M:%S %z', # full day of week825 '%A, %d %b %Y %H:%M:%S %z', # full day of week
diff --git a/gitubuntu/git_repository_test.py b/gitubuntu/git_repository_test.py
index 838c31e..05bc157 100644
--- a/gitubuntu/git_repository_test.py
+++ b/gitubuntu/git_repository_test.py
@@ -136,6 +136,17 @@ def test_changelog_multiple_angle_brackets():
136 # Part-abbreviated day of week name, such as in:136 # Part-abbreviated day of week name, such as in:
137 # kubuntu-meta 1.76137 # kubuntu-meta 1.76
138 ('Thur, 15 May 2016 08:14:34 -0700', (2016, 5, 15, 8, 14, 34, -7)),138 ('Thur, 15 May 2016 08:14:34 -0700', (2016, 5, 15, 8, 14, 34, -7)),
139 # apachetop 0.12.5-7
140 ('Thurs, 12 Jan 2006 12:09:58 +0000', (2006, 1, 12, 12, 9, 58, 0)),
141 # easychem 0.6-0ubuntu1
142 ('Tues, 20 Dec 2005 16:57:16 -0500', (2005, 12, 20, 16, 57, 16, -5)),
143 # Part-abbreviated month name, such as in:
144 # libapp-cache-perl 0.35-1
145 ('Wed, 24 Sept 2008 19:32:23 +0200', (2008, 9, 24, 19, 32, 23, 2)),
146 # libcrypt-hcesha-perl 0.70-2
147 ('Wed, 24 Sept 2008 19:44:01 +0200', (2008, 9, 24, 19, 44, 1, 2)),
148 # gnome-shell-extension-tilix-shortcut 1.0.1-1
149 ('Tue, 19 Sept 2017 14:23:17 +0200', (2017, 9, 19, 14, 23, 17, 2)),
139])150])
140def test_parse_changelog_date(input_date_string, expected_result):151def test_parse_changelog_date(input_date_string, expected_result):
141 """_parse_changelog_date should parse a basic date string correctly152 """_parse_changelog_date should parse a basic date string correctly

Subscribers

People subscribed via source and target branches