Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tags): parse timezone information from a tag #425

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions gto/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from abc import ABC, abstractmethod
from collections import defaultdict
from contextlib import contextmanager
from datetime import datetime
from functools import wraps
from pathlib import Path
from typing import (
Expand Down Expand Up @@ -524,7 +523,7 @@ def update_state(
EnrichmentEvent(
artifact=artifact.artifact,
version=version.version,
created_at=datetime.fromtimestamp(commit.commit_time),
created_at=commit.commit_datetime,
author=commit.author_name,
author_email=commit.author_email,
commit_hexsha=commit.hexsha,
Expand All @@ -548,7 +547,7 @@ def update_state(
EnrichmentEvent(
artifact=artifact.artifact,
version=version.version,
created_at=datetime.fromtimestamp(commit.commit_time),
created_at=commit.commit_datetime,
author=commit.author_name,
author_email=commit.author_email,
commit_hexsha=commit.hexsha,
Expand Down
6 changes: 3 additions & 3 deletions gto/tag.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import datetime
import os
import re
from datetime import datetime
from enum import Enum
from typing import FrozenSet, Iterable, Optional, Union

Expand Down Expand Up @@ -124,7 +124,7 @@ class Tag(BaseModel):
name: str
version: Optional[str]
stage: Optional[str]
created_at: datetime
created_at: datetime.datetime
tag: GitTag

class Config:
Expand All @@ -134,7 +134,7 @@ class Config:
def parse_tag(tag: GitTag):
return Tag(
tag=tag,
created_at=datetime.fromtimestamp(tag.tag_time),
created_at=tag.tag_datetime,
**parse_name(tag.name),
)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import find_packages, setup

install_requires = [
"scmrepo>=1.3.1,<2",
"scmrepo>=1.4.0,<2",
"typer>=0.4.1",
"rich",
# pydantic.v1.parse_obj is broken in ==2.0.0:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"timestamp": "2022-05-26 23:49:52",
"timestamp": "2022-05-27 02:49:52+03:00",
"artifact": "churn",
"event": "assignment",
"priority": 5,
Expand All @@ -13,7 +13,7 @@
"ref": "churn#prod#2"
},
{
"timestamp": "2022-05-25 20:03:12",
"timestamp": "2022-05-25 23:03:12+03:00",
"artifact": "churn",
"event": "assignment",
"priority": 5,
Expand All @@ -26,7 +26,7 @@
"ref": "churn#staging#1"
},
{
"timestamp": "2022-05-24 16:16:32",
"timestamp": "2022-05-24 19:16:32+03:00",
"artifact": "churn",
"event": "registration",
"priority": 3,
Expand All @@ -39,7 +39,7 @@
"ref": "churn@v3.1.0"
},
{
"timestamp": "2022-05-20 01:09:52",
"timestamp": "2022-05-20 04:09:52+03:00",
"artifact": "churn",
"event": "registration",
"priority": 3,
Expand Down
10 changes: 9 additions & 1 deletion tests/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from gto.constants import Action
from gto.exceptions import RefNotFound, TagExists
from gto.tag import create_tag, find, name_tag, parse_name
from gto.tag import create_tag, find, name_tag, parse_name, parse_tag


def test_name_tag(scm: Git):
Expand Down Expand Up @@ -148,3 +148,11 @@ def test_create_tag_repeated_tagname(scm: Git):
def test_lightweight_tag(scm: Git):
scm.tag("lightweight-tag@v0.0.1")
assert find(scm=scm) == []


@pytest.mark.usefixtures("repo_with_commit")
def test_parse_tag_created_at_timezone(scm: Git):
create_tag(scm, "nn#prod", rev="HEAD", message="msg")
tag = parse_tag(scm.get_tag("nn#prod"))
d = tag.created_at
assert d.tzinfo is not None and d.tzinfo.utcoffset(d) is not None
Loading