Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P510
dulwich-based fake date git commit proto-prototype
Active
Public
Actions
Authored by
olasd
on Aug 20 2019, 2:40 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
#!/usr/bin/env python3
import
sys
import
dateutil.parser
import
dulwich.repo
def
commit
(
repo
,
timestamp
,
author
=
b
'Software Heritage <test@softwareheritage.org>'
,
message
=
'Commit test
\n
'
,
ref
=
b
'HEAD'
):
"""Commit the current working tree in a new commit with message on
the branch 'ref'.
At the end of the commit, the reference should stay the same
and the index should be clean.
"""
message
=
message
.
encode
()
ret
=
repo
.
do_commit
(
message
=
message
,
committer
=
author
,
commit_timestamp
=
timestamp
,
commit_timezone
=
0
,
ref
=
ref
)
return
ret
if
__name__
==
'__main__'
:
repo
=
dulwich
.
repo
.
Repo
(
'.'
)
date
=
sys
.
argv
[
1
]
timestamp
=
dateutil
.
parser
.
parse
(
date
)
.
timestamp
()
print
(
date
,
timestamp
)
commit
(
repo
,
timestamp
)
Event Timeline
olasd
created this paste.
Aug 20 2019, 2:40 PM
2019-08-20 14:40:05 (UTC+2)
Log In to Comment