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
1diff --git a/gitubuntu/git_repository.py b/gitubuntu/git_repository.py
2index 2c2a3da..27ed645 100644
3--- a/gitubuntu/git_repository.py
4+++ b/gitubuntu/git_repository.py
5@@ -517,6 +517,23 @@ def unescape_dot_git(path):
6 class ChangelogError(Exception):
7 pass
8
9+
10+def _apply_re_substitutions(original_string, subs):
11+ """Apply a sequence of regular expression substitutions to a string
12+
13+ :param str original_string: the string to which to apply substitutions
14+ :param list(str, str) subs: a list of substitutions to apply. The first
15+ element of each tuple is the regexp to match, and the second is what to
16+ replace it with.
17+ :rtype: str
18+ :returns: the original string but altered by all the substitutions
19+ """
20+ changed_string = original_string
21+ for regex, replacement in subs:
22+ changed_string = re.sub(regex, replacement, changed_string)
23+ return changed_string
24+
25+
26 class Changelog:
27 '''Representation of a debian/changelog file found inside a git tree-ish
28
29@@ -792,14 +809,17 @@ class Changelog:
30 # time.strptime ignores time zones, so we must use datetime.strptime()
31
32 # strptime doesn't support anything other than standard locale names
33- # for days of the week, so handle the "Thur" abbreviation as a special
34- # case as defined in the spec as it is unambiguous.
35- adjusted_changelog_timestamp_string = re.sub(
36- r'^Thur,',
37- 'Thu,',
38- changelog_timestamp_string,
39+ # for days of the week, so handle "Thur", "Thurs", "Tues" and "Sept"
40+ # abbreviations as special cases as defined in the spec since they are
41+ # unambiguous.
42+ adjusted_changelog_timestamp_string = _apply_re_substitutions(
43+ original_string=changelog_timestamp_string,
44+ subs=[
45+ (r'^Thur(s)?,', 'Thu,'),
46+ (r'^Tues,', 'Tue,'),
47+ (r'\bSept\b', 'Sep'),
48+ ],
49 )
50-
51 acceptable_date_formats = [
52 '%a, %d %b %Y %H:%M:%S %z', # standard
53 '%A, %d %b %Y %H:%M:%S %z', # full day of week
54diff --git a/gitubuntu/git_repository_test.py b/gitubuntu/git_repository_test.py
55index 838c31e..05bc157 100644
56--- a/gitubuntu/git_repository_test.py
57+++ b/gitubuntu/git_repository_test.py
58@@ -136,6 +136,17 @@ def test_changelog_multiple_angle_brackets():
59 # Part-abbreviated day of week name, such as in:
60 # kubuntu-meta 1.76
61 ('Thur, 15 May 2016 08:14:34 -0700', (2016, 5, 15, 8, 14, 34, -7)),
62+ # apachetop 0.12.5-7
63+ ('Thurs, 12 Jan 2006 12:09:58 +0000', (2006, 1, 12, 12, 9, 58, 0)),
64+ # easychem 0.6-0ubuntu1
65+ ('Tues, 20 Dec 2005 16:57:16 -0500', (2005, 12, 20, 16, 57, 16, -5)),
66+ # Part-abbreviated month name, such as in:
67+ # libapp-cache-perl 0.35-1
68+ ('Wed, 24 Sept 2008 19:32:23 +0200', (2008, 9, 24, 19, 32, 23, 2)),
69+ # libcrypt-hcesha-perl 0.70-2
70+ ('Wed, 24 Sept 2008 19:44:01 +0200', (2008, 9, 24, 19, 44, 1, 2)),
71+ # gnome-shell-extension-tilix-shortcut 1.0.1-1
72+ ('Tue, 19 Sept 2017 14:23:17 +0200', (2017, 9, 19, 14, 23, 17, 2)),
73 ])
74 def test_parse_changelog_date(input_date_string, expected_result):
75 """_parse_changelog_date should parse a basic date string correctly

Subscribers

People subscribed via source and target branches