9
9
import subprocess
10
10
import zlib
11
11
12
+ repo_dir = 'repo.tmp'
12
13
git_dir = b'.git'
13
14
objects_dir = os .path .join (git_dir , b'objects' )
14
15
22
23
default_email = b'[email protected] '
23
24
# 2000-01-01T00:00:00+0000
24
25
default_date_s = 946684800
25
- default_date_format = b'%s +0000'
26
- default_date = b'%s +0000' % str ( default_date_s ). encode ( 'ascii' )
27
- default_author_date = default_date
26
+ default_tz = b'+0000'
27
+ default_author_date_s = default_date_s
28
+ default_author_date_tz = default_tz
28
29
default_author_email = default_email
29
30
default_author_name = default_name
30
- default_committer_date = default_date
31
+ default_committer_date_s = default_date_s
32
+ default_committer_date_tz = default_tz
31
33
default_committer_email = default_email
32
34
default_committer_name = default_name
33
35
default_message = b'a'
34
36
# ASCII hex of parents.
35
37
default_parents = ()
36
38
37
39
def init ():
38
- repo = 'tmp/repo.tmp'
39
- for d in (repo , 'clone.tmp' ):
40
+ for d in (repo_dir , 'clone.tmp' ):
40
41
shutil .rmtree (d , ignore_errors = True )
41
- os .mkdir (repo )
42
- os .chdir (repo )
42
+ os .mkdir (repo_dir )
43
+ os .chdir (repo_dir )
43
44
subprocess .check_output (['git' , 'init' , '-q' ])
44
45
45
46
def get_object_and_sha (obj_type , content ):
@@ -66,21 +67,23 @@ def save_commit_object(
66
67
parents = default_parents ,
67
68
author_name = default_author_name ,
68
69
author_email = default_author_email ,
69
- author_date = default_author_date ,
70
+ author_date_s = default_author_date_s ,
71
+ author_date_tz = default_author_date_tz ,
70
72
committer_name = default_committer_name ,
71
73
committer_email = default_committer_email ,
72
- committer_date = default_committer_date ,
74
+ committer_date_s = default_committer_date_s ,
75
+ committer_date_tz = default_committer_date_tz ,
73
76
message = default_message ):
74
77
if parents and parents [0 ]:
75
78
parents_bytes = b''
76
79
sep = b'\n parent '
77
80
parents_bytes = sep + sep .join (parents ) + b'\n '
78
81
else :
79
82
parents_bytes = b'\n '
80
- commit_content = b'tree %s%sauthor %s <%s> %s\n committer %s <%s> %s\n \n %s\n ' % (
83
+ commit_content = b'tree %s%sauthor %s <%s> %s %s \n committer %s <%s> %s %s\n \n %s\n ' % (
81
84
tree_sha_ascii , parents_bytes ,
82
- author_name , author_email , author_date ,
83
- committer_name , committer_email , committer_date ,
85
+ author_name , author_email , str ( author_date_s ). encode ( 'ascii' ), author_date_tz ,
86
+ committer_name , committer_email , str ( committer_date_s ). encode ( 'ascii' ), committer_date_tz ,
84
87
message )
85
88
return save_object (b'commit' , commit_content ) + (commit_content ,)
86
89
0 commit comments