Skip to content

Commit 864d809

Browse files
committed
Use my email, make util.py more general
1 parent c135ab0 commit 864d809

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

other-test-repos/many-commits.py

100644100755
+19-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env python3
22

33
"""
4-
You may want to create this in a tmpfs or ramfs, since deleting the generate repository can take a **huge** ammount of time.
4+
Packing is important, or else deleting and pushing the generated repository could take a **huge** ammount of time.
5+
6+
For extra safety, use a tmpfs or ramfs:
57
68
ulimit -Sv 500000
79
sudo umount tmp && \
@@ -21,9 +23,13 @@
2123

2224
import datetime
2325
import subprocess
26+
import time
2427

2528
import util
2629

30+
31+
name = b'Ciro Santilli'
32+
2733
util.init()
2834

2935
tree = util.create_tree_with_one_file()
@@ -32,8 +38,18 @@
3238
percent = (n / 100)
3339
p = 0
3440
for i in range(n):
35-
commit, _, _ = util.save_commit_object(tree, (commit,),
36-
message=(str(i).encode('ascii')))
41+
now = int(time.time())
42+
commit, _, _ = util.save_commit_object(
43+
tree,
44+
(commit,),
45+
author_date_s=now,
46+
author_email=email,
47+
author_name=name,
48+
committer_date_s=now,
49+
committer_email=email,
50+
committer_name=name,
51+
message=(str(i).encode('ascii')),
52+
)
3753
if i % percent == 0:
3854
print(p)
3955
print(datetime.datetime.now())

other-test-repos/util.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import subprocess
1010
import zlib
1111

12+
repo_dir = 'repo.tmp'
1213
git_dir = b'.git'
1314
objects_dir = os.path.join(git_dir, b'objects')
1415

@@ -22,24 +23,24 @@
2223
default_email = b'[email protected]'
2324
# 2000-01-01T00:00:00+0000
2425
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
2829
default_author_email = default_email
2930
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
3133
default_committer_email = default_email
3234
default_committer_name = default_name
3335
default_message = b'a'
3436
# ASCII hex of parents.
3537
default_parents = ()
3638

3739
def init():
38-
repo = 'tmp/repo.tmp'
39-
for d in (repo, 'clone.tmp'):
40+
for d in (repo_dir, 'clone.tmp'):
4041
shutil.rmtree(d, ignore_errors=True)
41-
os.mkdir(repo)
42-
os.chdir(repo)
42+
os.mkdir(repo_dir)
43+
os.chdir(repo_dir)
4344
subprocess.check_output(['git', 'init', '-q'])
4445

4546
def get_object_and_sha(obj_type, content):
@@ -66,21 +67,23 @@ def save_commit_object(
6667
parents=default_parents,
6768
author_name=default_author_name,
6869
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,
7072
committer_name=default_committer_name,
7173
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,
7376
message=default_message):
7477
if parents and parents[0]:
7578
parents_bytes = b''
7679
sep = b'\nparent '
7780
parents_bytes = sep + sep.join(parents) + b'\n'
7881
else:
7982
parents_bytes = b'\n'
80-
commit_content = b'tree %s%sauthor %s <%s> %s\ncommitter %s <%s> %s\n\n%s\n' % (
83+
commit_content = b'tree %s%sauthor %s <%s> %s %s\ncommitter %s <%s> %s %s\n\n%s\n' % (
8184
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,
8487
message)
8588
return save_object(b'commit', commit_content) + (commit_content,)
8689

0 commit comments

Comments
 (0)