Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8393338
swh-revhash
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
swh-revhash
View Options
#!/usr/bin/env python3
# Use:
# swh-revhash 'tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\nparent 22c0fa5195a53f2e733ec75a9b6e9d1624a8b771\nauthor seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\ncommitter seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\n\nmaking dir structure...\n' # noqa
# output: 17a631d474f49bbebfdf3d885dcde470d7faafd7
# To compare with git:
# git-revhash 'tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904\nparent 22c0fa5195a53f2e733ec75a9b6e9d1624a8b771\nauthor seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\ncommitter seanius <seanius@3187e211-bb14-4c82-9596-0b59d67cd7f4> 1138341044 +0000\n\nmaking dir structure...\n' # noqa
# output: 17a631d474f49bbebfdf3d885dcde470d7faafd7
import
sys
from
swh.model
import
hashutil
,
identifiers
def
revhash
(
revision_raw
):
"""Compute the revision hash."""
# HACK: string have somehow their \n expanded to \\n
if
b
"
\\
n"
in
revision_raw
:
revision_raw
=
revision_raw
.
replace
(
b
"
\\
n"
,
b
"
\n
"
)
h
=
hashutil
.
hash_git_data
(
revision_raw
,
"commit"
)
return
identifiers
.
identifier_to_str
(
h
)
if
__name__
==
"__main__"
:
revision_raw
=
sys
.
argv
[
1
]
.
encode
(
"utf-8"
)
print
(
revhash
(
revision_raw
))
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, Jun 4, 7:12 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3239313
Attached To
rDMOD Data model
Event Timeline
Log In to Comment