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
Renaud Boyer
swh-model
Commits
c6c0aed2
Commit
c6c0aed2
authored
9 years ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Patches
Plain Diff
identifiers: add release identifier computation
parent
ddf3f532
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/identifiers.py
+19
-0
19 additions, 0 deletions
swh/model/identifiers.py
swh/model/tests/test_identifiers.py
+58
-0
58 additions, 0 deletions
swh/model/tests/test_identifiers.py
with
77 additions
and
0 deletions
swh/model/identifiers.py
+
19
−
0
View file @
c6c0aed2
...
...
@@ -234,3 +234,22 @@ def revision_identifier(revision):
print
(
b
''
.
join
(
components
).
decode
(
'
utf-8
'
))
return
hashutil
.
hash_git_data
(
b
''
.
join
(
components
),
'
commit
'
)
def
release_identifier
(
release
):
"""
Return the intrinsic identifier for a release.
"""
components
=
[
b
'
object
'
,
identifier_to_str
(
release
[
'
revision
'
]).
encode
(),
b
'
\n
'
,
b
'
type commit
\n
'
,
b
'
tag
'
,
release
[
'
name
'
].
encode
(
'
utf-8
'
),
b
'
\n
'
,
]
if
'
author
'
in
release
and
release
[
'
author
'
]:
components
.
extend
([
b
'
tagger
'
,
format_author
(
release
[
'
author
'
]),
b
'
\n
'
,
])
components
.
extend
([
b
'
\n
'
,
release
[
'
comment
'
]])
print
(
b
''
.
join
(
components
).
decode
(
'
utf-8
'
))
return
hashutil
.
hash_git_data
(
b
''
.
join
(
components
),
'
tag
'
)
This diff is collapsed.
Click to expand it.
swh/model/tests/test_identifiers.py
+
58
−
0
View file @
c6c0aed2
...
...
@@ -211,3 +211,61 @@ class RevisionIdentifier(unittest.TestCase):
identifiers
.
revision_identifier
(
self
.
synthetic_revision
),
identifiers
.
identifier_to_str
(
self
.
synthetic_revision
[
'
id
'
]),
)
class
ReleaseIdentifier
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
release
=
{
'
id
'
:
'
2b10839e32c4c476e9d94492756bb1a3e1ec4aa8
'
,
'
revision
'
:
b
'
t
\x1b
"
R
\xa5\xe1
Ml`
\xa9\x13\xc7
z`
\x99\xab\xe7
:
\x85
J
'
,
'
name
'
:
'
v2.6.14
'
,
'
author
'
:
{
'
name
'
:
b
'
Linus Torvalds
'
,
'
email
'
:
b
'
torvalds@g5.osdl.org
'
,
'
date
'
:
datetime
.
datetime
(
2005
,
10
,
28
,
0
,
2
,
33
,
tzinfo
=
datetime
.
timezone
.
utc
),
'
date_offset
'
:
-
420
,
},
'
comment
'
:
b
'''
\
Linux 2.6.14 release
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBDYWq6F3YsRnbiHLsRAmaeAJ9RCez0y8rOBbhSv344h86l/VVcugCeIhO1
wdLOnvj91G4wxYqrvThthbE=
=7VeT
-----END PGP SIGNATURE-----
'''
,
'
synthetic
'
:
False
,
}
self
.
release_no_author
=
{
'
id
'
:
b
'
&y
\x1a\x8b\xcf\x0e
m3
\xf4
:
\xef
v
\x82\xbd\xb5
U#mV
\xde
'
,
'
revision
'
:
'
9ee1c939d1cb936b1f98e8d81aeffab57bae46ab
'
,
'
name
'
:
'
v2.6.12
'
,
'
comment
'
:
b
'''
\
This is the final 2.6.12 release
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQBCsykyF3YsRnbiHLsRAvPNAJ482tCZwuxp/bJRz7Q98MHlN83TpACdHr37
o6X/3T+vm8K3bf3driRr34c=
=sBHn
-----END PGP SIGNATURE-----
'''
,
'
synthetic
'
:
False
,
}
@istest
def
release_identifier
(
self
):
self
.
assertEqual
(
identifiers
.
release_identifier
(
self
.
release
),
identifiers
.
identifier_to_str
(
self
.
release
[
'
id
'
])
)
@istest
def
release_identifier_no_author
(
self
):
self
.
assertEqual
(
identifiers
.
release_identifier
(
self
.
release_no_author
),
identifiers
.
identifier_to_str
(
self
.
release_no_author
[
'
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