diff --git a/CHANGELOG.md b/CHANGELOG.md index d6ecd56..e15089e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.2 + +- Fix bugs with and severely de-cruft Gitlab timestamp parsing + ## 2.0.1 - Fix issue where ASCII-only terminals cannot display progress bars diff --git a/assigner/backends/gitlab.py b/assigner/backends/gitlab.py index 81d09b4..f50ea9a 100644 --- a/assigner/backends/gitlab.py +++ b/assigner/backends/gitlab.py @@ -381,9 +381,20 @@ def get_last_HEAD_commit(self, ref="master"): # Gitlab's commit created_at time uses the git metadata; # rather than trusting students, we get the time the commit was pushed at if matching_pushes and HEAD['id'] == matching_pushes[0]['push_data']['commit_to']: - # For whatever reason, Gitlab uses a different time format here than for commits... - unmangled_time = matching_pushes[0]['created_at'][:-1] + "-0000" - HEAD['created_at'] = unmangled_time + created_at = matching_pushes[0]['created_at'] + + if created_at.endswith('Z'): # convert 'Z' to appropriate UTC offset + created_at = created_at[:-1] + "-0000" + else: + # Fix UTC offset format in GitLab's datetime: prior to py3.7, UTC offsets could not contain colons + # timezone specifier starts with - or +; look for - first and if that fails then look for + + tz_start = created_at.rfind('-') + if tz_start == -1: + tz_start = created_at.rfind('+') + if tz_start != -1: + created_at = created_at[:tz_start] + created_at[tz_start:].replace(':', '') + + HEAD['created_at'] = created_at return HEAD diff --git a/assigner/commands/status.py b/assigner/commands/status.py index a515dc4..3db9727 100644 --- a/assigner/commands/status.py +++ b/assigner/commands/status.py @@ -86,11 +86,6 @@ def status(conf, backend, args): row[6] = head["short_id"] row[7] = head["author_name"] created_at = head["created_at"] - # Fix UTC offset format in GitLab's datetime: prior to py3.7, UTC offsets could not contain colons - created_at = created_at[:-7] + created_at[-7:].replace(':', '') - # Remove odd postfix and add missing 0 to UTC offset - if created_at.endswith('-0000'): - created_at = created_at[:-5] + '0' row[8] = datetime.strptime( created_at, "%Y-%m-%dT%H:%M:%S.%f%z" ).astimezone().strftime("%c") diff --git a/requirements.txt b/requirements.txt index 311496f..910ef1f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ pyapi-gitlab==7.8.5 pyflakes==2.1.1 requests==2.21.0 six==1.12 -smmap==0.9.0 +smmap==3.0.1 wheel==0.24.0 PTable==0.9.2 progressbar2==3.10.1