Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Dandrimont
swh-model
Commits
b54adf79
Verified
Commit
b54adf79
authored
5 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
model: Update revision date types to be optional
Related to P589
parent
57a0e089
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/model/model.py
+13
-5
13 additions, 5 deletions
swh/model/model.py
swh/model/tests/test_model.py
+16
-0
16 additions, 0 deletions
swh/model/tests/test_model.py
with
29 additions
and
5 deletions
swh/model/model.py
+
13
−
5
View file @
b54adf79
...
...
@@ -296,8 +296,8 @@ class Revision(BaseModel, HashableObject):
message
=
attr
.
ib
(
type
=
bytes
)
author
=
attr
.
ib
(
type
=
Person
)
committer
=
attr
.
ib
(
type
=
Person
)
date
=
attr
.
ib
(
type
=
TimestampWithTimezone
)
committer_date
=
attr
.
ib
(
type
=
TimestampWithTimezone
)
date
=
attr
.
ib
(
type
=
Optional
[
TimestampWithTimezone
]
)
committer_date
=
attr
.
ib
(
type
=
Optional
[
TimestampWithTimezone
]
)
type
=
attr
.
ib
(
type
=
RevisionType
)
directory
=
attr
.
ib
(
type
=
Sha1Git
)
synthetic
=
attr
.
ib
(
type
=
bool
)
...
...
@@ -314,12 +314,20 @@ class Revision(BaseModel, HashableObject):
@classmethod
def
from_dict
(
cls
,
d
):
d
=
d
.
copy
()
date
=
d
.
pop
(
'
date
'
)
if
date
:
date
=
TimestampWithTimezone
.
from_dict
(
date
)
committer_date
=
d
.
pop
(
'
committer_date
'
)
if
committer_date
:
committer_date
=
TimestampWithTimezone
.
from_dict
(
committer_date
)
return
cls
(
author
=
Person
.
from_dict
(
d
.
pop
(
'
author
'
)),
committer
=
Person
.
from_dict
(
d
.
pop
(
'
committer
'
)),
date
=
TimestampWithTimezone
.
from_dict
(
d
.
pop
(
'
date
'
)),
committer_date
=
TimestampWithTimezone
.
from_dict
(
d
.
pop
(
'
committer_date
'
)),
date
=
date
,
committer_date
=
committer_date
,
type
=
RevisionType
(
d
.
pop
(
'
type
'
)),
**
d
)
...
...
This diff is collapsed.
Click to expand it.
swh/model/tests/test_model.py
+
16
−
0
View file @
b54adf79
...
...
@@ -88,6 +88,22 @@ def test_revision_model_id_computation():
assert
rev_model
.
id
==
hash_to_bytes
(
revision_identifier
(
rev_dict
))
def
test_revision_model_id_computation_with_no_date
():
"""
We can have revision with date to None
"""
rev_dict
=
dict
(
revision_example
)
rev_dict
[
'
date
'
]
=
None
rev_dict
[
'
committer_date
'
]
=
None
del
rev_dict
[
'
id
'
]
rev_id
=
hash_to_bytes
(
revision_identifier
(
rev_dict
))
for
rev_model
in
[
Revision
(
**
rev_dict
),
Revision
.
from_dict
(
rev_dict
)]:
assert
rev_model
.
date
is
None
assert
rev_model
.
committer_date
is
None
assert
rev_model
.
id
==
rev_id
def
test_release_model_id_computation
():
rel_dict
=
dict
(
release_example
)
del
rel_dict
[
'
id
'
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment